Chemistry Reference and  Research
           
 
Periodic Table
- standard table
- large table
 
Chemical Elements
- by name
- by symbol
- by atomic number
 
Chemical Properties
 
Chemical Reactions
 
Organic Chemistry
 
Branches of Chemistry
Analytical chemistry
Biochemistry
Computational Chemistry
Electrochemistry
Environmental chemistry
Geochemistry
Inorganic chemistry
Materials science
Medicinal chemistry
Nuclear chemistry
Organic chemistry
Pharmacology
Physical chemistry
Polymer chemistry
Supramolecular Chemistry
Thermochemistry

Ambiguous grammar

In computer science, a grammar is an ambiguous grammar if some string in the language can be generated in more than one way (i.e., it has more than one parse tree or more than one leftmost derivation ). A language is inherently ambiguous if it can only be generated by ambiguous grammars.

For programming languages, ambiguous grammars can lead to difficulties for some compilers.

Example

The context free grammar

A → A + A | A − A | a

is ambiguous since there are two leftmost derivations for the string a + a − a:

     A → A + A     |     A → A − A
     → a + A     |     → A + A − A
     → a + A − A     |     → a + A − A
     → a + a − A     |     → a + a − A
     → a + a − a     |     → a + a − a

Equivalently, it is ambiguous since there are two parse trees for the string a + a − a:

The language that it generates, however, is not inherently ambiguous; the following is a non-ambiguous grammar generating the same language:

A → A + a | A − a | a

References

Compilers: Principles, Techniques and Tools

Programming Languages: Design and Implementation, T. Pratt, M. Zelkowitz. Prentice Hall, 2001

01-04-2007 01:16:19
The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License. How to see transparent copy