Grammar and language summary and combing (9.25)

Ambiguous grammar :

A sentence may correspond to a plurality of the syntax tree, a sentence may correspond to a plurality of the leftmost / rightmost derivation.

If a grammar of a sentence may correspond to two different syntax tree, called the grammar is ambiguous in.

Two different grammar may be the same language.

If all the grammar of a language is ambiguous, and claimed that this language inherent ambiguity.

Determine whether a grammar is ambiguous is recursively unsolvable.

2. Try to write grammar PL / 0 language.

Integer n n :: = 1 | 2 | ..... | 9 | 0

Identifier i i :: = <letters> | {<letters> | <number>}

Expression e :: = [+ | -] <item> {<subtraction operator> <term>}

Conditional statement :: = if <condition> then <statement>

Assignment :: = <id>: = <expression>

Compound statement :: = begin <statement> {; <statement>} end

Function :: = <Description Type> <function name> <compound statement>

Program :: = [<Constant Description section>] [<Variable Description section>] [<Process Description section>] <statement>

Guess you like

Origin www.cnblogs.com/lywkkk/p/11583493.html