/** * Parses an integer literal. * * @return An integer literal. * * @throws SourceCodeException If the next token in the sequence is not an integer literal. */ public NumericType intLiteral() throws SourceCodeException { Token valToken = consumeToken(INTEGER_LITERAL); NumericType result = new IntLiteral(Integer.parseInt(valToken.image)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCodePositionImpl(valToken.beginLine, valToken.beginColumn, valToken.endLine, valToken.endColumn); result.setSourceCodePosition(position); return result; }
/** * Parses an integer literal. * * @return An integer literal. * * @throws SourceCodeException If the next token in the sequence is not an integer literal. */ public Term intLiteral() throws SourceCodeException { Token valToken = consumeToken(INTEGER_LITERAL); NumericType result = new IntLiteral(Integer.parseInt(valToken.image)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCodePositionImpl(valToken.beginLine, valToken.beginColumn, valToken.endLine, valToken.endColumn); result.setSourceCodePosition(position); return result; }
/** * Parses a real number literal. * * @return A real number literal. * * @throws SourceCodeException If the next token in the sequence is not a real number literal. */ public NumericType doubleLiteral() throws SourceCodeException { Token valToken = consumeToken(FLOATING_POINT_LITERAL); NumericType result = new DoubleLiteral(Double.parseDouble(valToken.image)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCodePositionImpl(valToken.beginLine, valToken.beginColumn, valToken.endLine, valToken.endColumn); result.setSourceCodePosition(position); return result; }
/** * Parses a real number literal. * * @return A real number literal. * * @throws SourceCodeException If the next token in the sequence is not a real number literal. */ public Term doubleLiteral() throws SourceCodeException { Token valToken = consumeToken(FLOATING_POINT_LITERAL); NumericType result = new DoubleLiteral(Double.parseDouble(valToken.image)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCodePositionImpl(valToken.beginLine, valToken.beginColumn, valToken.endLine, valToken.endColumn); result.setSourceCodePosition(position); return result; }