Class Rule
This class implements a production rule, which is of the form: Left Hand Side -> Right Hand Side Left hand side can be a single nonterminal, right hand side can be a sequence of nonterminals. see class description of Nonterminal for more details about the nonterminal type. (Right hand side with length 0 expands to the empty string, i.e. an epsilon rule)
Implements
Inherited Members
Namespace: EarleyParser
Assembly: EarleyParser.dll
Syntax
public class Rule : IEquatable<Rule>
Constructors
| Edit this page View SourceRule(Rule)
Initializes a new instance of the Rule class as a copy of another rule.
Declaration
public Rule(Rule otherRule)
Parameters
| Type | Name | Description |
|---|---|---|
| Rule | otherRule | The rule to copy. |
Rule(string, string[])
Initializes a new instance of the Rule class.
Declaration
public Rule(string lhs, string[] rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lhs | The left-hand side of the rule. |
| string[] | rhs | The right-hand side of the rule. |
Properties
| Edit this page View SourceIsLexical
Gets a value indicating whether this rule is a lexical rule.
Declaration
public bool IsLexical { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
LeftHandSide
Gets the left-hand side of the grammar rule.
Declaration
public string LeftHandSide { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
RightHandSide
Gets the right-hand side of the grammar rule.
Declaration
public string[] RightHandSide { get; set; }
Property Value
| Type | Description |
|---|---|
| string[] |
Methods
| Edit this page View SourceEquals(Rule)
Determines whether this rule equals another rule.
Declaration
public bool Equals(Rule otherRule)
Parameters
| Type | Name | Description |
|---|---|---|
| Rule | otherRule | The rule to compare with. |
Returns
| Type | Description |
|---|---|
| bool | True if the rules are equal, false otherwise. |
Equals(object)
Determines whether this rule equals another object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with. |
Returns
| Type | Description |
|---|---|
| bool | True if the objects are equal, false otherwise. |
Overrides
| Edit this page View SourceExamineRuleForLexicalizedTokens()
Examines the rule to determine if it contains lexicalized tokens.
Declaration
public bool ExamineRuleForLexicalizedTokens()
Returns
| Type | Description |
|---|---|
| bool |
GetHashCode()
Returns the hash code for this rule.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for the current rule. |
Overrides
| Edit this page View SourceISPOSAssignmentRule()
Checks if this rule is a part-of-speech assignment rule.
Declaration
public bool ISPOSAssignmentRule()
Returns
| Type | Description |
|---|---|
| bool | True if the rule assigns a part of speech to a word. |
ToFormattedStackString()
Returns a formatted string representation of the rule.
Declaration
public string ToFormattedStackString()
Returns
| Type | Description |
|---|---|
| string | A string in the format "LHS -> RHS". |
ToString()
Returns a string representation of the rule.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string in the format "LHS -> RHS". |