Pep 0.4 API Documentation

edu.osu.ling.pep
Class Category

java.lang.Object
  extended by edu.osu.ling.pep.Category

public class Category
extends Object

A category in a grammar. Categories are the atomic subparts that make up grammar rules.

Categories can either be terminal or non-terminal. A terminal category is one from which no further categories can be derived, while non-terminal categories can yield a series of other categories when they occur as the left-hand side of a rule. If a category is created by specifying only its name, this class's corresponding constructor assumes that the category is non-terminal.

Once created, categories are immutable and have no setXxx methods. This ensures that, once loaded in a grammar, a category will remain as it was when created.

Version:
$LastChangedRevision: 556 $
Author:
Scott Martin
See Also:
Rule

Field Summary
static Category START
          Special start category for seeding Earley parsers.
 
Constructor Summary
Category(String name)
          Creates a new non-terminal category with the specified name.
Category(String name, boolean terminal)
          Creates a new category name with the specified terminal status.
 
Method Summary
 boolean equals(Object obj)
          Tests whether this category is equal to another.
 String getName()
          Gets the name of this category.
 int hashCode()
          Computes a hash code for this category based on its name and terminal status.
 boolean isTerminal()
          Gets the terminal status of this category.
 String toString()
          Gets a string representation of this category.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

START

public static final Category START
Special start category for seeding Earley parsers.

Constructor Detail

Category

public Category(String name)
Creates a new non-terminal category with the specified name.

See Also:
Category(String, boolean)

Category

public Category(String name,
                boolean terminal)
Creates a new category name with the specified terminal status.

Parameters:
name - The name for this category.
terminal - Whether or not this category is a terminal.
Throws:
IllegalArgumentException - If name is null or zero-length.
Method Detail

equals

public boolean equals(Object obj)
Tests whether this category is equal to another.

Overrides:
equals in class Object
Returns:
true iff the specified object is an instance of Category and its name and terminal status are equal to this category's name and terminal status.

getName

public String getName()
Gets the name of this category.

Returns:
The value specified for this category's name when it was constructed.

hashCode

public int hashCode()
Computes a hash code for this category based on its name and terminal status.

Overrides:
hashCode in class Object

isTerminal

public boolean isTerminal()
Gets the terminal status of this category.

Returns:
The terminal status specified for this category upon construction.

toString

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

Overrides:
toString in class Object
Returns:
The value of this category's name.

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.