An augmented grammar is any grammar whose productions are augmented with conditions expressed using features. Features may be associated with any nonterminal symbol in a derivation. A feature associated with a nonterminal symbol is shown following that nonterminal separated from it by a ".", e.g. A.COUNT is the COUNT feature associated with the nonterminal A. When the value is included with the feature, the feature and its value are bracketed and the dot omitted, as in A[COUNT 1]. If no ambiguity arises, the feature name may be omitted, as in A[1]. The values of the features may be assigned by the application of a production (indicated by the assignment operator ":=" for 'is set equal to'), or they may be compared (checked) using a comparison operator such as "=".
Here are the productions of an augmented context-free grammar G1 that generates the SIXL Ln³ = {anbncn | n > 0}. Nonterminal symbols that occur more than once in a production are distinguished by indices. The nonterminal symbol to the left of the rewrite arrow "® " gets index 0 (e.g. A0), and recurring nonterminals to the right of the arrow get indices 1, 2, ... from left to right, e.g. A1. COUNT is an integer feature (a feature that takes integer values) of each of the nonterminal symbols in G1.
Here are the productions of a grammar G2 that parses Ln³. A derivation with respect to a parsing grammar (parser) such as G2, is constructed in reverse fashion from that of a generating grammar (generator) such as G1. [Note that I do not call G2 a generative grammar. I use the latter term, as Chomsky does, to refer to the class of parsers and generators of languages.] It starts with a terminal string, and each successive line is built up from the preceding line by replacing a substring by a nonterminal symbol together with its features in accordance with a production of the grammar. The derivation is terminated if the final line is a start symbol, and it's easy to see that the language parsed by G2 is identical to the language generated by G1, namely Ln³. Each equivalence class of derivations with respect to a parser can be represented as a tree. However, the structural descriptions associated with the members of Ln³ by G2 are different from those associated with them by G1. To distinguish the productions of a parser from those of a generator, I also reverse the direction of the production arrow.
Write the productions of a parser that is structurally equivalent to the generator G1. Click here for an answer.
The generator G1 makes use of an infinite set of start symbols {S[n]: n > 0}. The generator G3, whose productions are listed below, makes use of the single start symbol A[0]. Note that G3 is an augmented regular grammar. NEWCOUNT , like COUNT (but defined for nonterminal B only), is an integer feature.
Write augmented regulars parsers for Ln³, one that parses from right-to-left and one that parses from left-to-right. Click here for answers.
Here are the productions of an augmented regular generator G4 for the SIXL Lxx = {xx : x Î (a | b)*}. The nonterminals have a string feature (feature whose value is a string) STR. The start symbol is S[e].
Write the productions of a left-to right augmented regular parser for Lxx. Click here for an answer.