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 | Properties | List of all members
Mercury.Syntax.Rule Class Reference

Represents a Context-Free Grammar rule. This is an immutable class. More...

Inheritance diagram for Mercury.Syntax.Rule:

Public Member Functions

 Rule (Symbol lhs, IEnumerable< Symbol > rhs)
 Creates a rule. If the constructor does not throw any exception, the rule is guaranteed to be valid. More...
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 
bool Equals (Rule other)
 
int CompareTo (Rule other)
 Compares the rule with another rule. Defines a lexicographical order as follows: More...
 

Properties

Symbol LHS [get, set]
 The Left-Hand Side (LHS) of the rule. More...
 
IReadOnlyList< SymbolRHS [get, set]
 The Right-Hand Side (RHS) of the rule. More...
 
bool IsEpsilon [get, set]
 Determines whether the rule is an epsilon rule. More...
 

Detailed Description

Represents a Context-Free Grammar rule. This is an immutable class.

Conditions for a symbol to be valid:
LHS:
a single NONTERMINAL symbol
RHS:
a) a non-empty list of Terminal and/or Nonterminal symbols
– OR –
b) a list of EXACTLY ONE epsilon symbol

Definition at line 23 of file Rule.cs.

Constructor & Destructor Documentation

Mercury.Syntax.Rule.Rule ( Symbol  lhs,
IEnumerable< Symbol rhs 
)

Creates a rule. If the constructor does not throw any exception, the rule is guaranteed to be valid.

Parameters
lhsThe LHS symbol.
rhsThe RHS symbols.
Exceptions
System.ArgumentNullExceptionrhs
Mercury.Exceptions.InvalidRuleExceptionWhen the rule is not valid.

Definition at line 47 of file Rule.cs.

Member Function Documentation

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

Compares the rule with another rule. Defines a lexicographical order as follows:

  1. compare Left-Hand Sides
  2. compare the length of Right-Hand Sides
  3. lexicographically compare symbols in R-H Sides
Parameters
otherAnother rule
Returns
A value that indicates the relative order of the rules being compared. See IComparable.

Definition at line 151 of file Rule.cs.

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

Definition at line 83 of file Rule.cs.

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

Definition at line 120 of file Rule.cs.

override int Mercury.Syntax.Rule.GetHashCode ( )

Definition at line 89 of file Rule.cs.

override string Mercury.Syntax.Rule.ToString ( )

Definition at line 102 of file Rule.cs.

Property Documentation

bool Mercury.Syntax.Rule.IsEpsilon
getset

Determines whether the rule is an epsilon rule.

true if the rule's RHS is epsilon, false otherwise.

Definition at line 77 of file Rule.cs.

Symbol Mercury.Syntax.Rule.LHS
getset

The Left-Hand Side (LHS) of the rule.

The LHS Symbol.

Definition at line 66 of file Rule.cs.

IReadOnlyList<Symbol> Mercury.Syntax.Rule.RHS
getset

The Right-Hand Side (RHS) of the rule.

An unmodifiable list of RHS symbols.

Definition at line 70 of file Rule.cs.


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