Mercury library 1.0 Translation of CFG grammars into an object model (Bachelor's thesis).

- Main Page
- Packages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

- epsilon: must meet terminal (a) condition
- terminal: one of the following
  a) both of the following:
  1. begins with a lowercase letter or a digit
  2. contains only letters and digits
     b) consists of leading +/-, digits and one dot that is NOT the last character
     c) exactly one punctuation (printable) symbol
- nonterminal: all of the following:
  a) begins with an uppercase letter or a character from Mercury.Defaults.Alpha
  b) contains at least one letter
  c) contains only letters, digits or characters from Mercury.Defaults.Alpha
  If a symbol is terminal, all uppercase characters will be converted to lowercase.

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

  name | Symbol 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

  name | Symbol name
  type | Desired symbol type

Exceptions

  System.ArgumentNullException | name
  Mercury.Exceptions.InvalidSymbolException | When 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

  token | Input token

Exceptions

  System.ArgumentNullException | token
  Mercury.Exceptions.InvalidSymbolException | When 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

  name | Symbol 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
| get set

Symbol name

Symbol name

Definition at line 183 of file Symbol.cs.

Token Mercury.Syntax.Symbol.Token
| get set

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
| get set

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:

- Mercury/Mercury/Syntax/Symbol.cs