コード例 #1
0
ファイル: ParserImpl.java プロジェクト: chashnikov/funCalc
 private BooleanExpression parseBooleanExpression() {
   Expression left = parseExpression();
   TokenType type = myLexer.nextToken();
   ComparisonOperation operation = BOOLEAN_OPERATIONS.get(type);
   if (operation == null) {
     throw new ParsingException(
         "'<', '>', '<=', '>=', '!=' or '==' expected but " + myLexer.getToken() + " found");
   }
   Expression right = parseExpression();
   return new ComparisonExpression(operation, left, right);
 }
コード例 #2
0
ファイル: ParserImpl.java プロジェクト: chashnikov/funCalc
 static {
   BOOLEAN_OPERATIONS.put(TokenType.EQUAL, Operations.EQUAL);
   BOOLEAN_OPERATIONS.put(TokenType.LESS, Operations.LESS);
   BOOLEAN_OPERATIONS.put(TokenType.GREATER, Operations.GREATER);
   BOOLEAN_OPERATIONS.put(TokenType.GREATER_EQ, Operations.GREATER_EQ);
   BOOLEAN_OPERATIONS.put(TokenType.LESS_EQ, Operations.LESS_EQ);
   BOOLEAN_OPERATIONS.put(TokenType.NOT_EQ, Operations.NOT_EQ);
 }