Syntax analysis
Recursive Descent with Backtracking
Step through recursive-descent parsing as it tries each production in order, matches tokens, and backtracks.
- Lecture reference: Top-Down Parsing
Alternatives are tried in the order written.
Terminals of the grammar, separated by spaces.
Open this grammar in Context-Free Grammars, Predictive Recursive Descent or LL(1) Parsing Table
Lecture reference: Top-Down Parsing
Start with the top-level non-terminal E and try the rules for E in order. T → int and T → int * T do not match (, so each is removed again; T → ( E ) matches.
- With backtracking accept
6 productions tried 2 backtracks
- bool functions accept
6 productions tried 2 backtracks
( int ) is a sentence of the grammar.
Steps every try, match and mismatch
Step 1 of 12
Parse tree
Grammar rules are tried in this order
E T (being tried) T+E
T int int*T (E)
Token stream
next token: ( (1 of 3)
- Fringe
- E
- New fringe
- T
The leaves of the tree: matched tokens, the leftmost non-terminal (marked), the rest.