JBoss Dynamic Model Representation API 1.2.0.Beta1

org.jboss.dmr
Class Parser

java.lang.Object
  extended by org.jboss.dmr.Parser

public abstract class Parser
extends Object

Author:
David M. Lloyd

Field Summary
protected static int ARROW
           
protected static int BIG
           
protected static int BYTES
           
protected static int CLOSE_BRACE
           
protected static int CLOSE_BRACKET
           
protected static int CLOSE_PAREN
           
protected static int COMMA
           
protected static int DEC_VAL
           
protected static int DECIMAL
           
protected static int DOUBLE_SPECIAL_VAL
           
protected static int EXPRESSION
           
protected static int FALSE
           
protected static int INITIAL
           
protected static int INT_HEX_VAL
           
protected static int INT_VAL
           
protected static int INTEGER
           
protected static int LONG_HEX_VAL
           
protected static int LONG_VAL
           
protected static int OPEN_BRACE
           
protected static int OPEN_BRACKET
           
protected static int OPEN_PAREN
           
protected static int STR_VAL
           
protected static int TRUE
           
protected static int TYPE_VAL
           
protected static int UNDEFINED
           
 
Constructor Summary
Parser()
           
 
Method Summary
protected  void begin(int baseState)
          Set the lexer's current state.
protected  void begin(String state)
          This function is used to change the initial state for the lexer.
 void echo()
          Print the current string token to the standard output.
 InputStream getInput()
          Obtain the current input.
 void setBufferSize(int bufferSize)
          Set the internal buffer size.
 void setInput(InputStream is)
          Set the current input.
protected  void yyClearError()
          Clear the error flag.
protected  Object yyGetValue(int arg)
          Gets the object value associated with the symbol at the argument's position.
 int yyInputStackSize()
          Obtain the number of input objects on the stack.
 int yyLength()
          Get the current text token's length.
protected  void yyLess(int n)
          Put all but n characters back to the input stream.
protected  int yyLex()
          Call this function to start the scanning of the input.
 int yyParse()
          Call this function to start parsing.
protected  boolean yyParseError(int terminal)
          This function reports error and return true if critical error occurred, or false if the error has been successfully recovered.
protected  org.jboss.dmr.Parser.YYParserState yyPeekLookahead()
          This function is used by the error handling grammars to check the immediate lookahead token on the stack.
 void yyPopInput()
          Switch the current input to the old input on stack.
protected  void yyPopLexerState()
          Restore the previous lexer state.
protected  void yyPopLookahead()
          This function is used by the error handling grammars to pop an unwantted token from the lookahead stack.
 void yyPushInput(InputStream is)
          Switch the current input to the new input.
protected  void yyPushLexerState(int newState)
          Push the current state onto lexer state onto stack and begin the new state specified by the user.
protected  void yyPushLexerState(String state)
          Push the current state onto lexer state onto stack and begin the new state specified by the user.
protected  boolean yyRefreshBuffer()
           
 void yyResetBuffer()
          Reset the internal buffer.
protected  void yySetValue(Object value)
          Set the object value for the current non-terminal being reduced.
 String yyText()
          Get the current token text.
protected  boolean yyWrap()
          Check if there are more inputs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_BRACE

protected static final int OPEN_BRACE
See Also:
Constant Field Values

CLOSE_BRACE

protected static final int CLOSE_BRACE
See Also:
Constant Field Values

OPEN_BRACKET

protected static final int OPEN_BRACKET
See Also:
Constant Field Values

CLOSE_BRACKET

protected static final int CLOSE_BRACKET
See Also:
Constant Field Values

OPEN_PAREN

protected static final int OPEN_PAREN
See Also:
Constant Field Values

CLOSE_PAREN

protected static final int CLOSE_PAREN
See Also:
Constant Field Values

ARROW

protected static final int ARROW
See Also:
Constant Field Values

COMMA

protected static final int COMMA
See Also:
Constant Field Values

BIG

protected static final int BIG
See Also:
Constant Field Values

BYTES

protected static final int BYTES
See Also:
Constant Field Values

INTEGER

protected static final int INTEGER
See Also:
Constant Field Values

DECIMAL

protected static final int DECIMAL
See Also:
Constant Field Values

EXPRESSION

protected static final int EXPRESSION
See Also:
Constant Field Values

UNDEFINED

protected static final int UNDEFINED
See Also:
Constant Field Values

TRUE

protected static final int TRUE
See Also:
Constant Field Values

FALSE

protected static final int FALSE
See Also:
Constant Field Values

INT_VAL

protected static final int INT_VAL
See Also:
Constant Field Values

INT_HEX_VAL

protected static final int INT_HEX_VAL
See Also:
Constant Field Values

LONG_VAL

protected static final int LONG_VAL
See Also:
Constant Field Values

LONG_HEX_VAL

protected static final int LONG_HEX_VAL
See Also:
Constant Field Values

