kaby76 / Trash

Toolkit for grammars
MIT License
74 stars 5 forks source link

bugfix/feature request: automate avoiding ANTLR keywords #12

Open SKalt opened 3 years ago

SKalt commented 3 years ago

I've got a token named SKIP, which is an ANTLR keyword. Do you think it would be appropriate for trconvert to postfix tokens that collide with ANTLR keywords with a '_'?

kaby76 commented 3 years ago

I agree. This seems like it's Antlr4 specific knowledge, and the rules should be added to the converter, as well as tranalyze.

Several months ago, I started to make changes to the grammars-v4 repo so they can be used with all supported targets (e.g., Java, C#, Python, Go, Javascript, etc). Unfortunately, most problems were these symbol conflicts. Initially, I made the manually, but after a few months of manual changes, I decided to write trrename to automate the process.

The actual list of renames is currently enumerated in the script here. It should be added to the converter itself.

Note, I was working on modifying Antlr4 to eliminate these symbol conflicts, so renaming would be unnecessary, but I just hadn't had time to complete it.