Parse tree design

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 9: Line 9:
 
== Terminology ==
 
== Terminology ==
 
In parsing lingo a ''symbol'' is a name in a grammar.  Each symbol is either a ''terminal'' or a ''non-terminal''.  Non-terminals appear on the left hand side of a grammar production; terminals don't.
 
In parsing lingo a ''symbol'' is a name in a grammar.  Each symbol is either a ''terminal'' or a ''non-terminal''.  Non-terminals appear on the left hand side of a grammar production; terminals don't.
 +
 +
== Class-Design ==
 +
 +
[[Image:ParseTree.jpeg]]
 +
 +
That's the first Design that came up in class:
 +
*the addKid()-function in the Terminal class throws an exception
 +
*symbol is of type enum, which has a representation for every symbol of the grammar.

Revision as of 05:39, 9 September 2008

A context free grammar defines a language, e.g.

Grammar.gif

A parse tree shows how a sentence in the language is structured according to the grammar.

Parsetree.gif

Terminology

In parsing lingo a symbol is a name in a grammar. Each symbol is either a terminal or a non-terminal. Non-terminals appear on the left hand side of a grammar production; terminals don't.

Class-Design

ParseTree.jpeg

That's the first Design that came up in class:

  • the addKid()-function in the Terminal class throws an exception
  • symbol is of type enum, which has a representation for every symbol of the grammar.
Personal tools