Skip to content

Why are the syntax trees obtained by chevrotain/ecma5 and acorn different in level when executing the same code? #2045

Answered by bd82
alamhubb asked this question in Q&A
Discussion options

You must be logged in to vote

Chevrotain produces a Concrete Syntax Tree which is implicitly defined by the grammar.
So of course the structure would be different from a different parser (e.g Acorn).
And could be different between different implementations of the same grammar in Chevrotain.

In regards to expressions parsing:

  1. The grouped nodes are in the orders which they have been encountered, so the order information is there.
  2. There is also location information included in these nodes, which is another way to re-construct the order.
  3. Operator precedence is another thing which can affect the "level" / structure of the CST
    • In the Calculator example the precedence is "baked" into the grammar and is thus represented in …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alamhubb
Comment options

Answer selected by alamhubb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants