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.Edge Class Reference

Represents an edge in the chart created by the ChartParser. This is an immutable class.
The Edge contains four values:
More...

Inheritance diagram for Mercury.Syntax.Edge:

Public Member Functions

 Edge (Rule rule, int dot, int left, int right)
 Creates a new edge. If the constructor does not throw any exception, the edge is guaranteed to be valid. More...
 
bool IsValid ()
 Determines whether this edge is valid. More...
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 
bool Equals (Edge other)
 
int CompareTo (Edge other)
 Compares the edge with another edge. Defines a lexicographical order as follows: More...
 

Properties

Rule Rule [get, set]
 The source rule. More...
 
int Dot [get, set]
 Position of the dot. More...
 
int Left [get, set]
 Left node number. More...
 
int Right [get, set]
 Right node number. More...
 
bool IsActive [get, set]
 Determines whether the edge is active. More...
 
bool IsPassive [get, set]
 Complement of IsActive (convenience property). More...
 
Symbol NextSymbol [get, set]
 Returns the next symbol after the dot. The edge must be active, otherwise is null. More...
 

Detailed Description

Represents an edge in the chart created by the ChartParser. This is an immutable class.
The Edge contains four values:

Edge is usually written in the form (l, r) A -> alpha . beta which means that this edge "covers" tokens l to r in the input (alpha) and is yet to cover beta.

Edge is said to be active iff beta is not empty (that is, dot < n). Otherwise the rule is said to be passive.

For an edge to be valid the following conditions must hold:

  1. source rule is valid,

  2. a) dot == 0 if the source rule is an epsilon rule
    b) 0 <= dot <= n otherwise (n is the count of RHS symbols)
  3. left <= right

Definition at line 37 of file Edge.cs.

Constructor & Destructor Documentation

Mercury.Syntax.Edge.Edge ( Rule  rule,
int  dot,
int  left,
int  right 
)

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

Parameters
ruleThe source rule.
dotPosition of the dot.
leftLeft node number.
rightRight node number.
Exceptions
System.ArgumentNullExceptionWhen the source rule is null.
Mercury.Exceptions.InvalidEdgeExceptionWhen the edge is not valid.

Definition at line 55 of file Edge.cs.

Member Function Documentation

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

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

  1. compare left node numbers
  2. compare right node numbers
  3. lexicobraphically compare source rules
  4. compare dot positions
Parameters
otherAnother edge
Returns
A value that indicates the relative order of the edges. See IComparable.

Definition at line 179 of file Edge.cs.

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

Definition at line 124 of file Edge.cs.

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

Definition at line 155 of file Edge.cs.

override int Mercury.Syntax.Edge.GetHashCode ( )

Definition at line 130 of file Edge.cs.

bool Mercury.Syntax.Edge.IsValid ( )

Determines whether this edge is valid.

Returns
true if the edge is valid, false otherwise.

Definition at line 117 of file Edge.cs.

override string Mercury.Syntax.Edge.ToString ( )

Definition at line 133 of file Edge.cs.

Property Documentation

int Mercury.Syntax.Edge.Dot
getset

Position of the dot.

Definition at line 76 of file Edge.cs.

bool Mercury.Syntax.Edge.IsActive
getset

Determines whether the edge is active.

true if the edge is active, false otherwise

Definition at line 91 of file Edge.cs.

bool Mercury.Syntax.Edge.IsPassive
getset

Complement of IsActive (convenience property).

true if the rule is not active false otherwise

Definition at line 100 of file Edge.cs.

int Mercury.Syntax.Edge.Left
getset

Left node number.

Definition at line 79 of file Edge.cs.

Symbol Mercury.Syntax.Edge.NextSymbol
getset

Returns the next symbol after the dot. The edge must be active, otherwise is null.

Definition at line 106 of file Edge.cs.

int Mercury.Syntax.Edge.Right
getset

Right node number.

Definition at line 82 of file Edge.cs.

Rule Mercury.Syntax.Edge.Rule
getset

The source rule.

Definition at line 73 of file Edge.cs.


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