You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, Thanks for the interesting tutorial! I'm just learning about PEG etc and wondered how to modify the grammar so that
//assert_eq!(Interpreter::source("(1 + 2)").unwrap() as i32, 3);
will work?
Thanks
Mike
The text was updated successfully, but these errors were encountered:
Pest gives a great interactive parser at the bottom of their page. Check it out. The problem with giving the first term wrapped in parentheses is that the grammar tries to parse it as a full Binary Expression first. While this is true, it checks for least recursive first. To fix this, I changed the binary expression to include at least one operator and term. Then an expression can also be a term too (what was originally a binary term with no suffixed operator and term). The following is a fixed version of the grammar code. I also changed an Int to be defined as either negative or non-negative (getting rid of the possibility of having a preceding plus sign).
Hi, Thanks for the interesting tutorial! I'm just learning about PEG etc and wondered how to modify the grammar so that
//assert_eq!(Interpreter::source("(1 + 2)").unwrap() as i32, 3);
will work?
Thanks
Mike
The text was updated successfully, but these errors were encountered: