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

ply lex seems not greedy (when using class) #49

Closed
Astyan-42 opened this issue Nov 14, 2014 · 1 comment
Closed

ply lex seems not greedy (when using class) #49

Astyan-42 opened this issue Nov 14, 2014 · 1 comment

Comments

@Astyan-42
Copy link

I have write an exemple of the issue : https://github.com/Astyan-42/plynotgreedy
I don't know a lot about ply but if I remember well lex should be greedy so the KEYWORD should be reconized like a KEYWORD and not a word.

Here the statements of the parser seem to count in the token size.

@johnyf
Copy link

johnyf commented Nov 14, 2014

This is because you define both the CHAR and KEYWORD token rules using methods, instead of plain regular expressions. Their precedence is the order in which they appear in the source code, unlike the tokens that are defined by plains strings, whose order is obtained after sorting them in decreasing regular expression length. This is described here in the documentation.

@dabeaz dabeaz closed this as completed Apr 16, 2015
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

3 participants