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

Docs Question - Optional Prefix to Regular Expressions #438

Closed
DavidHVernon opened this issue Jan 15, 2024 · 5 comments
Closed

Docs Question - Optional Prefix to Regular Expressions #438

DavidHVernon opened this issue Jan 15, 2024 · 5 comments

Comments

@DavidHVernon
Copy link

Snip from https://softdevteam.github.io/grmtools/latest_release/book/lexcompatibility.html

Both Lex and grmtools lex files support start conditions as an optional prefix to regular expressions, listing necessary states for the input expression to be considered for matching against the input. Lex uses a special action expression BEGIN(state) to switch to the named state. grmtools lex files use a token name prefix.

Could someone point me at an example of this? I'm very curious, and think it might fix an issue that i've been wrestling with.

@ratmice
Copy link
Collaborator

ratmice commented Jan 15, 2024

The example in the repo that uses this is the lrpar/examples/start_states:

https://github.com/softdevteam/grmtools/blob/master/lrpar/examples/start_states/src/comment.l

When the left hand side matches the current state of the lexer (which starts out in the INITIAL state)
it tries to apply the regex, if that then matches the state operation on the right hand side is applied, modifying the current state and a token is produced.

@DavidHVernon
Copy link
Author

Thank you for the clarification. I'm not quite sure that I follow, but I will give it some more thought before I ask follow-on questions.

@ratmice
Copy link
Collaborator

ratmice commented Jan 15, 2024

I tried to update that hopefully making it a bit clearer.

@DavidHVernon
Copy link
Author

Thank you for that, but the real issue is that I was reading it in the grocery store checkout line :)

@DavidHVernon
Copy link
Author

Hey all. Thanks for the help here. Life has gotten in between me and Rust lately, but I've got my head around this now and I suppose we can close the issue.

@ltratt ltratt closed this as completed Feb 11, 2024
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