Strumenta / antlr-kotlin

Support for Kotlin as a target for ANTLR 4
Apache License 2.0
221 stars 47 forks source link

Avoid possible conflict between enum's name and built-in name property #146

Closed lppedd closed 7 months ago

lppedd commented 7 months ago

A Kotlin enum has a built-in name property, which might conflict with a parser rule named "name".
~Capitalizing generated enum names for the parser's Rules enum solves the issue in an elegant way.~

This fixes this issue and any related issues by replacing the enums with objects containing const values.
Const values are inlined at compile time, providing a general performance boost while parsing, especially in JS.

cc @ftomassetti

Closes: #145

lppedd commented 7 months ago

Evaluating a different approach to optimize speed on slower platforms like JS.

lppedd commented 7 months ago

@piacenti have a look at this PR. Let me know if it looks good.

You should now be able to also use var and val as parser rule names.

ftomassetti commented 7 months ago

Looks good to me, I would just revise the list of keywords as per my comment