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

Having trouble making recursive parsers #36

Closed
Ralle opened this issue Jul 15, 2015 · 3 comments
Closed

Having trouble making recursive parsers #36

Ralle opened this issue Jul 15, 2015 · 3 comments

Comments

@Ralle
Copy link

Ralle commented Jul 15, 2015

I am building a parser for a language of my imagination, I am having problem with recursive parsers. Take a look at this gist:

https://gist.github.com/Ralle/336941d1472a598d1121

I can parse ints and I can parse floats, but as soon as I make a pair using '(int, int)' it expects a float. I don't understand why this happens. I tried switching around the int_parser and float_parser but then it would obviously not parse floats as it succesfully parses the int and then don't know what to do with the '.'.

Please advice.

@Marwes
Copy link
Owner

Marwes commented Jul 15, 2015

The parsers are LL(1) which means that in your or parser the float parser
being first manages to parse a few digits before failing when it does not
fund a '.'. You can create parsers with arbitrary lookahead with the try
function.
On 15 Jul 2015 17:40, "Ralle" notifications@github.com wrote:

I am building a parser for a language of my imagination, I am having
problem with recursive parsers. Take a look at this gist:

https://gist.github.com/Ralle/336941d1472a598d1121

I can parse ints and I can parse floats, but as soon as I make a pair
using '(int, int)' it expects a float. I don't understand why this happens.
I tried switching around the int_parser and float_parser but then it would
obviously not parse floats as it succesfully parses the int and then don't
know what to do with the '.'.

Please advice.


Reply to this email directly or view it on GitHub
#36.

@Ralle
Copy link
Author

Ralle commented Jul 15, 2015

Ah. I never knew what that meant. Thank you so much for helping me and for responding so quickly.

@Ralle Ralle closed this as completed Jul 15, 2015
@Marwes
Copy link
Owner

Marwes commented Jul 15, 2015

As an aside I also have the language extension crate at https://github.com/Marwes/parser-combinators-language. Its a bit rough but there might be something of use for you there.

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