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

Document Lexer Rules #24

Closed
valarauca opened this issue Jun 14, 2018 · 4 comments
Closed

Document Lexer Rules #24

valarauca opened this issue Jun 14, 2018 · 4 comments

Comments

@valarauca
Copy link

Depending on the lexiconal order the EBNF rules, what is and is not a valid parse changes.

Now to a degree this makes sense, but most implementations resolve this ahead of time.

But for example if I have an EBNF like

(. changed to ; for github syntax highlighting)

num = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
Version = { num } [ "." { num } [ "." { num } ] ] ;

letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ;
package_name = letter | num | "_" | "-" | "." ;
PackageID = letter { package_name } ;

This will correctly parse for @Version and @PackageID

But if I add the rule:

NameID = ID ":" ID ":"  Version ;

Anything tagged as @PackageID breaks because it doesn't contain a : character.

@valarauca valarauca changed the title Document gramatical lexiconal rules Document Lexer Rules Jun 14, 2018
@alecthomas
Copy link
Owner

Can you provide an example?

@alecthomas
Copy link
Owner

Also, have you tried latest master? I just merged the lookahead branch which should since this.

@alecthomas
Copy link
Owner

Sorry, was on mobile. I assume you're talking about the EBNF lexer. Can you provide the full lexer you're using that breaks, and an example grammar that fails? (your example above is missing the definition for ID).

@valarauca
Copy link
Author

Just me being a noob very sorry

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