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

why can't this be parsed? #487

Closed
zpdDG4gta8XKpMCd opened this issue Feb 5, 2017 · 2 comments
Closed

why can't this be parsed? #487

zpdDG4gta8XKpMCd opened this issue Feb 5, 2017 · 2 comments

Comments

@zpdDG4gta8XKpMCd
Copy link

zpdDG4gta8XKpMCd commented Feb 5, 2017

@dmajda

gammar

// from RFC 2396
domainlabel = 'a' / ('a' ('a' / '-')* 'a')

input

aa

can't parse, why?

@gguerreiro
Copy link

gguerreiro commented Feb 5, 2017

The rule ('a' / '-')* will try to match the longest string possible, so it will match 'aa' leaving no chars.

RFC 2396 domainlabel rule can be rewritten as

domainlabel = $([a-zA-Z] [a-zA-Z0-9]* ('-'+ [a-zA-Z0-9]+)*)

Also, take a look at Parsing Expression Types to check the rules PEG.js supports.

@zpdDG4gta8XKpMCd
Copy link
Author

thanks

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