Closed piacenti closed 7 months ago
Checking! Thanks for the report.
Would it be ok if we capitalize enum names? E.g., from:
public enum class Rules(public val id: kotlin.Int) {
`line`(1),
`name`(2),
`print`(3),
}
to:
public enum class Rules(public val id: kotlin.Int) {
`Line`(1),
`Name`(2),
`Print`(3),
}
I really don't want to prefix names with RULE_
, it's ugly and it states again what we already know since we are referring to the Rules
enum.
yeah I think capitalizing makes sense. It is similar to how tokens function while easily distinguishable in code and shouldn't ever have a conflict with language level functionality.
This should also address "id" which just happened to be another conflict (with constructor id) found in another one of my grammars' parse rules
I'm trying a different way, without using enums.
Regarding your last comment, do you have an example snippet?
this is in the grammar:
id : ID COLON STRING ;
name : NAME COLON STRING ;
Ahhhh got it now! Thanks!
I will replace enums with object-s acting as namespaces.
They will contain const values, which will resolve both issues and also provide a performance boost, since values are inlined at compile time.
I updated to the latest version and noticed that if I have a parser rule "name" in my grammar it generates an enum entry of "name" which conflicts with the enum "name" field. Previously it would prefix all rule enum entries with "RULE_" which is verbose but prevents name clashes.