News for hackers. Stuff that matters.
Re:We Need to Know LR and Recursive Descent Parsing Techniques by brhsagain on Tuesday January 17, 2023 @03:26PM (#34418394)
This is extremely interesting to me. I looked at the papers tree-sitter referenced but they were all written assuming an LR/generator-based parser and I couldn't figure out how to adapt it to recursive descent.

Let's say I've parsed an AST

    binary_expression
      lhs: number
      rhs: binary_expression
        lhs: number
        rhs: call_expression
          func: identifier
          args: call_argument_list
            [0]: number
            [1]: number

and I've detected that `rhs` on line 3 has changed. So I go back to the start of the node. What do I do then? How do I know I need to parse an expression there and that it belongs to the rhs of a binary expression?

In the literature, this is solved by storing the parse state. How do you do that with recursive descent?

Is there something you'd recommend reading to understand how to do incremental parsing for recursive descent specifically?

Re:We Need to Know LR and Recursive Descent Parsing Techniques by DannyBee on Wednesday January 18, 2023 @10:04AM (#34427451)
I implemented it for ANTLR (which is LL(*), so not fully recursive descent, but top-down) but never got around to shepherding the patches through.

https://github.com/dberlin/antlr4ts/blob/incremental/Increme...

and the commits on that branch should give you some idea.

I have java support somewhere for the non-TS target as well.

I'm happy to chat about it elsewhere as well, drop me a line at my email.

Re:We Need to Know LR and Recursive Descent Parsing Techniques by brhsagain on Wednesday January 18, 2023 @01:45PM (#34431013)
Thank you!