net.sourceforge.chaperon.model.extended
Class ExtendedGrammar

java.lang.Object
  extended by net.sourceforge.chaperon.model.extended.ExtendedGrammar
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ExtendedGrammar
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class represents a model for a grammar. The content of the grammar includes the definitions, start symbol, associativities and priorities.

Version:
CVS $Id: ExtendedGrammar.java,v 1.19 2004/01/08 11:30:52 benedikta Exp $
Author:
Stephan Michels
See Also:
Serialized Form

Constructor Summary
ExtendedGrammar()
          Creates an empty grammar.
 
Method Summary
 void addDefinition(Definition definition)
          Add a definition to this grammar.
 java.lang.Object clone()
          Creates a clone of this grammar.
 PatternSet getAllPattern()
           
 Definition getDefinition(int index)
          Return a definition giving by an index.
 Definition getDefinition(java.lang.String symbol)
          Returns all definition for given nonterminal symbol as a list of indices.
 int getDefinitionCount()
          Returns the count of definitions in this grammar.
 Definition[] getDefinitions()
           
 Pattern getEndPattern()
           
 PatternSet getFirstSet()
           
 PatternSet getFirstSet(java.lang.String symbol)
           
 PatternSet getLastSet()
           
 PatternSet getLastSet(java.lang.String symbol)
           
 java.lang.String getLocation()
          Returns the location from the input source.
 Pattern getStartPattern()
           
 java.lang.String getStartSymbol()
          Return the start symbol.
 boolean isNullable(java.lang.String symbol)
           
 void setLocation(java.lang.String location)
          Set the location from the input source.
 void setStartSymbol(java.lang.String symbol)
          Set the start symbol for this grammar.
 java.lang.String toString()
          Return a string representation of the grammar.
 java.lang.String toString(PatternSet previous, PatternSet next)
           
 void update()
           
 void updateAscendingSuccessors()
           
 void updateDescendingSuccessors()
           
 Violations validate()
          Validated the grammar.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendedGrammar

public ExtendedGrammar()
Creates an empty grammar.

Method Detail

addDefinition

public void addDefinition(Definition definition)
Add a definition to this grammar.

Parameters:
definition - Definition, which should be added.

getDefinition

public Definition getDefinition(int index)
Return a definition giving by an index.

Parameters:
index - Index of the Definition.
Returns:
The definition.

getDefinition

public Definition getDefinition(java.lang.String symbol)
Returns all definition for given nonterminal symbol as a list of indices.

Parameters:
ntsymbol - Nonterminal symbol
Returns:
List of indices from the definitions

getDefinitions

public Definition[] getDefinitions()

getDefinitionCount

public int getDefinitionCount()
Returns the count of definitions in this grammar.

Returns:
Count of definitions.

getAllPattern

public PatternSet getAllPattern()

update

public void update()

updateAscendingSuccessors

public void updateAscendingSuccessors()

isNullable

public boolean isNullable(java.lang.String symbol)

getFirstSet

public PatternSet getFirstSet(java.lang.String symbol)

getFirstSet

public PatternSet getFirstSet()

getLastSet

public PatternSet getLastSet(java.lang.String symbol)

getLastSet

public PatternSet getLastSet()

updateDescendingSuccessors

public void updateDescendingSuccessors()

setStartSymbol

public void setStartSymbol(java.lang.String symbol)
Set the start symbol for this grammar.

Parameters:
startSymbol - Start symbol.

getStartSymbol

public java.lang.String getStartSymbol()
Return the start symbol.

Returns:
Start symbol.

getStartPattern

public Pattern getStartPattern()

getEndPattern

public Pattern getEndPattern()

setLocation

public void setLocation(java.lang.String location)
Set the location from the input source.

Parameters:
location - Location in the input source.

getLocation

public java.lang.String getLocation()
Returns the location from the input source.

Returns:
Location in the input source.

validate

public Violations validate()
Validated the grammar.

Returns:
Return a list of violations, if this object isn't valid.

toString

public java.lang.String toString()
Return a string representation of the grammar.

Overrides:
toString in class java.lang.Object
Returns:
String representation.

toString

public java.lang.String toString(PatternSet previous,
                                 PatternSet next)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a clone of this grammar.

Overrides:
clone in class java.lang.Object
Returns:
Clone of this grammar.
Throws:
java.lang.CloneNotSupportedException - If an exception occurs during the cloning.


Copyright ? 2003 Chaperon project. All Rights Reserved.