From 76273485f9fbf63a3b139315b7ca8bea21bdedda Mon Sep 17 00:00:00 2001 From: Massimo Comuzzo <43844835+max-co@users.noreply.github.com> Date: Sun, 8 Dec 2024 17:24:04 +0100 Subject: [PATCH 1/4] Add Makefile for ANTLR --- antlr/Makefile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 antlr/Makefile diff --git a/antlr/Makefile b/antlr/Makefile new file mode 100644 index 00000000..9330490b --- /dev/null +++ b/antlr/Makefile @@ -0,0 +1,30 @@ +# GNU Make >= 4.3 + +## Configuration + +OUTPUT_DIR = parser/grulev3 + +ANTLR = antlr4 +ANTLRFLAGS = -Dlanguage=Go -o '${OUTPUT_DIR}' -package '$(notdir ${OUTPUT_DIR})' + +GRAMMAR = grulev3.g4 + +## Rules + +PREFIX = ${OUTPUT_DIR}/$(basename ${GRAMMAR}) +tokens = $(addsuffix .interp,$(1)) $(addsuffix .tokens,$(1)) + +TOKENS = $(call tokens,${PREFIX}Lexer) $(call tokens,${PREFIX}) +LEXER = ${PREFIX}_lexer.go +PARSER = ${PREFIX}_parser.go ${PREFIX}_listener.go ${PREFIX}_base_listener.go ${PREFIX}_visitor.go ${PREFIX}_base_visitor.go + +.PHONY: clean all +.DELETE_ON_ERROR: + +all: ${TOKENS} ${LEXER} ${PARSER} + +${TOKENS} ${LEXER} ${PARSER} &: ${GRAMMAR} + $(ANTLR) ${ANTLRFLAGS} -visitor $^ + +clean: + rm -f ${TOKENS} ${LEXER} ${PARSER} From 98d02a3011eb8126f776386fd5166e5eb86b2e2e Mon Sep 17 00:00:00 2001 From: Massimo Comuzzo <43844835+max-co@users.noreply.github.com> Date: Sun, 8 Dec 2024 17:55:29 +0100 Subject: [PATCH 2/4] Remove unused go-billy.v4 dependency (go mod tidy) go-billy.v4 was substituted with go-billy/v5 in e4e90fe744ffffc1010edb7d12c5693a0b9ce477. --- go.mod | 1 - go.sum | 6 ------ 2 files changed, 7 deletions(-) diff --git a/go.mod b/go.mod index 5066bbf5..7d99861a 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.25.0 - gopkg.in/src-d/go-billy.v4 v4.3.2 ) require ( diff --git a/go.sum b/go.sum index ee774ff6..698b2299 100644 --- a/go.sum +++ b/go.sum @@ -17,7 +17,6 @@ github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9 github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -55,7 +54,6 @@ github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= @@ -121,7 +119,6 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -159,13 +156,10 @@ golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg= -gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 0da374d528c0b11621c4f4aaf1ecb8b1bf699a7c Mon Sep 17 00:00:00 2001 From: Massimo Comuzzo <43844835+max-co@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:05:19 +0100 Subject: [PATCH 3/4] Update ANTLR4 to v4.13.0 --- antlr/GruleParserV3Listener.go | 2 +- antlr/GruleParserV3_test.go | 2 +- antlr/parser/grulev3/grulev3.interp | 0 antlr/parser/grulev3/grulev3.tokens | 160 +- antlr/parser/grulev3/grulev3Lexer.interp | 0 antlr/parser/grulev3/grulev3Lexer.tokens | 160 +- antlr/parser/grulev3/grulev3_base_listener.go | 4 +- antlr/parser/grulev3/grulev3_base_visitor.go | 4 +- antlr/parser/grulev3/grulev3_lexer.go | 49 +- antlr/parser/grulev3/grulev3_listener.go | 4 +- antlr/parser/grulev3/grulev3_parser.go | 1911 ++++++++++------- antlr/parser/grulev3/grulev3_visitor.go | 4 +- builder/RuleBuilder.go | 2 +- examples/ItemArrayExample_test.go | 2 +- go.mod | 3 +- go.sum | 6 +- pkg/errorReporter.go | 2 +- 17 files changed, 1312 insertions(+), 1003 deletions(-) mode change 100755 => 100644 antlr/parser/grulev3/grulev3.interp mode change 100755 => 100644 antlr/parser/grulev3/grulev3.tokens mode change 100755 => 100644 antlr/parser/grulev3/grulev3Lexer.interp mode change 100755 => 100644 antlr/parser/grulev3/grulev3Lexer.tokens mode change 100755 => 100644 antlr/parser/grulev3/grulev3_base_listener.go mode change 100755 => 100644 antlr/parser/grulev3/grulev3_base_visitor.go mode change 100755 => 100644 antlr/parser/grulev3/grulev3_lexer.go mode change 100755 => 100644 antlr/parser/grulev3/grulev3_listener.go mode change 100755 => 100644 antlr/parser/grulev3/grulev3_parser.go mode change 100755 => 100644 antlr/parser/grulev3/grulev3_visitor.go diff --git a/antlr/GruleParserV3Listener.go b/antlr/GruleParserV3Listener.go index 332e35ff..b5432ffa 100755 --- a/antlr/GruleParserV3Listener.go +++ b/antlr/GruleParserV3Listener.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" "github.com/hyperjumptech/grule-rule-engine/antlr/parser/grulev3" "github.com/hyperjumptech/grule-rule-engine/ast" "github.com/hyperjumptech/grule-rule-engine/logger" diff --git a/antlr/GruleParserV3_test.go b/antlr/GruleParserV3_test.go index 154966b9..e5e58e7e 100755 --- a/antlr/GruleParserV3_test.go +++ b/antlr/GruleParserV3_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" parser "github.com/hyperjumptech/grule-rule-engine/antlr/parser/grulev3" "github.com/hyperjumptech/grule-rule-engine/ast" "github.com/hyperjumptech/grule-rule-engine/pkg" diff --git a/antlr/parser/grulev3/grulev3.interp b/antlr/parser/grulev3/grulev3.interp old mode 100755 new mode 100644 diff --git a/antlr/parser/grulev3/grulev3.tokens b/antlr/parser/grulev3/grulev3.tokens old mode 100755 new mode 100644 index 11d19536..57800a11 --- a/antlr/parser/grulev3/grulev3.tokens +++ b/antlr/parser/grulev3/grulev3.tokens @@ -1,80 +1,80 @@ -T__0=1 -PLUS=2 -MINUS=3 -DIV=4 -MUL=5 -MOD=6 -DOT=7 -SEMICOLON=8 -LR_BRACE=9 -RR_BRACE=10 -LR_BRACKET=11 -RR_BRACKET=12 -LS_BRACKET=13 -RS_BRACKET=14 -RULE=15 -WHEN=16 -THEN=17 -AND=18 -OR=19 -TRUE=20 -FALSE=21 -NIL_LITERAL=22 -NEGATION=23 -SALIENCE=24 -EQUALS=25 -ASSIGN=26 -PLUS_ASIGN=27 -MINUS_ASIGN=28 -DIV_ASIGN=29 -MUL_ASIGN=30 -GT=31 -LT=32 -GTE=33 -LTE=34 -NOTEQUALS=35 -BITAND=36 -BITOR=37 -SIMPLENAME=38 -DQUOTA_STRING=39 -SQUOTA_STRING=40 -DECIMAL_FLOAT_LIT=41 -DECIMAL_EXPONENT=42 -HEX_FLOAT_LIT=43 -HEX_EXPONENT=44 -DEC_LIT=45 -HEX_LIT=46 -OCT_LIT=47 -SPACE=48 -COMMENT=49 -LINE_COMMENT=50 -','=1 -'+'=2 -'-'=3 -'/'=4 -'*'=5 -'%'=6 -'.'=7 -';'=8 -'{'=9 -'}'=10 -'('=11 -')'=12 -'['=13 -']'=14 -'&&'=18 -'||'=19 -'!'=23 -'=='=25 -'='=26 -'+='=27 -'-='=28 -'/='=29 -'*='=30 -'>'=31 -'<'=32 -'>='=33 -'<='=34 -'!='=35 -'&'=36 -'|'=37 +T__0=1 +PLUS=2 +MINUS=3 +DIV=4 +MUL=5 +MOD=6 +DOT=7 +SEMICOLON=8 +LR_BRACE=9 +RR_BRACE=10 +LR_BRACKET=11 +RR_BRACKET=12 +LS_BRACKET=13 +RS_BRACKET=14 +RULE=15 +WHEN=16 +THEN=17 +AND=18 +OR=19 +TRUE=20 +FALSE=21 +NIL_LITERAL=22 +NEGATION=23 +SALIENCE=24 +EQUALS=25 +ASSIGN=26 +PLUS_ASIGN=27 +MINUS_ASIGN=28 +DIV_ASIGN=29 +MUL_ASIGN=30 +GT=31 +LT=32 +GTE=33 +LTE=34 +NOTEQUALS=35 +BITAND=36 +BITOR=37 +SIMPLENAME=38 +DQUOTA_STRING=39 +SQUOTA_STRING=40 +DECIMAL_FLOAT_LIT=41 +DECIMAL_EXPONENT=42 +HEX_FLOAT_LIT=43 +HEX_EXPONENT=44 +DEC_LIT=45 +HEX_LIT=46 +OCT_LIT=47 +SPACE=48 +COMMENT=49 +LINE_COMMENT=50 +','=1 +'+'=2 +'-'=3 +'/'=4 +'*'=5 +'%'=6 +'.'=7 +';'=8 +'{'=9 +'}'=10 +'('=11 +')'=12 +'['=13 +']'=14 +'&&'=18 +'||'=19 +'!'=23 +'=='=25 +'='=26 +'+='=27 +'-='=28 +'/='=29 +'*='=30 +'>'=31 +'<'=32 +'>='=33 +'<='=34 +'!='=35 +'&'=36 +'|'=37 diff --git a/antlr/parser/grulev3/grulev3Lexer.interp b/antlr/parser/grulev3/grulev3Lexer.interp old mode 100755 new mode 100644 diff --git a/antlr/parser/grulev3/grulev3Lexer.tokens b/antlr/parser/grulev3/grulev3Lexer.tokens old mode 100755 new mode 100644 index 11d19536..57800a11 --- a/antlr/parser/grulev3/grulev3Lexer.tokens +++ b/antlr/parser/grulev3/grulev3Lexer.tokens @@ -1,80 +1,80 @@ -T__0=1 -PLUS=2 -MINUS=3 -DIV=4 -MUL=5 -MOD=6 -DOT=7 -SEMICOLON=8 -LR_BRACE=9 -RR_BRACE=10 -LR_BRACKET=11 -RR_BRACKET=12 -LS_BRACKET=13 -RS_BRACKET=14 -RULE=15 -WHEN=16 -THEN=17 -AND=18 -OR=19 -TRUE=20 -FALSE=21 -NIL_LITERAL=22 -NEGATION=23 -SALIENCE=24 -EQUALS=25 -ASSIGN=26 -PLUS_ASIGN=27 -MINUS_ASIGN=28 -DIV_ASIGN=29 -MUL_ASIGN=30 -GT=31 -LT=32 -GTE=33 -LTE=34 -NOTEQUALS=35 -BITAND=36 -BITOR=37 -SIMPLENAME=38 -DQUOTA_STRING=39 -SQUOTA_STRING=40 -DECIMAL_FLOAT_LIT=41 -DECIMAL_EXPONENT=42 -HEX_FLOAT_LIT=43 -HEX_EXPONENT=44 -DEC_LIT=45 -HEX_LIT=46 -OCT_LIT=47 -SPACE=48 -COMMENT=49 -LINE_COMMENT=50 -','=1 -'+'=2 -'-'=3 -'/'=4 -'*'=5 -'%'=6 -'.'=7 -';'=8 -'{'=9 -'}'=10 -'('=11 -')'=12 -'['=13 -']'=14 -'&&'=18 -'||'=19 -'!'=23 -'=='=25 -'='=26 -'+='=27 -'-='=28 -'/='=29 -'*='=30 -'>'=31 -'<'=32 -'>='=33 -'<='=34 -'!='=35 -'&'=36 -'|'=37 +T__0=1 +PLUS=2 +MINUS=3 +DIV=4 +MUL=5 +MOD=6 +DOT=7 +SEMICOLON=8 +LR_BRACE=9 +RR_BRACE=10 +LR_BRACKET=11 +RR_BRACKET=12 +LS_BRACKET=13 +RS_BRACKET=14 +RULE=15 +WHEN=16 +THEN=17 +AND=18 +OR=19 +TRUE=20 +FALSE=21 +NIL_LITERAL=22 +NEGATION=23 +SALIENCE=24 +EQUALS=25 +ASSIGN=26 +PLUS_ASIGN=27 +MINUS_ASIGN=28 +DIV_ASIGN=29 +MUL_ASIGN=30 +GT=31 +LT=32 +GTE=33 +LTE=34 +NOTEQUALS=35 +BITAND=36 +BITOR=37 +SIMPLENAME=38 +DQUOTA_STRING=39 +SQUOTA_STRING=40 +DECIMAL_FLOAT_LIT=41 +DECIMAL_EXPONENT=42 +HEX_FLOAT_LIT=43 +HEX_EXPONENT=44 +DEC_LIT=45 +HEX_LIT=46 +OCT_LIT=47 +SPACE=48 +COMMENT=49 +LINE_COMMENT=50 +','=1 +'+'=2 +'-'=3 +'/'=4 +'*'=5 +'%'=6 +'.'=7 +';'=8 +'{'=9 +'}'=10 +'('=11 +')'=12 +'['=13 +']'=14 +'&&'=18 +'||'=19 +'!'=23 +'=='=25 +'='=26 +'+='=27 +'-='=28 +'/='=29 +'*='=30 +'>'=31 +'<'=32 +'>='=33 +'<='=34 +'!='=35 +'&'=36 +'|'=37 diff --git a/antlr/parser/grulev3/grulev3_base_listener.go b/antlr/parser/grulev3/grulev3_base_listener.go old mode 100755 new mode 100644 index 9f374f15..2d5e877b --- a/antlr/parser/grulev3/grulev3_base_listener.go +++ b/antlr/parser/grulev3/grulev3_base_listener.go @@ -1,7 +1,7 @@ -// Code generated from C:/Users/Ferdinand/WSL/workspace/golang/src/github.com/newm4n/grule-rule-engine/antlr\grulev3.g4 by ANTLR 4.10.1. DO NOT EDIT. +// Code generated from grulev3.g4 by ANTLR 4.13.2. DO NOT EDIT. package grulev3 // grulev3 -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" // Basegrulev3Listener is a complete listener for a parse tree produced by grulev3Parser. type Basegrulev3Listener struct{} diff --git a/antlr/parser/grulev3/grulev3_base_visitor.go b/antlr/parser/grulev3/grulev3_base_visitor.go old mode 100755 new mode 100644 index e7e3a858..857fcb90 --- a/antlr/parser/grulev3/grulev3_base_visitor.go +++ b/antlr/parser/grulev3/grulev3_base_visitor.go @@ -1,7 +1,7 @@ -// Code generated from C:/Users/Ferdinand/WSL/workspace/golang/src/github.com/newm4n/grule-rule-engine/antlr\grulev3.g4 by ANTLR 4.10.1. DO NOT EDIT. +// Code generated from grulev3.g4 by ANTLR 4.13.2. DO NOT EDIT. package grulev3 // grulev3 -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" type Basegrulev3Visitor struct { *antlr.BaseParseTreeVisitor diff --git a/antlr/parser/grulev3/grulev3_lexer.go b/antlr/parser/grulev3/grulev3_lexer.go old mode 100755 new mode 100644 index 70c74adb..e1b0b319 --- a/antlr/parser/grulev3/grulev3_lexer.go +++ b/antlr/parser/grulev3/grulev3_lexer.go @@ -1,13 +1,12 @@ -// Code generated from C:/Users/Ferdinand/WSL/workspace/golang/src/github.com/newm4n/grule-rule-engine/antlr\grulev3.g4 by ANTLR 4.10.1. DO NOT EDIT. +// Code generated from grulev3.g4 by ANTLR 4.13.2. DO NOT EDIT. package grulev3 import ( "fmt" + "github.com/antlr4-go/antlr/v4" "sync" "unicode" - - "github.com/antlr/antlr4/runtime/Go/antlr" ) // Suppress unused import error @@ -22,34 +21,34 @@ type grulev3Lexer struct { // TODO: EOF string } -var grulev3lexerLexerStaticData struct { +var Grulev3LexerLexerStaticData struct { once sync.Once serializedATN []int32 - channelNames []string - modeNames []string - literalNames []string - symbolicNames []string - ruleNames []string - predictionContextCache *antlr.PredictionContextCache + ChannelNames []string + ModeNames []string + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache atn *antlr.ATN decisionToDFA []*antlr.DFA } func grulev3lexerLexerInit() { - staticData := &grulev3lexerLexerStaticData - staticData.channelNames = []string{ + staticData := &Grulev3LexerLexerStaticData + staticData.ChannelNames = []string{ "DEFAULT_TOKEN_CHANNEL", "HIDDEN", } - staticData.modeNames = []string{ + staticData.ModeNames = []string{ "DEFAULT_MODE", } - staticData.literalNames = []string{ + staticData.LiteralNames = []string{ "", "','", "'+'", "'-'", "'/'", "'*'", "'%'", "'.'", "';'", "'{'", "'}'", "'('", "')'", "'['", "']'", "", "", "", "'&&'", "'||'", "", "", "", "'!'", "", "'=='", "'='", "'+='", "'-='", "'/='", "'*='", "'>'", "'<'", "'>='", "'<='", "'!='", "'&'", "'|'", } - staticData.symbolicNames = []string{ + staticData.SymbolicNames = []string{ "", "", "PLUS", "MINUS", "DIV", "MUL", "MOD", "DOT", "SEMICOLON", "LR_BRACE", "RR_BRACE", "LR_BRACKET", "RR_BRACKET", "LS_BRACKET", "RS_BRACKET", "RULE", "WHEN", "THEN", "AND", "OR", "TRUE", "FALSE", "NIL_LITERAL", @@ -59,7 +58,7 @@ func grulev3lexerLexerInit() { "DECIMAL_EXPONENT", "HEX_FLOAT_LIT", "HEX_EXPONENT", "DEC_LIT", "HEX_LIT", "OCT_LIT", "SPACE", "COMMENT", "LINE_COMMENT", } - staticData.ruleNames = []string{ + staticData.RuleNames = []string{ "T__0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "ISC", "IC", "PLUS", "MINUS", "DIV", "MUL", "MOD", "DOT", "SEMICOLON", @@ -72,7 +71,7 @@ func grulev3lexerLexerInit() { "DEC_LIT", "HEX_LIT", "OCT_LIT", "HEX_DIGITS", "DEC_DIGITS", "OCT_DIGITS", "DEC_DIGIT", "OCT_DIGIT", "HEX_DIGIT", "SPACE", "COMMENT", "LINE_COMMENT", } - staticData.predictionContextCache = antlr.NewPredictionContextCache() + staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ 4, 0, 50, 484, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, @@ -308,7 +307,7 @@ func grulev3lexerLexerInit() { // Newgrulev3Lexer(). You can call this function if you wish to initialize the static state ahead // of time. func Grulev3LexerInit() { - staticData := &grulev3lexerLexerStaticData + staticData := &Grulev3LexerLexerStaticData staticData.once.Do(grulev3lexerLexerInit) } @@ -317,13 +316,13 @@ func Newgrulev3Lexer(input antlr.CharStream) *grulev3Lexer { Grulev3LexerInit() l := new(grulev3Lexer) l.BaseLexer = antlr.NewBaseLexer(input) - staticData := &grulev3lexerLexerStaticData - l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache) - l.channelNames = staticData.channelNames - l.modeNames = staticData.modeNames - l.RuleNames = staticData.ruleNames - l.LiteralNames = staticData.literalNames - l.SymbolicNames = staticData.symbolicNames + staticData := &Grulev3LexerLexerStaticData + l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + l.channelNames = staticData.ChannelNames + l.modeNames = staticData.ModeNames + l.RuleNames = staticData.RuleNames + l.LiteralNames = staticData.LiteralNames + l.SymbolicNames = staticData.SymbolicNames l.GrammarFileName = "grulev3.g4" // TODO: l.EOF = antlr.TokenEOF diff --git a/antlr/parser/grulev3/grulev3_listener.go b/antlr/parser/grulev3/grulev3_listener.go old mode 100755 new mode 100644 index 261c02ed..b50b1f71 --- a/antlr/parser/grulev3/grulev3_listener.go +++ b/antlr/parser/grulev3/grulev3_listener.go @@ -1,7 +1,7 @@ -// Code generated from C:/Users/Ferdinand/WSL/workspace/golang/src/github.com/newm4n/grule-rule-engine/antlr\grulev3.g4 by ANTLR 4.10.1. DO NOT EDIT. +// Code generated from grulev3.g4 by ANTLR 4.13.2. DO NOT EDIT. package grulev3 // grulev3 -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" // grulev3Listener is a complete listener for a parse tree produced by grulev3Parser. type grulev3Listener interface { diff --git a/antlr/parser/grulev3/grulev3_parser.go b/antlr/parser/grulev3/grulev3_parser.go old mode 100755 new mode 100644 index de1e161d..aa21cf13 --- a/antlr/parser/grulev3/grulev3_parser.go +++ b/antlr/parser/grulev3/grulev3_parser.go @@ -1,4 +1,4 @@ -// Code generated from C:/Users/Ferdinand/WSL/workspace/golang/src/github.com/newm4n/grule-rule-engine/antlr\grulev3.g4 by ANTLR 4.10.1. DO NOT EDIT. +// Code generated from grulev3.g4 by ANTLR 4.13.2. DO NOT EDIT. package grulev3 // grulev3 import ( @@ -6,7 +6,7 @@ import ( "strconv" "sync" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" ) // Suppress unused import errors @@ -18,26 +18,26 @@ type grulev3Parser struct { *antlr.BaseParser } -var grulev3ParserStaticData struct { +var Grulev3ParserStaticData struct { once sync.Once serializedATN []int32 - literalNames []string - symbolicNames []string - ruleNames []string - predictionContextCache *antlr.PredictionContextCache + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache atn *antlr.ATN decisionToDFA []*antlr.DFA } func grulev3ParserInit() { - staticData := &grulev3ParserStaticData - staticData.literalNames = []string{ + staticData := &Grulev3ParserStaticData + staticData.LiteralNames = []string{ "", "','", "'+'", "'-'", "'/'", "'*'", "'%'", "'.'", "';'", "'{'", "'}'", "'('", "')'", "'['", "']'", "", "", "", "'&&'", "'||'", "", "", "", "'!'", "", "'=='", "'='", "'+='", "'-='", "'/='", "'*='", "'>'", "'<'", "'>='", "'<='", "'!='", "'&'", "'|'", } - staticData.symbolicNames = []string{ + staticData.SymbolicNames = []string{ "", "", "PLUS", "MINUS", "DIV", "MUL", "MOD", "DOT", "SEMICOLON", "LR_BRACE", "RR_BRACE", "LR_BRACKET", "RR_BRACKET", "LS_BRACKET", "RS_BRACKET", "RULE", "WHEN", "THEN", "AND", "OR", "TRUE", "FALSE", "NIL_LITERAL", @@ -47,7 +47,7 @@ func grulev3ParserInit() { "DECIMAL_EXPONENT", "HEX_FLOAT_LIT", "HEX_EXPONENT", "DEC_LIT", "HEX_LIT", "OCT_LIT", "SPACE", "COMMENT", "LINE_COMMENT", } - staticData.ruleNames = []string{ + staticData.RuleNames = []string{ "grl", "ruleEntry", "salience", "ruleName", "ruleDescription", "whenScope", "thenScope", "thenExpressionList", "thenExpression", "assignment", "expression", "mulDivOperators", "addMinusOperators", "comparisonOperator", "andLogicOperator", @@ -57,7 +57,7 @@ func grulev3ParserInit() { "decimalLiteral", "hexadecimalLiteral", "octalLiteral", "stringLiteral", "booleanLiteral", } - staticData.predictionContextCache = antlr.NewPredictionContextCache() + staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ 4, 1, 50, 263, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, @@ -187,7 +187,7 @@ func grulev3ParserInit() { // Newgrulev3Parser(). You can call this function if you wish to initialize the static state ahead // of time. func Grulev3ParserInit() { - staticData := &grulev3ParserStaticData + staticData := &Grulev3ParserStaticData staticData.once.Do(grulev3ParserInit) } @@ -196,11 +196,11 @@ func Newgrulev3Parser(input antlr.TokenStream) *grulev3Parser { Grulev3ParserInit() this := new(grulev3Parser) this.BaseParser = antlr.NewBaseParser(input) - staticData := &grulev3ParserStaticData - this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache) - this.RuleNames = staticData.ruleNames - this.LiteralNames = staticData.literalNames - this.SymbolicNames = staticData.symbolicNames + staticData := &Grulev3ParserStaticData + this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + this.RuleNames = staticData.RuleNames + this.LiteralNames = staticData.LiteralNames + this.SymbolicNames = staticData.SymbolicNames this.GrammarFileName = "grulev3.g4" return this @@ -305,28 +305,38 @@ type IGrlContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + EOF() antlr.TerminalNode + AllRuleEntry() []IRuleEntryContext + RuleEntry(i int) IRuleEntryContext + // IsGrlContext differentiates from other interfaces. IsGrlContext() } type GrlContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyGrlContext() *GrlContext { var p = new(GrlContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_grl return p } +func InitEmptyGrlContext(p *GrlContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_grl +} + func (*GrlContext) IsGrlContext() {} func NewGrlContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *GrlContext { var p = new(GrlContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_grl @@ -412,32 +422,16 @@ func (s *GrlContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *grulev3Parser) Grl() (localctx IGrlContext) { - this := p - _ = this - localctx = NewGrlContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 0, grulev3ParserRULE_grl) var _la int - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) p.SetState(69) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) for _la == grulev3ParserRULE { @@ -448,14 +442,31 @@ func (p *grulev3Parser) Grl() (localctx IGrlContext) { p.SetState(71) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) } { p.SetState(72) p.Match(grulev3ParserEOF) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IRuleEntryContext is an interface to support dynamic dispatch. @@ -465,28 +476,43 @@ type IRuleEntryContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + RULE() antlr.TerminalNode + RuleName() IRuleNameContext + LR_BRACE() antlr.TerminalNode + WhenScope() IWhenScopeContext + ThenScope() IThenScopeContext + RR_BRACE() antlr.TerminalNode + RuleDescription() IRuleDescriptionContext + Salience() ISalienceContext + // IsRuleEntryContext differentiates from other interfaces. IsRuleEntryContext() } type RuleEntryContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyRuleEntryContext() *RuleEntryContext { var p = new(RuleEntryContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_ruleEntry return p } +func InitEmptyRuleEntryContext(p *RuleEntryContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_ruleEntry +} + func (*RuleEntryContext) IsRuleEntryContext() {} func NewRuleEntryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RuleEntryContext { var p = new(RuleEntryContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_ruleEntry @@ -619,33 +645,18 @@ func (s *RuleEntryContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *grulev3Parser) RuleEntry() (localctx IRuleEntryContext) { - this := p - _ = this - localctx = NewRuleEntryContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 2, grulev3ParserRULE_ruleEntry) var _la int - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) { p.SetState(74) p.Match(grulev3ParserRULE) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(75) @@ -653,6 +664,9 @@ func (p *grulev3Parser) RuleEntry() (localctx IRuleEntryContext) { } p.SetState(77) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == grulev3ParserDQUOTA_STRING || _la == grulev3ParserSQUOTA_STRING { @@ -664,6 +678,9 @@ func (p *grulev3Parser) RuleEntry() (localctx IRuleEntryContext) { } p.SetState(80) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == grulev3ParserSALIENCE { @@ -676,6 +693,10 @@ func (p *grulev3Parser) RuleEntry() (localctx IRuleEntryContext) { { p.SetState(82) p.Match(grulev3ParserLR_BRACE) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(83) @@ -688,9 +709,23 @@ func (p *grulev3Parser) RuleEntry() (localctx IRuleEntryContext) { { p.SetState(85) p.Match(grulev3ParserRR_BRACE) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // ISalienceContext is an interface to support dynamic dispatch. @@ -700,28 +735,37 @@ type ISalienceContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + SALIENCE() antlr.TerminalNode + IntegerLiteral() IIntegerLiteralContext + // IsSalienceContext differentiates from other interfaces. IsSalienceContext() } type SalienceContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptySalienceContext() *SalienceContext { var p = new(SalienceContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_salience return p } +func InitEmptySalienceContext(p *SalienceContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_salience +} + func (*SalienceContext) IsSalienceContext() {} func NewSalienceContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SalienceContext { var p = new(SalienceContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_salience @@ -782,39 +826,33 @@ func (s *SalienceContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *grulev3Parser) Salience() (localctx ISalienceContext) { - this := p - _ = this - localctx = NewSalienceContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 4, grulev3ParserRULE_salience) - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) { p.SetState(87) p.Match(grulev3ParserSALIENCE) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(88) p.IntegerLiteral() } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IRuleNameContext is an interface to support dynamic dispatch. @@ -824,28 +862,36 @@ type IRuleNameContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + SIMPLENAME() antlr.TerminalNode + // IsRuleNameContext differentiates from other interfaces. IsRuleNameContext() } type RuleNameContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyRuleNameContext() *RuleNameContext { var p = new(RuleNameContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_ruleName return p } +func InitEmptyRuleNameContext(p *RuleNameContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_ruleName +} + func (*RuleNameContext) IsRuleNameContext() {} func NewRuleNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RuleNameContext { var p = new(RuleNameContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_ruleName @@ -890,35 +936,29 @@ func (s *RuleNameContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *grulev3Parser) RuleName() (localctx IRuleNameContext) { - this := p - _ = this - localctx = NewRuleNameContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 6, grulev3ParserRULE_ruleName) - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) { p.SetState(90) p.Match(grulev3ParserSIMPLENAME) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IRuleDescriptionContext is an interface to support dynamic dispatch. @@ -928,28 +968,37 @@ type IRuleDescriptionContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + DQUOTA_STRING() antlr.TerminalNode + SQUOTA_STRING() antlr.TerminalNode + // IsRuleDescriptionContext differentiates from other interfaces. IsRuleDescriptionContext() } type RuleDescriptionContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyRuleDescriptionContext() *RuleDescriptionContext { var p = new(RuleDescriptionContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_ruleDescription return p } +func InitEmptyRuleDescriptionContext(p *RuleDescriptionContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_ruleDescription +} + func (*RuleDescriptionContext) IsRuleDescriptionContext() {} func NewRuleDescriptionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RuleDescriptionContext { var p = new(RuleDescriptionContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_ruleDescription @@ -998,29 +1047,10 @@ func (s *RuleDescriptionContext) Accept(visitor antlr.ParseTreeVisitor) interfac } func (p *grulev3Parser) RuleDescription() (localctx IRuleDescriptionContext) { - this := p - _ = this - localctx = NewRuleDescriptionContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 8, grulev3ParserRULE_ruleDescription) var _la int - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) { p.SetState(92) @@ -1034,7 +1064,17 @@ func (p *grulev3Parser) RuleDescription() (localctx IRuleDescriptionContext) { } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IWhenScopeContext is an interface to support dynamic dispatch. @@ -1044,28 +1084,37 @@ type IWhenScopeContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + WHEN() antlr.TerminalNode + Expression() IExpressionContext + // IsWhenScopeContext differentiates from other interfaces. IsWhenScopeContext() } type WhenScopeContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyWhenScopeContext() *WhenScopeContext { var p = new(WhenScopeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_whenScope return p } +func InitEmptyWhenScopeContext(p *WhenScopeContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_whenScope +} + func (*WhenScopeContext) IsWhenScopeContext() {} func NewWhenScopeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *WhenScopeContext { var p = new(WhenScopeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_whenScope @@ -1126,39 +1175,33 @@ func (s *WhenScopeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *grulev3Parser) WhenScope() (localctx IWhenScopeContext) { - this := p - _ = this - localctx = NewWhenScopeContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 10, grulev3ParserRULE_whenScope) - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) { p.SetState(94) p.Match(grulev3ParserWHEN) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(95) p.expression(0) } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IThenScopeContext is an interface to support dynamic dispatch. @@ -1168,28 +1211,37 @@ type IThenScopeContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + THEN() antlr.TerminalNode + ThenExpressionList() IThenExpressionListContext + // IsThenScopeContext differentiates from other interfaces. IsThenScopeContext() } type ThenScopeContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyThenScopeContext() *ThenScopeContext { var p = new(ThenScopeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_thenScope return p } +func InitEmptyThenScopeContext(p *ThenScopeContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_thenScope +} + func (*ThenScopeContext) IsThenScopeContext() {} func NewThenScopeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ThenScopeContext { var p = new(ThenScopeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_thenScope @@ -1250,39 +1302,33 @@ func (s *ThenScopeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *grulev3Parser) ThenScope() (localctx IThenScopeContext) { - this := p - _ = this - localctx = NewThenScopeContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 12, grulev3ParserRULE_thenScope) - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) { p.SetState(97) p.Match(grulev3ParserTHEN) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(98) p.ThenExpressionList() } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IThenExpressionListContext is an interface to support dynamic dispatch. @@ -1292,28 +1338,39 @@ type IThenExpressionListContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + AllThenExpression() []IThenExpressionContext + ThenExpression(i int) IThenExpressionContext + AllSEMICOLON() []antlr.TerminalNode + SEMICOLON(i int) antlr.TerminalNode + // IsThenExpressionListContext differentiates from other interfaces. IsThenExpressionListContext() } type ThenExpressionListContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyThenExpressionListContext() *ThenExpressionListContext { var p = new(ThenExpressionListContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = grulev3ParserRULE_thenExpressionList return p } +func InitEmptyThenExpressionListContext(p *ThenExpressionListContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = grulev3ParserRULE_thenExpressionList +} + func (*ThenExpressionListContext) IsThenExpressionListContext() {} func NewThenExpressionListContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ThenExpressionListContext { var p = new(ThenExpressionListContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = grulev3ParserRULE_thenExpressionList @@ -1403,35 +1460,19 @@ func (s *ThenExpressionListContext) Accept(visitor antlr.ParseTreeVisitor) inter } func (p *grulev3Parser) ThenExpressionList() (localctx IThenExpressionListContext) { - this := p - _ = this - localctx = NewThenExpressionListContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 14, grulev3ParserRULE_thenExpressionList) var _la int - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - p.EnterOuterAlt(localctx, 1) p.SetState(103) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) - for ok := true; ok; ok = (((_la)&-(0x1f+1)) == 0 && ((int64(1)< Date: Sun, 8 Dec 2024 18:10:17 +0100 Subject: [PATCH 4/4] Fix typo --- antlr/GruleParserV3Listener.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antlr/GruleParserV3Listener.go b/antlr/GruleParserV3Listener.go index b5432ffa..d8750e76 100755 --- a/antlr/GruleParserV3Listener.go +++ b/antlr/GruleParserV3Listener.go @@ -35,7 +35,7 @@ var ( "struct": "GruleParserV3Listener", } - // LoggerV3 is a logger instance twith default fields for grule + // LoggerV3 is a logger instance with default fields for grule LoggerV3 = logger.Log.WithFields(loggerV3Fields) )