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 | Static Public Member Functions | Properties | List of all members
Mercury.Syntax.Symbol Class Reference

Represents a single symbol of the grammar. This is an immutable class.

For a symbol name to be valid it must NOT contain control or separator characters, must not be empty and must meet these conditions:
More...

Inheritance diagram for Mercury.Syntax.Symbol:

Public Member Functions

 Symbol ()
 Creates an epsilon symbol. More...
 
 Symbol (string name)
 Creates a new symbol and infers its type. If the constructor does not throw any exception, the symbol is guaranteed to be valid. More...
 
 Symbol (string name, SymbolType type)
 Creates a new symbol with desired type. If the constructor does not throw any exception, the symbol is guaranteed to be valid. More...
 
 Symbol (Token token)
 Creates a new terminal symbol from a token. If the constructor does not throw any exception, the symbol is guaranteed to be valid. More...
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 
bool Equals (Symbol other)
 
int CompareTo (Symbol other)
 

Static Public Member Functions

static SymbolType InferType (string name)
 Infers the type of symbol according to conditions described in the constructor documentation. More...
 

Properties

string Name [get, set]
 Symbol name More...
 
SymbolType Type [get, set]
 Symbol type More...
 
bool IsEpsilon [get]
 Indicates whether the symbol is an epsilon symbol More...
 
Token Token [get, set]
 A token that created this symbol or null if other constructor was used More...
 

Detailed Description

Represents a single symbol of the grammar. This is an immutable class.

For a symbol name to be valid it must NOT contain control or separator characters, must not be empty and must meet these conditions:

Definition at line 51 of file Symbol.cs.

Constructor & Destructor Documentation

Mercury.Syntax.Symbol.Symbol ( )

Creates an epsilon symbol.

Definition at line 65 of file Symbol.cs.

Mercury.Syntax.Symbol.Symbol ( string  name)

Creates a new symbol and infers its type. If the constructor does not throw any exception, the symbol is guaranteed to be valid.

Parameters
nameSymbol name

Definition at line 77 of file Symbol.cs.

Mercury.Syntax.Symbol.Symbol ( string  name,
SymbolType  type 
)

Creates a new symbol with desired type. If the constructor does not throw any exception, the symbol is guaranteed to be valid.

Parameters
nameSymbol name
typeDesired symbol type
Exceptions
System.ArgumentNullExceptionname
Mercury.Exceptions.InvalidSymbolExceptionWhen the symbol is not valid.

Definition at line 91 of file Symbol.cs.

Mercury.Syntax.Symbol.Symbol ( Token  token)

Creates a new terminal symbol from a token. If the constructor does not throw any exception, the symbol is guaranteed to be valid.

Parameters
tokenInput token
Exceptions
System.ArgumentNullExceptiontoken
Mercury.Exceptions.InvalidSymbolExceptionWhen the symbol is not valid.

Definition at line 110 of file Symbol.cs.

Member Function Documentation

int Mercury.Syntax.Symbol.CompareTo ( Symbol  other)

Definition at line 235 of file Symbol.cs.

override bool Mercury.Syntax.Symbol.Equals ( object  obj)

Definition at line 203 of file Symbol.cs.

bool Mercury.Syntax.Symbol.Equals ( Symbol  other)

Definition at line 228 of file Symbol.cs.

override int Mercury.Syntax.Symbol.GetHashCode ( )

Definition at line 209 of file Symbol.cs.

static SymbolType Mercury.Syntax.Symbol.InferType ( string  name)
static

Infers the type of symbol according to conditions described in the constructor documentation.

If input meets terminal a) condition (= terminal or epsilon), this method returns SymbolType.Terminal | SymbolType.Epsilon.

Parameters
nameSymbol name
Returns
Inferred symbol type

Definition at line 133 of file Symbol.cs.

override string Mercury.Syntax.Symbol.ToString ( )

Definition at line 212 of file Symbol.cs.

Property Documentation

bool Mercury.Syntax.Symbol.IsEpsilon
get

Indicates whether the symbol is an epsilon symbol

true if this is epsilon; false otherwise

Definition at line 191 of file Symbol.cs.

string Mercury.Syntax.Symbol.Name
getset

Symbol name

Symbol name

Definition at line 183 of file Symbol.cs.

Token Mercury.Syntax.Symbol.Token
getset

A token that created this symbol or null if other constructor was used

Definition at line 197 of file Symbol.cs.

SymbolType Mercury.Syntax.Symbol.Type
getset

Symbol type

The type of the symbol, inferred when constructed

Definition at line 187 of file Symbol.cs.


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