An expression parser uses the ambiguous grammar
Inputs contain identifiers separated by plus tokens, with no parentheses. Let NnN_nNn be the number of structurally distinct parse trees for a fixed sequence containing nnn identifiers. Do not count different expansion orders for the same tree separately.
Splitting at the root plus gives
You may use N2=1N_2=1N2=1 and N3=2N_3=2N3=2. Find the parse-tree counts for a four-identifier input and a five-identifier input. Enter each as an exact integer number of trees, with zero decimal places.
Unlock full course notes by signing up
When an Empty Production Is Legal
A predictive parser uses this grammar, with start symbol SSS and an external end-of-input marker called EOF:
Complete the decision table for a call to RRR. Enter exactly continue for R→+idRR \to +\mathrm{id}RR→+idR, empty for R→εR \to \varepsilonR→ε, or error when neither production is valid for the lookahead token.
Two Structures for One Token Sequence
An expression grammar has start symbol EEE and productions
For the token sequence id(a) + id(b) * id(c), which statements are true? Select every true statement. No precedence or associativity rules supplement the grammar.
Delaying a Predictive Choice
A command parser chooses a production using only the next input token. The token names name and value each denote a single token category. The symbols =, (, and ) are literal tokens.
The original grammar has these labelled productions:
O1: S→name = valueS \to \text{name}\;=\;\text{value}S→name=value
Recursion Direction and Parser Stack Space
A configuration tool parses the list alpha, beta, gamma, delta, eta, theta, kappa, omega. Each identifier becomes one id token, and each comma becomes one comma token. Compare two bottom-up parsers that start with empty stacks.
The left-recursive grammar is: