From 39c77ca20f3b85d6d341ddfbd0662091ed12fab0 Mon Sep 17 00:00:00 2001 From: Peter Boyer Date: Tue, 29 Nov 2016 23:45:29 -0500 Subject: [PATCH 1/3] Potential fix for antlr/antlr4 #1397 --- .../org/antlr/v4/tool/templates/codegen/Go/Go.stg | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg index 57885eee3..adf5ea17e 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg @@ -405,6 +405,10 @@ func (p *) ( } }() + + + var _int alt + @@ -663,7 +667,7 @@ la_ := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), , StarBlock(choice, alts, Sync, iteration) ::= << p.SetState() p.GetErrorHandler().Sync(p) -_alt := p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), , p.GetParserRuleContext()) +_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), , p.GetParserRuleContext()) for _alt != && _alt != antlr.ATNInvalidAltNumber { if _alt == 1+1 { @@ -683,7 +687,7 @@ for _alt != && _alt != antlr.ATNInvalidAltNumber { PlusBlock(choice, alts, error) ::= << p.SetState() p.GetErrorHandler().Sync(p) -_alt := 1+1 +_alt = 1+1 for ok := true; ok; ok = _alt != && _alt != antlr.ATNInvalidAltNumber { switch _alt { From ced8fba5bc66fda5413c3cf75c32e3e7cd693744 Mon Sep 17 00:00:00 2001 From: Peter Boyer Date: Tue, 29 Nov 2016 23:50:39 -0500 Subject: [PATCH 2/3] Update Go.stg --- tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg index adf5ea17e..62b257a42 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg @@ -407,7 +407,7 @@ func (p *) ( - var _int alt + var _alt int From f00e346ccdf3f36299e40a1b36c9649a211c9fc2 Mon Sep 17 00:00:00 2001 From: Peter Boyer Date: Wed, 30 Nov 2016 11:18:26 -0500 Subject: [PATCH 3/3] Add additional _alt decl --- tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg index 62b257a42..df4a434f9 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg @@ -480,6 +480,10 @@ func (p *) (_p int } } }() + + var _alt int + +