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:
A transformed grammar has these labelled productions:
Complete each predictive parsing entry. Enter the production label when exactly one production can begin with the next token, conflict when more than one can, or error when none can. Treat each row as a separate lookup for the indicated nonterminal.
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.
Counting Ambiguous Groupings
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.
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: