com.neoworks.rdc
Class Parser

java.lang.Object
  |
  +--com.neoworks.rdc.Parser
Direct Known Subclasses:
JukeXParser

public class Parser
extends java.lang.Object

The purpose of this abstract class is to provide the framework upon which concrete versions of the class are instantiated. The parser will create handles for lexed input, as well as for the output of target code. There will also be a handle for Source code. Contains the basif functions for getting the next token, matching the next token and generating pars error.


Field Summary
static int DUMMY
           
protected  boolean fVerbose
          Set to true to see verbose output
static int ID
           
protected static int LOOKAHEAD_TYPE
           
protected static int LOOKAHEAD_VALUE
           
static int NONE
           
static int NUM
           
static int STRING
           
 
Constructor Summary
protected Parser(java.lang.String sourceCode, java.util.Vector tokens)
          Protected constructor to make sure there can be instantiation of the class only by derived classes
 
Method Summary
protected  void configure(java.lang.String sourceCode, java.util.Vector tokens)
          Configure the parser.
protected  void displayMessageVerbose(java.lang.String verboseStr, java.lang.String shortStr)
           
protected  java.lang.String getLookAheadData()
           
protected  int getLookAheadType()
           
protected  int getLookAheadValue()
           
 boolean getVerbose()
          Get the current verbose logging flag
protected  boolean lookAhead(int type)
           
protected  boolean lookAhead(int type, int value)
           
protected  java.lang.String lookupTokenID(int token_id)
          Lookup a meaningful name for a token based on its number by introspecting the class object.
protected  void match()
          Match any token from the input stream.
protected  void match(int tokenType)
          Match a token from the input stream with a given type.
protected  void match(int tokenType, int tokenValue)
          Match a token from the input stream with a given type and value.
protected  void parseError()
          Simple parse error on the current token
protected  void parseError(int errorToken)
          Generate a parss error for the given token index
protected  void parseError(int errorTokenIndex, java.lang.String errorString)
          Generate a parss error for the given token index with additional error string
protected  void parseError(java.lang.String errorString)
          Simple parse error on the current token with additional error string
 void setVerbose(boolean b)
          Set the verbose logging flag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUMMY

public static final int DUMMY
See Also:
Constant Field Values

NUM

public static final int NUM
See Also:
Constant Field Values

ID

public static final int ID
See Also:
Constant Field Values

STRING

public static final int STRING
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values

LOOKAHEAD_TYPE

protected static final int LOOKAHEAD_TYPE
See Also:
Constant Field Values

LOOKAHEAD_VALUE

protected static final int LOOKAHEAD_VALUE
See Also:
Constant Field Values

fVerbose

protected boolean fVerbose
Set to true to see verbose output

Constructor Detail

Parser

protected Parser(java.lang.String sourceCode,
                 java.util.Vector tokens)
Protected constructor to make sure there can be instantiation of the class only by derived classes

Parameters:
sourceCode - The source code
tokens - List of tokens to parse
Method Detail

configure

protected void configure(java.lang.String sourceCode,
                         java.util.Vector tokens)
Configure the parser. This also runs the lexer over the source code.

Parameters:
sourceCode - Source code
tokens - List of tokens to match

lookAhead

protected boolean lookAhead(int type,
                            int value)

lookAhead

protected boolean lookAhead(int type)

getLookAheadValue

protected int getLookAheadValue()

getLookAheadType

protected int getLookAheadType()

getLookAheadData

protected java.lang.String getLookAheadData()

match

protected void match()
              throws ParserException
Match any token from the input stream. Moves the current pointer.

ParserException

match

protected void match(int tokenType)
              throws ParserException
Match a token from the input stream with a given type. Only match a token of type tokenType. The value is not checked. Moves the current pointer. produces a parse error if not the right type of token.

Parameters:
tokenType - The type of the token to match
ParserException

match

protected void match(int tokenType,
                     int tokenValue)
              throws ParserException
Match a token from the input stream with a given type and value. Only match a token of type tokenType and tokenValue. Moves the current pointer. produces a parse error if not the right type of token.

Parameters:
tokenType - The type of the token to match
tokenValue - The value of the token to match
ParserException

lookupTokenID

protected java.lang.String lookupTokenID(int token_id)
Lookup a meaningful name for a token based on its number by introspecting the class object.

Parameters:
token_id - ID of token look up.

parseError

protected void parseError()
                   throws ParserException
Simple parse error on the current token

ParserException

parseError

protected void parseError(java.lang.String errorString)
                   throws ParserException
Simple parse error on the current token with additional error string

Parameters:
errorString - The optional string to show in the error
ParserException

parseError

protected void parseError(int errorToken)
                   throws ParserException
Generate a parss error for the given token index

Parameters:
errorToken - The index of the token which is in error
ParserException

parseError

protected void parseError(int errorTokenIndex,
                          java.lang.String errorString)
                   throws ParserException
Generate a parss error for the given token index with additional error string

Parameters:
errorString - The optional string to show in the error
ParserException

setVerbose

public void setVerbose(boolean b)
Set the verbose logging flag

Parameters:
b - Verbosity flag value

getVerbose

public boolean getVerbose()
Get the current verbose logging flag

Returns:
The verbose logging flag

displayMessageVerbose

protected void displayMessageVerbose(java.lang.String verboseStr,
                                     java.lang.String shortStr)