mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fix exponent parsing, remove impossible (?) case
(cherry picked from commit 02da42f90b8a912047c00479df789563853cfeee)
This commit is contained in:
parent
57154224dc
commit
f1fb51f748
@ -60,10 +60,11 @@ DEFAULT : 'default' ;
|
||||
fragment DIGIT : [0-9] ;
|
||||
fragment SIGN : [+-] ;
|
||||
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.
|
||||
NUMBER : ( DIGIT+ DECIMAL? | DECIMAL ) ;
|
||||
NUMBER : ( DIGIT+ DECIMAL? | DECIMAL ) EXPONENT? ;
|
||||
|
||||
ID : [A-Za-z] [0-9A-Za-z_]* ;
|
||||
|
||||
|
@ -612,14 +612,9 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
|
||||
|
||||
@Override
|
||||
public MethodHandle visitConstantExpression(ExpressionParser.ConstantExpressionContext ctx) {
|
||||
try {
|
||||
return ExpressionHandles.dropData(
|
||||
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());
|
||||
}
|
||||
return ExpressionHandles.dropData(
|
||||
MethodHandles.constant(Double.class, Double.parseDouble(ctx.getText()))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user