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

Allow namechars to appear in token when performing nameguard check #65

Closed
pdw-mb opened this issue May 15, 2018 · 1 comment
Closed

Comments

@pdw-mb
Copy link

pdw-mb commented May 15, 2018

Consider:

myrule = 
"key" ~ ";" |
"key-word" ~ ";" |
"key-word-extra" ~ ";" ;

And set namechars = '-'.

This will happily parse "key" and "key-word" but not "key-word-extra", because nameguard requires that the token being matched is alphanumeric:

partial_match = (
                token.isalnum() and
                token[0].isalpha() and
                self.is_name_char(self.current())
            )

I think this check should allow namechars to appear in the token being matched too.

@apalala
Copy link
Collaborator

apalala commented May 16, 2018

I can understand the need, but not the example. PEG grammars should place longer options first:

myrule 
    = 
    (key-word-extra" | "key-word" | "key") ~ ";" 
    ;

At any rate, for consistency the check should be:

        partial_match = all(self.is_name_char(t) for t in token + self.current())

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