From 777b132a041cbba7c7fe971c0e3150f523a9844a Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sun, 27 Oct 2019 12:58:32 -0700 Subject: [PATCH] Catch small edge-case in parser --- .../src/main/antlr/com/sk89q/worldedit/antlr/Expression.g4 | 2 +- .../sk89q/worldedit/internal/expression/ExpressionTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/antlr/com/sk89q/worldedit/antlr/Expression.g4 b/worldedit-core/src/main/antlr/com/sk89q/worldedit/antlr/Expression.g4 index 107aa5176..507aa3ad0 100644 --- a/worldedit-core/src/main/antlr/com/sk89q/worldedit/antlr/Expression.g4 +++ b/worldedit-core/src/main/antlr/com/sk89q/worldedit/antlr/Expression.g4 @@ -63,7 +63,7 @@ fragment EXP_CHAR : [eE] ; fragment DECIMAL : '.' DIGIT+ ( EXP_CHAR SIGN? DIGIT+ )? ; // All numbers are treated the same. No int/dec divide. -NUMBER : SIGN? ( DIGIT+ DECIMAL? | DECIMAL ) ; +NUMBER : ( DIGIT+ DECIMAL? | DECIMAL ) ; ID : [A-Za-z] [0-9A-Za-z_]* ; diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java index c33112f05..a8a30ba40 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java @@ -74,6 +74,11 @@ public class ExpressionTest { assertEquals(8, compile("foo+bar", "foo", "bar").evaluate(5D, 3D), 0); } + @Test + void testTightTokenization() { + assertEquals(4, simpleEval("3+1"), 0); + } + @Test public void testErrors() { // test lexer errors