Pep 0.4 API Documentation

edu.osu.ling.pep
Class Rule

java.lang.Object
  extended by edu.osu.ling.pep.Rule
Direct Known Subclasses:
DottedRule

public class Rule
extends Object

Represents a production rule in a context-free grammar.

Rules contain a single category on the left side that produces the series of categories on the right side.

Rules are immutable and cannot be changed once instantiated.

Version:
$LastChangedRevision: 1782 $
Author:
Scott Martin
See Also:
Category, Grammar

Constructor Summary
Rule(Category left, Category... right)
          Creates a new rule with the specified left side category and series of categories on the right side.
 
Method Summary
 boolean equals(Object obj)
          Tests whether this rule is equal to another, with the same left and right sides.
 Category getLeft()
          Gets the left side category of this rule.
 Category[] getRight()
          Gets the series of categories on the right side of this rule.
 int hashCode()
          Compues a hash code for this rule based on its left and right side categories.
 boolean isPreterminal()
          Tests whether this rule is a pre-terminal production rule.
 boolean isSingletonPreterminal()
          Tests whether this rule is a pre-terminal with a right side of length 1.
 String toString()
          Gets a string representation of this rule.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rule

public Rule(Category left,
            Category... right)
Creates a new rule with the specified left side category and series of categories on the right side.

Parameters:
left - The left side (trigger) for this production rule.
right - The right side (productions) licensed for this rule's left side.
Throws:
IllegalArgumentException - If
  1. the specified left or right categories are null,
  2. the right series is zero-length,
  3. the right side contains a null category.
Method Detail

equals

public boolean equals(Object obj)
Tests whether this rule is equal to another, with the same left and right sides.

Overrides:
equals in class Object
Returns:
true iff the specified object is an instance of Rule and its left and right sides are equal to this rule's left and right sides.

getLeft

public Category getLeft()
Gets the left side category of this rule.


getRight

public Category[] getRight()
Gets the series of categories on the right side of this rule.


hashCode

public int hashCode()
Compues a hash code for this rule based on its left and right side categories.

Overrides:
hashCode in class Object

isPreterminal

public boolean isPreterminal()
Tests whether this rule is a pre-terminal production rule. A rule is a preterminal rule if its right side contains a terminal category.

Returns:
true iff this rule's right side contains a terminal category.

isSingletonPreterminal

public boolean isSingletonPreterminal()
Tests whether this rule is a pre-terminal with a right side of length 1.

Since:
0.4
See Also:
isPreterminal(), getRight()

toString

public String toString()
Gets a string representation of this rule.

Overrides:
toString in class Object
Returns:
"S -> NP VP" for a rule with a left side category of S and a right side sequence [NP, VP].
See Also:
Category.toString()

Pep: Pep is an Earley parser

Pep API Documentation, Copyright © 2007 Scott Martin

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the overview file.