Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stlutz opened this issue Jul 11, 2019 · 2 comments
Open

Comments

@stlutz
Copy link

stlutz commented Jul 11, 2019

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
Copy link
Author

stlutz commented Jul 11, 2019

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.

@codeZeilen
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants