Mercury library  1.0
Translation of CFG grammars into an object model (Bachelor's thesis).
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Member Functions | Protected Attributes | Properties | List of all members
Mercury.Syntax.GrammarBuilder Class Reference

Class that creates grammars. More...

Inherited by Mercury.Syntax.ExtendedGrammarBuilder.

Public Member Functions

 GrammarBuilder ()
 Default constructor. Uses Root and Epsilon symbols that are specified in the configuration. More...
 
 GrammarBuilder (Symbol root, Symbol epsilon)
 Creates a GrammarBuilder with custom Root and Epsilon symbols. More...
 
GrammarBuilder AddSymbol (Symbol newSymbol)
 Adds a new symbol to the grammar. The destination set is determined by the symbol type. Epsilon or symbols that already are in the grammar are ignored. More...
 
virtual GrammarBuilder AddRule (Rule rule)
 Adds a new rule to the grammar. If the rule contains symbols that are not in the grammar, they will be added. Rules that are already in the grammar will be ignored. More...
 
GrammarBuilder AddRules (IEnumerable< Rule > rules)
 Adds the collection of rules to the builder. More...
 
GrammarBuilder Include (GrammarBuilder other)
 Includes the other builder. More...
 
Grammar GetGrammar ()
 
Returns
A grammar from the builder.
More...
 

Protected Attributes

HashSet< Symbolnonterminals = new HashSet<Symbol>()
 
HashSet< Symbolterminals = new HashSet<Symbol>()
 
HashSet< Rulerules = new HashSet<Rule>()
 

Properties

Symbol Root [get, set]
 Root symbol. More...
 
Symbol Epsilon [get, set]
 Epsilon symbol. More...
 

Detailed Description

Class that creates grammars.

Definition at line 13 of file GrammarBuilder.cs.

Constructor & Destructor Documentation

Mercury.Syntax.GrammarBuilder.GrammarBuilder ( )

Default constructor. Uses Root and Epsilon symbols that are specified in the configuration.

Definition at line 27 of file GrammarBuilder.cs.

Mercury.Syntax.GrammarBuilder.GrammarBuilder ( Symbol  root,
Symbol  epsilon 
)

Creates a GrammarBuilder with custom Root and Epsilon symbols.

Parameters
rootA root symbol, must be a nonterminal.
epsilonEpsilon symbol.

Definition at line 36 of file GrammarBuilder.cs.

Member Function Documentation

virtual GrammarBuilder Mercury.Syntax.GrammarBuilder.AddRule ( Rule  rule)
virtual

Adds a new rule to the grammar. If the rule contains symbols that are not in the grammar, they will be added. Rules that are already in the grammar will be ignored.

Parameters
ruleThe rule to be added
Returns
This builder to support chaining.

Definition at line 93 of file GrammarBuilder.cs.

GrammarBuilder Mercury.Syntax.GrammarBuilder.AddRules ( IEnumerable< Rule rules)

Adds the collection of rules to the builder.

Parameters
rulesThe rules.
Returns
This builder to support chaining.

Definition at line 111 of file GrammarBuilder.cs.

GrammarBuilder Mercury.Syntax.GrammarBuilder.AddSymbol ( Symbol  newSymbol)

Adds a new symbol to the grammar. The destination set is determined by the symbol type. Epsilon or symbols that already are in the grammar are ignored.

Parameters
newSymbolThe new symbol.
Returns
This builder to support chaining.

Definition at line 67 of file GrammarBuilder.cs.

Grammar Mercury.Syntax.GrammarBuilder.GetGrammar ( )

Returns
A grammar from the builder.

Definition at line 121 of file GrammarBuilder.cs.

GrammarBuilder Mercury.Syntax.GrammarBuilder.Include ( GrammarBuilder  other)

Includes the other builder.

Parameters
otherThe other builder.
Returns
This builder to support chaining.

Definition at line 117 of file GrammarBuilder.cs.

Member Data Documentation

HashSet<Symbol> Mercury.Syntax.GrammarBuilder.nonterminals = new HashSet<Symbol>()
protected

Definition at line 17 of file GrammarBuilder.cs.

HashSet<Rule> Mercury.Syntax.GrammarBuilder.rules = new HashSet<Rule>()
protected

Definition at line 19 of file GrammarBuilder.cs.

HashSet<Symbol> Mercury.Syntax.GrammarBuilder.terminals = new HashSet<Symbol>()
protected

Definition at line 18 of file GrammarBuilder.cs.

Property Documentation

Symbol Mercury.Syntax.GrammarBuilder.Epsilon
getset

Epsilon symbol.

Definition at line 56 of file GrammarBuilder.cs.

Symbol Mercury.Syntax.GrammarBuilder.Root
getset

Root symbol.

Definition at line 53 of file GrammarBuilder.cs.


The documentation for this class was generated from the following file: