Example #1
0
  // literal := INTEGER | FLOAT | TRUE | FALSE .
  public ast.Expression literal() throws IOException {
    ast.Expression expr = null;

    if (currentToken.kind.name().equals("INTEGER")) {
      expr = Command.newLiteral(expectRetrieve(Token.Kind.INTEGER));
    } else if (currentToken.kind.name().equals("FLOAT")) {
      expr = Command.newLiteral(expectRetrieve(Token.Kind.FLOAT));
    } else if (currentToken.kind.name().equals("TRUE")) {
      expr = Command.newLiteral(expectRetrieve(Token.Kind.TRUE));
    } else if (currentToken.kind.name().equals("FALSE")) {
      expr = Command.newLiteral(expectRetrieve(Token.Kind.FALSE));
    }

    return expr;
  }
Example #2
0
 // type := IDENTIFIER .
 private ast.Expression type() throws IOException {
   // TODO Auto-generated method stub
   // expects IDENTIFIER
   return Command.newLiteral(expectRetrieve(Token.Kind.IDENTIFIER));
 }