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

Missing trailing context? #18

Closed
neizod opened this issue Jun 27, 2012 · 2 comments
Closed

Missing trailing context? #18

neizod opened this issue Jun 27, 2012 · 2 comments

Comments

@neizod
Copy link

neizod commented Jun 27, 2012

In lex/flex, there is a 'trailing context' pattern: match/require, such as

a/n

which will match only a if it follow by n. So a in and, can, another are matched, but a in alone, mask is not matched.

I found this feature is missing in PLY. Since I'm greatly rely on this feature, please add it.

@neizod
Copy link
Author

neizod commented Jun 27, 2012

Just report my work around. I've add a backward function for the lexer. In a lexer rule I search for the whole text. Do rexgex match unwanted part, count its length, call this function, and sub this unwanted part from the whole matched. Hooray! Its work. :)

@neizod neizod closed this as completed Jun 27, 2012
@neizod
Copy link
Author

neizod commented Jun 27, 2012

Oh... that's all my bad. I'm just old fashion guy from lex/flex rexgex style. There is a better way to deal with this rexgex directly in Python:

match(?=require)

btw, could you write some short documentation on this?

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

1 participant