DOUBLE_SPECIAL_VAL

protected static final int DOUBLE_SPECIAL_VAL
See Also:
Constant Field Values

DEC_VAL

protected static final int DEC_VAL
See Also:
Constant Field Values

STR_VAL

protected static final int STR_VAL
See Also:
Constant Field Values

TYPE_VAL

protected static final int TYPE_VAL
See Also:
Constant Field Values

INITIAL

protected static final int INITIAL
See Also:
Constant Field Values
Constructor Detail

Parser

public Parser()
Method Detail

setInput

public void setInput(InputStream is)
Set the current input.

Parameters:
is - the new input.

getInput

public InputStream getInput()
Obtain the current input.

Returns:
the current input

yyPushInput

public void yyPushInput(InputStream is)
Switch the current input to the new input. The old input and already buffered characters are pushed onto the stack.

Parameters:
is - the new input

yyPopInput

public void yyPopInput()
Switch the current input to the old input on stack. The currently buffered characters are inserted infront of the old buffered characters.


yyInputStackSize

public int yyInputStackSize()
Obtain the number of input objects on the stack.

Returns:
the number of input objects on the stack.

yyText

public String yyText()
Get the current token text.

Avoid calling this function unless it is absolutely necessary since it creates a copy of the token string. The string length can be found by reading _yyLength or calling yyLength () function.

Returns:
the current text token.

yyLength

public int yyLength()
Get the current text token's length. Actions specified in the CookCC file can directly access the variable _yyLength.

Returns:
the string token length

echo

public void echo()
Print the current string token to the standard output.


yyLess

protected void yyLess(int n)
Put all but n characters back to the input stream. Be aware that calling yyLess (0) is allowed, but be sure to change the state some how to avoid an endless loop.

Parameters:
n - The number of characters.

begin

protected void begin(int baseState)
Set the lexer's current state.

Parameters:
baseState - the base state index

yyPushLexerState

protected void yyPushLexerState(int newState)
Push the current state onto lexer state onto stack and begin the new state specified by the user.

Parameters:
newState - the new state.

yyPopLexerState

protected void yyPopLexerState()
Restore the previous lexer state.


yyRefreshBuffer

protected boolean yyRefreshBuffer()
                           throws IOException
Throws:
IOException

yyResetBuffer

public void yyResetBuffer()
Reset the internal buffer.


setBufferSize

public void setBufferSize(int bufferSize)
Set the internal buffer size. This action can only be performed when the buffer is empty. Having a large buffer is useful to read a whole file in to increase the performance sometimes.

Parameters:
bufferSize - the new buffer size.

yyLex

protected int yyLex()
             throws IOException
Call this function to start the scanning of the input.

Returns:
a token or status value.
Throws:
IOException - in case of I/O error.

yyParse

public int yyParse()
            throws IOException
Call this function to start parsing.

Returns:
0 if everything is okay, or 1 if an error occurred.
Throws:
IOException - in case of error

yyPeekLookahead

protected org.jboss.dmr.Parser.YYParserState yyPeekLookahead()
This function is used by the error handling grammars to check the immediate lookahead token on the stack.

Returns:
the top of lookahead stack.

yyPopLookahead

protected void yyPopLookahead()
This function is used by the error handling grammars to pop an unwantted token from the lookahead stack.


yyClearError

protected void yyClearError()
Clear the error flag. If this flag is present and the parser again sees another error transition, it would immediately calls yyParseError, which would by default exit the parser.

This function is used in error recovery.


yyParseError

protected boolean yyParseError(int terminal)
                        throws IOException
This function reports error and return true if critical error occurred, or false if the error has been successfully recovered. IOException is an optional choice of reporting error.

Parameters:
terminal - the terminal that caused the error.
Returns:
true if irrecoverable error occurred. Or simply throw an IOException. false if the parsing can be continued to check for specific error tokens.
Throws:
IOException - in case of error.

yyGetValue

protected Object yyGetValue(int arg)
Gets the object value associated with the symbol at the argument's position.

Parameters:
arg - the symbol position starting from 1.
Returns:
the object value associated with symbol.

yySetValue

protected void yySetValue(Object value)
Set the object value for the current non-terminal being reduced.

Parameters:
value - the object value for the current non-terminal.

begin

protected void begin(String state)
This function is used to change the initial state for the lexer.

Parameters:
state - the name of the state

yyPushLexerState

protected void yyPushLexerState(String state)
Push the current state onto lexer state onto stack and begin the new state specified by the user.

Parameters:
state - the new state.

yyWrap

protected boolean yyWrap()
                  throws IOException
Check if there are more inputs. This function is called when EOF is encountered.

Returns:
true to indicate no more inputs.
Throws:
IOException - in case of an IO error

JBoss Dynamic Model Representation API 1.2.0.Beta1

Copyright © 2010 JBoss, a division of Red Hat, Inc.