cdx.scorebot.scoring.logic.parser
Class LogicParser

java.lang.Object
  extended by cdx.scorebot.scoring.logic.parser.LogicParser
All Implemented Interfaces:
LogicParserConstants

public class LogicParser
extends java.lang.Object
implements LogicParserConstants


Field Summary
 Token jj_nt
           
 boolean lookingAhead
           
 Token token
           
 LogicParserTokenManager token_source
           
 
Fields inherited from interface cdx.scorebot.scoring.logic.parser.LogicParserConstants
AND, ARROW, ASSIGN, BANG, COMMA, DEFAULT, DIGIT, DIVIDE, DOT, ELSE, EOF, EQ, GE, GT, IDENTIFIER, IF, IN_MULTI_LINE_COMMENT, IN_QUOTED_STRING, LBRACE, LBRACKET, LE, LETTER, LITERAL_BOOL, LITERAL_FP, LITERAL_INT, LITERAL_NULL, LITERAL_STRING, LPAREN, LT, MINUS, MOD, NE, NEWLINE, OR, PLUS, RBRACE, RBRACKET, RPAREN, SEMICOLON, SINGLE_LINE_COMMENT, TIMES, tokenImage, TYPE_BOOL, TYPE_FP, TYPE_INT, TYPE_STRING, XOR
 
Constructor Summary
LogicParser()
          default constructor
LogicParser(java.io.InputStream stream)
           
LogicParser(java.io.InputStream stream, java.lang.String encoding)
           
LogicParser(LogicParserTokenManager tm)
           
LogicParser(java.io.Reader stream)
           
 
Method Summary
static boolean checkIdentifier(java.lang.String givenIdentifier, java.lang.String[] validIdentifiers)
          returns true if givenIdentifier is in validIdentifiers, and false otherwise
 void disable_tracing()
           
 void enable_tracing()
           
 java.lang.String generateInformedLogicException(LogicException e)
          generates a LogicException documented with the specified line and column at which the error occurred (the stack trace is preserved)
 java.lang.String generateInformedLogicException(TokenMgrError e)
          generates a LogicException documented with the specified line and column at which the error occurred (the stack trace is preserved)
 ParseException generateParseException()
           
 Token getNextToken()
           
 java.lang.String getParseLoc()
          returns the line and column at which this occurred
 java.util.Vector<TestIdentifier> getTestsUsed()
           
 Token getToken(int index)
           
