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

How to handle Tokens when the lexical grammar might be non regular #463

Open
vikigenius opened this issue Jan 19, 2025 · 1 comment
Open

Comments

@vikigenius
Copy link

I am working on a toy CSS parser and it seems to have really complicated identifiers that don't seem like they can be captured by a regex?

https://www.w3.org/TR/css-syntax-3/#ident-token-diagram

And also what if you have to treat a Token differently based on surrounding context? Is it an identifier or an arithmetic operation (CSS/SASS allow hyphens in their identifier)?

How would I handle such cases in Logos? Would you recommend just combining the parser and lexer for cases like these and not use Logos?

@jeertmans
Copy link
Collaborator

Hi @vikigenius, this is probably possible using extras (Extra) or callbacks, did you check the examples and the book?

Context-based lexing is pretty much a matter of you implementing the necessary logic inside callbacks.

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