cdx.scorebot.scoring.logic.parser
Class LogicParser
java.lang.Object
cdx.scorebot.scoring.logic.parser.LogicParser
- All Implemented Interfaces:
- LogicParserConstants
public class LogicParser
- extends java.lang.Object
- implements LogicParserConstants
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
token_source
public LogicParserTokenManager token_source
token
public Token token
jj_nt
public Token jj_nt
lookingAhead
public boolean lookingAhead
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)
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 parsetestsInfo
- 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 checkvalidIdentifiers
- 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()