static void main(java.lang.String[] args)
           
 LogicUnit parseString(java.lang.String code)
          parse the specified code into a LogicUnit
 LogicUnit parseString(java.lang.String code, java.util.HashMap<java.lang.String,TestData> testsInfo)
          parse the specified code into a LogicUnit
 AdditiveExpression prAdditiveExpression()
           
 ArgumentList prArgumentList()
           
 Arguments prArguments()
           
 Assignment prAssignment()
           
 OperatorType prAssignmentOperator()
           
 Block prBlock()
           
 BlockStatementType prBlockStatement()
           
 ConditionalAndExpression prConditionalAndExpression()
           
 ConditionalOrExpression prConditionalOrExpression()
           
 EqualityExpression prEqualityExpression()
           
 ConditionalXorExpression prExclusiveOrExpression()
           
 Expression prExpression()
           
 Identifier prIdentifier()
           
 IfStatement prIfStatement()
           
 Literal prLiteral()
           
 LogicUnit prLogicUnit()
           
 Method prMethod()
           
 Identifier prMethodIdentifier()
           
 MultiplicativeExpression prMultiplicativeExpression()
           
 PrimaryExpression prPrimaryExpression()
           
 RelationalExpression prRelationalExpression()
           
 Statement prStatement()
           
 TestIdentifier prTestIdentifier()
           
 LiteralType prType()
           
 UnaryExpression prUnaryExpression()
           
 VariableInitialization prVariableInitialization()
           
 VoidMethod prVoidMethod()
           
 Identifier prVoidMethodIdentifier()
           
 void ReInit(java.io.InputStream stream)
           
 void ReInit(java.io.InputStream stream, java.lang.String encoding)
           
 void ReInit(LogicParserTokenManager tm)
           
 void ReInit(java.io.Reader stream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public LogicParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead
Constructor Detail

LogicParser

public LogicParser()
default constructor


LogicParser

public LogicParser(java.io.InputStream stream)

LogicParser

public LogicParser(java.io.InputStream stream,
                   java.lang.String encoding)

LogicParser

public LogicParser(java.io.Reader stream)

LogicParser

public LogicParser(LogicParserTokenManager tm)
Method Detail

getTestsUsed

public java.util.Vector<TestIdentifier> getTestsUsed()

parseString

public LogicUnit parseString(java.lang.String code)
                      throws LogicException,
                             ParseException
parse the specified code into a LogicUnit

Parameters:
code - the code to parse
Throws:
ParseException - if the code cannot be parsed
LogicException

parseString

public LogicUnit parseString(java.lang.String code,
                             java.util.HashMap<java.lang.String,TestData> testsInfo)
                      throws LogicException,
                             ParseException
parse the specified code into a LogicUnit

Parameters:
code - the code to parse
testsInfo - information about tests this may contain and the literal types of options and results they hold
Throws:
ParseException - if the code cannot be parsed
LogicException

main

public static void main(java.lang.String[] args)
                 throws LogicException,
                        ParseException,
                        TokenMgrError
Throws:
LogicException
ParseException
TokenMgrError

checkIdentifier

public static final boolean checkIdentifier(java.lang.String givenIdentifier,
                                            java.lang.String[] validIdentifiers)
returns true if givenIdentifier is in validIdentifiers, and false otherwise

Parameters:
givenIdentifier - the identifier to check
validIdentifiers - an array of valid identifiers
Returns:
true if givenIdentifier is the same as one of the identifiers in validIdentifiers

getParseLoc

public java.lang.String getParseLoc()
returns the line and column at which this occurred


generateInformedLogicException

public java.lang.String generateInformedLogicException(LogicException e)
                                                throws LogicException
generates a LogicException documented with the specified line and column at which the error occurred (the stack trace is preserved)

Throws:
LogicException

generateInformedLogicException

public java.lang.String generateInformedLogicException(TokenMgrError e)
                                                throws LogicException
generates a LogicException documented with the specified line and column at which the error occurred (the stack trace is preserved)

Throws:
LogicException

prLogicUnit

public final LogicUnit prLogicUnit()
                            throws ParseException,
                                   LogicException
Throws:
ParseException
LogicException

prBlock

public final Block prBlock()
                    throws ParseException,
                           LogicException
Throws:
ParseException
LogicException

prBlockStatement

public final BlockStatementType prBlockStatement()
                                          throws ParseException,
                                                 LogicException
Throws:
ParseException
LogicException

prVariableInitialization

public final VariableInitialization prVariableInitialization()
                                                      throws ParseException,
                                                             LogicException
Throws:
ParseException
LogicException

prStatement

public final Statement prStatement()
                            throws ParseException,
                                   LogicException
Throws:
ParseException
LogicException

prVoidMethod

public final VoidMethod prVoidMethod()
                              throws ParseException,
                                     LogicException
Throws:
ParseException
LogicException

prMethod

public final Method prMethod()
                      throws ParseException,
                             LogicException
Throws:
ParseException
LogicException

prType

public final LiteralType prType()
                         throws ParseException
Throws:
ParseException

prExpression

public final Expression prExpression()
                              throws ParseException,
                                     LogicException
Throws:
ParseException
LogicException

prIfStatement

public final IfStatement prIfStatement()
                                throws ParseException,
                                       LogicException
Throws:
ParseException
LogicException

prAssignment

public final Assignment prAssignment()
                              throws ParseException,
                                     LogicException
Throws:
ParseException
LogicException

prAssignmentOperator

public final OperatorType prAssignmentOperator()
                                        throws ParseException
Throws:
ParseException

prPrimaryExpression

public final PrimaryExpression prPrimaryExpression()
                                            throws ParseException,
                                                   LogicException
Throws:
ParseException
LogicException

prIdentifier

public final Identifier prIdentifier()
                              throws ParseException
Throws:
ParseException

prTestIdentifier

public final TestIdentifier prTestIdentifier()
                                      throws ParseException,
                                             LogicException
Throws:
ParseException
LogicException

prMethodIdentifier

public final Identifier prMethodIdentifier()
                                    throws ParseException,
                                           LogicException
Throws:
ParseException
LogicException

prVoidMethodIdentifier

public final Identifier prVoidMethodIdentifier()
                                        throws ParseException,
                                               LogicException
Throws:
ParseException
LogicException

prLiteral

public final Literal prLiteral()
                        throws ParseException,
                               LogicException
Throws:
ParseException
LogicException

prArguments

public final Arguments prArguments()
                            throws ParseException,
                                   LogicException
Throws:
ParseException
LogicException

prArgumentList

public final ArgumentList prArgumentList()
                                  throws ParseException,
                                         LogicException
Throws:
ParseException
LogicException

prConditionalOrExpression

public final ConditionalOrExpression prConditionalOrExpression()
                                                        throws ParseException,
                                                               LogicException
Throws:
ParseException
LogicException

prConditionalAndExpression

public final ConditionalAndExpression prConditionalAndExpression()
                                                          throws ParseException,
                                                                 LogicException
Throws:
ParseException
LogicException

prExclusiveOrExpression

public final ConditionalXorExpression prExclusiveOrExpression()
                                                       throws ParseException,
                                                              LogicException
Throws:
ParseException
LogicException

prEqualityExpression

public final EqualityExpression prEqualityExpression()
                                              throws ParseException,
                                                     LogicException
Throws:
ParseException
LogicException

prRelationalExpression

public final RelationalExpression prRelationalExpression()
                                                  throws ParseException,
                                                         LogicException
Throws:
ParseException
LogicException

prAdditiveExpression

public final AdditiveExpression prAdditiveExpression()
                                              throws ParseException,
                                                     LogicException
Throws:
ParseException
LogicException

prMultiplicativeExpression

public final MultiplicativeExpression prMultiplicativeExpression()
                                                          throws ParseException,
                                                                 LogicException
Throws:
ParseException
LogicException

prUnaryExpression

public final UnaryExpression prUnaryExpression()
                                        throws ParseException,
                                               LogicException
Throws:
ParseException
LogicException

ReInit

public void ReInit(java.io.InputStream stream)

ReInit

public void ReInit(java.io.InputStream stream,
                   java.lang.String encoding)

ReInit

public void ReInit(java.io.Reader stream)

ReInit

public void ReInit(LogicParserTokenManager tm)

getNextToken

public final Token getNextToken()

getToken

public final Token getToken(int index)

generateParseException

public ParseException generateParseException()

enable_tracing

public final void enable_tracing()

disable_tracing

public final void disable_tracing()