parser
Class Parser

java.lang.Object
  extended by parser.Parser
All Implemented Interfaces:
ParserConstants, ParserTreeConstants

public final class Parser
extends Object
implements ParserTreeConstants, ParserConstants

Generated parser class.


Nested Class Summary
 
Nested classes/interfaces inherited from interface parser.ParserTreeConstants
ParserTreeConstants.Kind
 
Field Summary
protected  TreeSet<String> encScopeIds
          The ids in the currently enclosing scope.
protected  ErrorHandler errorHandler
          The ErrorHandler to use for reporting errors.
protected  String filename
          The filename (possibly fake) of the file being parse.
 Token jj_nt
           
protected  parser.JJTParserState jjtree
           
 boolean lookingAhead
           
protected  TreeSet<String> scopeIds
          The ids in the current scope, that is, the declaration/accumulation now being parsed.
protected  Stack<TreeSet<String>> scopeStack
          The scope stack is simply a stack of scopes, a scope being the set of all identifiers declared so far.
 Token token
           
 ParserTokenManager token_source
           
 
Fields inherited from interface parser.ParserTreeConstants
JJTACCUMSTATEMENT, JJTATTRSTATEMENT, JJTBARESTRING, JJTCONTROLLERBLOCK, JJTGUIFILE, JJTHANDLERSTATEMENT, JJTIDENTIFIER, JJTSTRINGVALUE, JJTVOID, JJTWIDGETDECLARATOR, JJTWIDGETSTATEMENT
 
Fields inherited from interface parser.ParserConstants
AFTERCOLON, BARESTRING, BRACE_CLOSE, BRACE_OPEN, COLON, COMMA, DEFAULT, EOF, ERROR, IDCHAR, IDENTIFIER, IDSTART, SEMICOLON, STRING, tokenImage, WHITESPACE
 
Constructor Summary
Parser(InputStream stream)
           
Parser(InputStream stream, String encoding)
           
Parser(ParserTokenManager tm)
           
Parser(Reader stream)
           
 
Method Summary
 void AccumStatement()
           
 void AttrStatement()
           
 void AttrStatementOnly()
           
 void AttrValue()
           
 void BareString()
           
protected  void continueBlock()
          Skip the current statement and continue the block.
 void ControllerBlock()
           
 void disable_tracing()
           
 void enable_tracing()
           
 ParseException generateParseException()
          Make a parse exception and pass it the current state of the parser.
 Token getNextToken()
          Get the next token parsed.
 Token getToken(int index)
           
protected  ParserTokenManager getTokenSource()
          Retrieve the lexer (known to JavaCC as the token manager).
 parser.GUINode GUIFile()
           
 void HandlerStatement()
           
 String Identifier()
           
protected  void jjtreeCloseNodeScope(parser.GUINode node)
          The JJTree hook called when a node scope is closed.
protected  void jjtreeOpenNodeScope(parser.GUINode node)
          The JJTree hook called when a node scope is opened.
protected  void leaveBlock()
          Skip to the end of the current block.
static void main(String... args)
          Quick command-line test functionality; reads from standard input and displays a syntax tree.
protected  void markBlock()
          Mark the current block, so that parsing may skip to the end.
 void MultiAccumStatement()
           
 void MultiWidgetStatement()
           
static GUIFile parse(InputStream ins)
          Parse an input stream into a list of widgets.
static GUIFile parse(InputStream ins, String filename, ErrorHandler handler)
          Parse an input stream into a list of widgets.
protected  void raiseError(ParseException error)
          Report the given error using the error handler.
protected  void raiseError(String msg)
          Report a syntax error with the given error message using the error handler.
 void ReInit(InputStream stream)
           
 void ReInit(InputStream stream, String encoding)
           
 void ReInit(ParserTokenManager tm)
           
 void ReInit(Reader stream)
           
 void SingleAccumStatement()
           
 void SingleWidgetStatement()
           
protected  Token skipUntil(int skipTgt, Integer... moreTgts)
          Skip parsing until a token of one of the given types is found.
 void Statement()
           
 void StringValue()
           
 void WidgetDeclarator()
           
 void WidgetStatement()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jjtree

protected parser.JJTParserState jjtree

token_source

public ParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead

filename

protected String filename
The filename (possibly fake) of the file being parse.


scopeStack

protected final Stack<TreeSet<String>> scopeStack
The scope stack is simply a stack of scopes, a scope being the set of all identifiers declared so far. This is used to distinguish accumulation from declaration. Conceptually, this is not the entire stack; rather, scopeIds is the top of the stack, and encScopeIds is the next one down. This relationship is an invariant that must be maintained.


scopeIds

protected TreeSet<String> scopeIds
The ids in the current scope, that is, the declaration/accumulation now being parsed. When the current node scope is closed, this will disappear.


encScopeIds

protected TreeSet<String> encScopeIds
The ids in the currently enclosing scope. These are the ones that are in scope from one declaration block to the next. Any declarator that includes an identifier adds this id to the enclosing scope. When the node scope is closed, this will be assigned to scopeIds and a scope will be popped off the stack.


errorHandler

protected ErrorHandler errorHandler
The ErrorHandler to use for reporting errors.

