-
I am using chumsky 0.9.3 for an assignment so I won't be able to share my actual code, but I've been experiencing an issue where the order of my parsers using or seems to be getting ignored. The language I am writing the parser for is a LOGO spinoff. For context, my program works fine until I introduce function calls which result in a stack overflow, and when I added some printing to debug, it showed that the program was always choosing the function call parser even though it is the last parser in the chain. The previous parsers should match all the other identifiers like "PENDOWN", "IF", "WHILE", etc., and then any identifier that isn't predefined in the language is supposed to be parsed as a function call. With the function call parser commented out, the other parsers work fine. I've tried writing the call parser inside the recursive block like the foo example, as well as outside the recursive block but it gives the same behaviour.
Am I doing something wrong or is this a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Stack overflow is almost always due to left recursion, which happens when a parser appears in left-most position within itself. I suspect that |
Beta Was this translation helpful? Give feedback.
-
As a heads up, inside of a I agree however with Zesterer, that there isn't enough information here to really be able to provide you a solution. If it helps though, I can recommend that you take a look at how the Rust-Nano example handles function calls, as it may help to see how it is recommended to go about parsing expression. Best of luck! |
Beta Was this translation helpful? Give feedback.
-
After a bit of bug testing I think the issue lays with my string parser which the call parser uses
No matter what code I use as input, i.e.
It would always go to the call parser, which prints the result "Parsing: " over and over until the program crashes, I'm not too sure but I think it's trying to parse an empty character or maybe the end of file character I fixed this by changing my string parser to be similar to text::ident() |
Beta Was this translation helpful? Give feedback.
After a bit of bug testing I think the issue lays with my string parser which the call parser uses
No matter what code I use as input, i.e.
It would always go to the call parser, which prints the result "Parsing: " over and over until the program crashes, I'm not too sure but I think it's trying to parse an empty character or maybe the end of file character
I fixed this by changing my string parser to be similar to text::ident()