openjava.syntax
Class SeparatedListRule

java.lang.Object
  |
  +--openjava.syntax.AbstractSyntaxRule
        |
        +--openjava.syntax.SeparatedListRule
All Implemented Interfaces:
SyntaxRule, TokenID
Direct Known Subclasses:
DefaultListRule, ExpressionListRule

public abstract class SeparatedListRule
extends AbstractSyntaxRule

The class SeparatedListRule represents the syntax rule of a list separated by an separator.

Suppose there's a syntax rule A and token t. This class can represents the syntax A ( t A )*.

Since:
%SOFTWARE% 1.0
See Also:
Object

Fields inherited from interface openjava.syntax.TokenID
ABSTRACT, ANDASSIGN, ASSIGN, BANG, BIT_AND, BIT_OR, BOOLEAN, BREAK, BYTE, CASE, CATCH, CHAR, CHARACTER_LITERAL, CLASS, COLON, COMMA, CONDITIONAL_AND, CONDITIONAL_OR, CONTINUE, DECREMENT, DEFAULT, DO, DOT, DOUBLE, DOUBLE_LITERAL, ELSE, EOF, EQUAL, EXTENDS, FALSE, FINAL, FINALLY, FLOAT, FLOAT_LITERAL, FOR, GREATER, GREATER_EQUAL, HOOK, IDENTIFIER, IF, IMPLEMENTS, IMPORT, INCREMENT, INSTANCEOF, INSTANTIATES, INT, INTEGER_LITERAL, INTERFACE, LBRACE, LBRACKET, LESS, LESS_EQUAL, LONG, LONG_LITERAL, LPAREN, LSHIFT, LSHIFTASSIGN, METACLASS, MINUS, MINUSASSIGN, NATIVE, NEW, NOT_EQUAL, NULL, ORASSIGN, PACKAGE, PLUS, PLUSASSIGN, PRIVATE, PROTECTED, PUBLIC, RBRACE, RBRACKET, REM, REMASSIGN, RETURN, RPAREN, RSIGNEDSHIFT, RSIGNEDSHIFTASSIGN, RUNSIGNEDSHIFT, RUNSIGNEDSHIFTASSIGN, SEMICOLON, SHORT, SLASH, SLASHASSIGN, STAR, STARASSIGN, STATIC, STRING_LITERAL, SUPER, SWITCH, SYNCHRONIZED, THIS, THROW, THROWS, TILDE, TRANSIENT, TRUE, TRY, VOID, VOLATILE, WHILE, XOR, XORASSIGN
 
Constructor Summary
SeparatedListRule(SyntaxRule elementRule, int separator_token)
          Allocates a new rule representing a list of a give rule separeted by a given separator.
SeparatedListRule(SyntaxRule elementRule, int separator_token, boolean allowsEmpty)
          Allocates a new rule representing a list of a give rule separeted by a given separator.
 
Method Summary
protected abstract  void addListElement(java.lang.Object elem)
           
 ParseTree consume(TokenSource token_src)
          Consumes token source.
protected abstract  ParseTree getList()
           
protected abstract  void initList()
           
 
Methods inherited from class openjava.syntax.AbstractSyntaxRule
getSyntaxException, lookahead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeparatedListRule

public SeparatedListRule(SyntaxRule elementRule,
                         int separator_token,
                         boolean allowsEmpty)
Allocates a new rule representing a list of a give rule separeted by a given separator.
Parameters:
elementRule - a rule of each element of the list
separator_token - the id of a token to be separator
allowEmpty - a flag to allow 0 iteration if it is true.
See Also:
TokenID

SeparatedListRule

public SeparatedListRule(SyntaxRule elementRule,
                         int separator_token)
Allocates a new rule representing a list of a give rule separeted by a given separator.
Parameters:
elementRule - a rule of each element of the list
separator_token - the id of a token to be separator
See Also:
TokenID
Method Detail

initList

protected abstract void initList()

addListElement

protected abstract void addListElement(java.lang.Object elem)

getList

protected abstract ParseTree getList()

consume

public final ParseTree consume(TokenSource token_src)
                        throws SyntaxException
Consumes token source.
Overrides:
consume in class AbstractSyntaxRule
Parameters:
token_src - token source.
Returns:
null if this fails to consume a syntax tree represented by this object. Otherwise it returns ObjectList object.