-
Notifications
You must be signed in to change notification settings - Fork 448
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
Allow recursive parsing from within the code callbacks. #6
Comments
It should be possible for you to store a reference to the parser in the yy scope variable: Then you could access But this may disrupt the currently executing parse, since If only a subset of the language is allowed in embedded code fragments, you could even use a separate grammar and parser altogether, which may be a bit more efficient for parsing, but would require maintaining two grammars. |
Yeah, I had hacked in a reference to the parser and found that the results are unexpected because of setInput being called again. It looks like I'll have to generate pseudo tokens for start and end of embedded code and then just make it all part of the ine grammer. |
Forgot to close |
I'm trying to port my bibtex translator from pegjs to jison and I'm facing a similar issue. Is this then a structural hard problem for jison? |
I would like the ability to recursively call parse from within the code hooks in my bnf.
My use case is implementing string interpolation in a programming language. My lexer will recursively tokenize the contents of embedded code in a string and give yyval the embedded token stream. I then want to recursively call parser.parse from within the string token in my bnf.
I can't seem to find a way to get at the current parser instance from within the callback. The
this
scope is just an object with one key$
. Would it be possible to add a reference to the current parser instance to thethis
scope.Also, while not required, it would help me a lot if I could specify the starter non-terminal for this recursive parse. I don't want to start at my root node, but at my expression node for the embedded code.
The text was updated successfully, but these errors were encountered: