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
Something we might need would be to add an EOF token to the stream, if we don't want to keep the parser waiting for more tokens indefinitely. Or, on the other hand, we might want exactly that.
Doing this in multiple threads could be done by lexing in one thread, parsing in another and executing in another. Doing concurrent parser might prove to be more difficult, though.
I may close this seeing as we can't do it that way dur to the lexer needing context
Actually, I think this is now more important than ever!
Instead of "streaming" we could do "lazy" lexing, and making the parser iterate over it, while changing context as needed. @maciejhirsz proposed to use Logos for this, and I think it makes sense. Not sure if there was any progress in that front.
I'm on holidays since yesterday, so I should have time to dig into Boa at last :)
Streaming (iterating) the tokens during parsing if anything makes things easier, since the Parser can supply the Lexer with context if need be. The main culprit in JS is the regex literal, and the rule here is fairly simple: any expression that begins with division token / (that is a unary prefix expression with operator /) should switch the lexer into regex mode. It's fairly easy to integrate that into standard recursive Pratt parsing for nested expressions.
I'm on holidays since yesterday, so I should have time to dig into Boa at last :)
Streaming (iterating) the tokens during parsing if anything makes things easier, since the Parser can supply the Lexer with context if need be. The main culprit in JS is the regex literal, and the rule here is fairly simple: any expression that begins with division token / (that is a unary prefix expression with operator /) should switch the lexer into regex mode. It's fairly easy to integrate that into standard recursive Pratt parsing for nested expressions.
Activity
Razican commentedon Mar 30, 2020
About the cursor, it might need to return a
Resulton each call, but for the rest, the external API could stay without much change.Razican commentedon Mar 31, 2020
Something we might need would be to add an
EOFtoken to the stream, if we don't want to keep the parser waiting for more tokens indefinitely. Or, on the other hand, we might want exactly that.Doing this in multiple threads could be done by lexing in one thread, parsing in another and executing in another. Doing concurrent parser might prove to be more difficult, though.
jasonwilliams commentedon Mar 31, 2020
The lexer can close the channel once it's finished, this will signal to the parser there is nothing more to come down the pipe.
jasonwilliams commentedon Apr 13, 2020
It might be due to the way parsing and lexing are related (goal symbols) this may not be possible.
Related:
jasonwilliams#294
Razican commentedon Apr 13, 2020
I think that what can be done is for the parser to request lexing of new tokens to the lexer via calls to
next()in the cursor.jasonwilliams commentedon May 2, 2020
I may close this seeing as we can't do it that way dur to the lexer needing context
Razican commentedon May 2, 2020
Actually, I think this is now more important than ever!
Instead of "streaming" we could do "lazy" lexing, and making the parser iterate over it, while changing context as needed. @maciejhirsz proposed to use Logos for this, and I think it makes sense. Not sure if there was any progress in that front.
maciejhirsz commentedon May 2, 2020
I'm on holidays since yesterday, so I should have time to dig into Boa at last :)
Streaming (iterating) the tokens during parsing if anything makes things easier, since the Parser can supply the Lexer with context if need be. The main culprit in JS is the regex literal, and the rule here is fairly simple: any expression that begins with division token
/(that is a unary prefix expression with operator/) should switch the lexer into regex mode. It's fairly easy to integrate that into standard recursive Pratt parsing for nested expressions.Razican commentedon May 9, 2020
Let us know if we can be of any help :)