Ohm-S icon indicating copy to clipboard operation
Ohm-S copied to clipboard

Late conversion of inline rule names to message names can cause clashes

Open stlutz opened this issue 5 years ago • 2 comments

Inline rule names do not match with the message that is sent to semantic actions. It is therefore possible to do the following:

SomeGrammar {
  RuleOne
    = "hello"
  Rule
    = "hello" "world" -- one
}

At the moment inline rule names' underscore is removed and the subsequent character capitalized when searching for methods in semantic actions. Both rules would therefore try to lookup the method RuleOne. Due to differing arities, only one of the rules can be acted upon.

This duplication of rules is not detected, since the inline rule name conforms to the Ohm/JS implementation (Rule_one) and is only later converted.

stlutz avatar Jul 11 '19 14:07 stlutz

Personally, I prefer the underscore in inline rule names. Since I never use underscores as normal rule names, it becomes much easier to distinguish between inline and normal definitions.

stlutz avatar Jul 11 '19 14:07 stlutz

@stlutz Maybe you have an oppinion on #68 ? As the dispatch can not be mixed safely, I opted for a configuration. For your attributes you can now decide on whether you want the original rule names or the converted ones. As the converted ones are the default, you have to explicitly opt-in for the underscore preservation.

codeZeilen avatar May 04 '21 15:05 codeZeilen