Commit e0838fbc authored by codefairy08's avatar codefairy08
Browse files

#2211 bug fixs

parent 7e1e7f54
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -69,6 +69,14 @@ public final class NumberUtil {
     * @return exactly number value and type
     */
    public static Number getExactlyNumber(final String value, final int radix) {
        try {
            return getBigInteger(value, radix);
        } catch (final NumberFormatException ex) {
            return new BigDecimal(value);
        }
    }
    
    private static Number getBigInteger(final String value, final int radix) {
        BigInteger result = new BigInteger(value, radix);
        if (result.compareTo(new BigInteger(String.valueOf(Integer.MIN_VALUE))) >= 0 && result.compareTo(new BigInteger(String.valueOf(Integer.MAX_VALUE))) <= 0) {
            return result.intValue();
+0 −4
Original line number Diff line number Diff line
@@ -100,10 +100,6 @@ public final class ExpressionExtractor {
        if (numberNode.isPresent()) {
            result.setLiterals(NumberUtil.getExactlyNumber(numberNode.get().getText(), 10));
        }
        Optional<ParserRuleContext> doubleNode = ExtractorUtils.findFirstChildNode(expressionNode, RuleName.DOUBLE_VALUE);
        if (doubleNode.isPresent()) {
            result.setLiterals(Double.parseDouble(doubleNode.get().getText()));
        }
        Optional<ParserRuleContext> stringNode = ExtractorUtils.findFirstChildNode(expressionNode, RuleName.STRING);
        if (stringNode.isPresent()) {
            String text = stringNode.get().getText();
+0 −2
Original line number Diff line number Diff line
@@ -117,8 +117,6 @@ public enum RuleName {
    
    NUMBER("Number"),
    
    DOUBLE_VALUE("DoubleValue"),
    
    STRING("String"),
    
    EXPR("Expr"),
+0 −5
Original line number Diff line number Diff line
@@ -191,7 +191,6 @@ variable
literal
    : question
    | number
    | doubleValue
    | TRUE
    | FALSE
    | NULL
@@ -211,10 +210,6 @@ number
   : NUMBER_
   ;

doubleValue
   : DOUBLE_VALUE_
   ;

string
    : STRING_
    ;
+1 −5
Original line number Diff line number Diff line
@@ -30,11 +30,7 @@ STRING_
    ;

NUMBER_
    : MINUS_? INT_
    ;

DOUBLE_VALUE_
    : MINUS_? INT_? DOT_ INT_ (E [+\-]? INT_)?
    : MINUS_? INT_? DOT_? INT_ (E [+\-]? INT_)?
    ;

HEX_DIGIT_