Constructor Detail

Parser

public Parser(InputStream stream)

Parser

public Parser(InputStream stream,
              String encoding)

Parser

public Parser(Reader stream)

Parser

public Parser(ParserTokenManager tm)
Method Detail

getTokenSource

protected ParserTokenManager getTokenSource()
Retrieve the lexer (known to JavaCC as the token manager). Implemented by the Parser class generated by JavaCC.

Returns:
The lexer being used for parsing.

GUIFile

public final parser.GUINode GUIFile()
                             throws ParseException
Throws:
ParseException

ControllerBlock

public final void ControllerBlock()
                           throws ParseException
Throws:
ParseException

HandlerStatement

public final void HandlerStatement()
                            throws ParseException
Throws:
ParseException

Statement

public final void Statement()
                     throws ParseException
Throws:
ParseException

WidgetStatement

public final void WidgetStatement()
                           throws ParseException
Throws:
ParseException

SingleWidgetStatement

public final void SingleWidgetStatement()
                                 throws ParseException
Throws:
ParseException

MultiWidgetStatement

public final void MultiWidgetStatement()
                                throws ParseException
Throws:
ParseException

AccumStatement

public final void AccumStatement()
                          throws ParseException
Throws:
ParseException

SingleAccumStatement

public final void SingleAccumStatement()
                                throws ParseException
Throws:
ParseException

MultiAccumStatement

public final void MultiAccumStatement()
                               throws ParseException
Throws:
ParseException

WidgetDeclarator

public final void WidgetDeclarator()
                            throws ParseException
Throws:
ParseException

AttrStatement

public final void AttrStatement()
                         throws ParseException
Throws:
ParseException

AttrStatementOnly

public final void AttrStatementOnly()
                             throws ParseException
Throws:
ParseException

AttrValue

public final void AttrValue()
                     throws ParseException
Throws:
ParseException

StringValue

public final void StringValue()
                       throws ParseException
Throws:
ParseException

BareString

public final void BareString()
                      throws ParseException
Throws:
ParseException

Identifier

public final String Identifier()
                        throws ParseException
Throws:
ParseException

ReInit

public void ReInit(InputStream stream)

ReInit

public void ReInit(InputStream stream,
                   String encoding)

ReInit

public void ReInit(Reader stream)

ReInit

public void ReInit(ParserTokenManager tm)

getNextToken

public final Token getNextToken()
Get the next token parsed. Implemented by the Parser class generated by JavaCC.

Returns:
The next token parsed.

getToken

public final Token getToken(int index)

generateParseException

public ParseException generateParseException()
Make a parse exception and pass it the current state of the parser. Implemented by the Parser class generated by JavaCC.

Returns:
A new ParseException.

enable_tracing

public final void enable_tracing()

disable_tracing

public final void disable_tracing()

main

public static void main(String... args)
                 throws Throwable
Quick command-line test functionality; reads from standard input and displays a syntax tree.

Parameters:
args - Command-line arguments; ignored.
Throws:
Throwable - If bad things happen.

jjtreeOpenNodeScope

protected final void jjtreeOpenNodeScope(parser.GUINode node)
The JJTree hook called when a node scope is opened.

Parameters:
node - The opened node.

jjtreeCloseNodeScope

protected final void jjtreeCloseNodeScope(parser.GUINode node)
The JJTree hook called when a node scope is closed.

Parameters:
node - The closed node.

parse

public static GUIFile parse(InputStream ins,
                            String filename,
                            ErrorHandler handler)
                     throws GUIFileException
Parse an input stream into a list of widgets.

Parameters:
ins - Any input stream, to be parsed.
filename - The filename associated with the input stream. May be faked (e.g. "<stdin>") if no true filename is known.
handler - An error handler.
Returns:
A GUIFile object, as described by the input, or null if there were errors and the handler handled all of them.
Throws:
GUIFileException - If the input is invalid and the error handler couldn't handle an error.

parse

public static GUIFile parse(InputStream ins)
                     throws GUIFileException
Parse an input stream into a list of widgets.

Parameters:
ins - Any input stream, to be parsed.
Returns:
A GUIFile object, as described by the input.
Throws:
GUIFileException - If the input is invalid.

skipUntil

protected final Token skipUntil(int skipTgt,
                                Integer... moreTgts)
Skip parsing until a token of one of the given types is found.

Parameters:
skipTgt - A token type to stop skipping on.
moreTgts - Other token types.
Returns:
The first token found matching one of the given types, or the EOF token.

raiseError

protected final void raiseError(ParseException error)
                         throws ParseException
Report the given error using the error handler.

Parameters:
error - The exception representing the error to report.
Throws:
ParseException - If the error handler passes on the error.

raiseError

protected final void raiseError(String msg)
                         throws ParseException
Report a syntax error with the given error message using the error handler.

Parameters:
msg - The error message.
Throws:
ParseException - If the error handler passes on the error.

markBlock

protected final void markBlock()
Mark the current block, so that parsing may skip to the end.


continueBlock

protected final void continueBlock()
Skip the current statement and continue the block.


leaveBlock

protected void leaveBlock()
Skip to the end of the current block.