Ohm-S
Ohm-S copied to clipboard
Late conversion of inline rule names to message names can cause clashes
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.
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 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.