geforkt von Mirrors/FastAsyncWorldEdit
Fix exponent parsing, remove impossible (?) case
(cherry picked from commit 02da42f90b8a912047c00479df789563853cfeee)
Dieser Commit ist enthalten in:
Ursprung
57154224dc
Commit
f1fb51f748
@ -60,10 +60,11 @@ DEFAULT : 'default' ;
|
|||||||
fragment DIGIT : [0-9] ;
|
fragment DIGIT : [0-9] ;
|
||||||
fragment SIGN : [+-] ;
|
fragment SIGN : [+-] ;
|
||||||
fragment EXP_CHAR : [eE] ;
|
fragment EXP_CHAR : [eE] ;
|
||||||
fragment DECIMAL : '.' DIGIT+ ( EXP_CHAR SIGN? DIGIT+ )? ;
|
fragment EXPONENT : EXP_CHAR SIGN? DIGIT+ ;
|
||||||
|
fragment DECIMAL : '.' DIGIT+ ;
|
||||||
|
|
||||||
// All numbers are treated the same. No int/dec divide.
|
// All numbers are treated the same. No int/dec divide.
|
||||||
NUMBER : ( DIGIT+ DECIMAL? | DECIMAL ) ;
|
NUMBER : ( DIGIT+ DECIMAL? | DECIMAL ) EXPONENT? ;
|
||||||
|
|
||||||
ID : [A-Za-z] [0-9A-Za-z_]* ;
|
ID : [A-Za-z] [0-9A-Za-z_]* ;
|
||||||
|
|
||||||
|
@ -612,14 +612,9 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MethodHandle visitConstantExpression(ExpressionParser.ConstantExpressionContext ctx) {
|
public MethodHandle visitConstantExpression(ExpressionParser.ConstantExpressionContext ctx) {
|
||||||
try {
|
|
||||||
return ExpressionHandles.dropData(
|
return ExpressionHandles.dropData(
|
||||||
MethodHandles.constant(Double.class, Double.parseDouble(ctx.getText()))
|
MethodHandles.constant(Double.class, Double.parseDouble(ctx.getText()))
|
||||||
);
|
);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// Rare, but might happen, e.g. if too many digits
|
|
||||||
throw ExpressionHelper.evalException(ctx, "Invalid constant: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren