From f67d5faeb7419799a884d4e5c0c944f4fef96660 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 26 Mar 2023 21:09:15 +0200 Subject: [PATCH] allow .123 as float literal syntax. Fixes #103 --- parser/antlr/Prog8ANTLR.g4 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parser/antlr/Prog8ANTLR.g4 b/parser/antlr/Prog8ANTLR.g4 index 03588246c..0e9b29eb1 100644 --- a/parser/antlr/Prog8ANTLR.g4 +++ b/parser/antlr/Prog8ANTLR.g4 @@ -30,8 +30,10 @@ BIN_INTEGER : '%' ('0' | '1')+ ; ADDRESS_OF: '&' ; INVALID_AND_COMPOSITE: '&&' ; -FLOAT_NUMBER : FNUMBER (('E'|'e') ('+' | '-')? FNUMBER)? ; // sign comes later from unary expression -fragment FNUMBER : ('0' .. '9') + ('.' ('0' .. '9') +)? ; +FLOAT_NUMBER : FNUMBER (('E'|'e') ('+' | '-')? DEC_INTEGER)? ; // sign comes later from unary expression +fragment FNUMBER : FDOTNUMBER | FNUMDOTNUMBER ; +fragment FDOTNUMBER : '.' ('0'..'9')+ ; +fragment FNUMDOTNUMBER : ('0'..'9')+ ('.' ('0'..'9')+ )? ; fragment STRING_ESCAPE_SEQ : '\\' . | '\\x' . . | '\\u' . . . .; STRING :