Skip to content

Fix 2016 round 2 - #3841

Merged
parrt merged 8 commits into
antlr:devfrom
parrt:fix-2016-round-2
Aug 29, 2022
Merged

parrt merged 8 commits into
antlr:devfrom
parrt:fix-2016-round-2

Conversation

@parrt

@parrt parrt commented Aug 27, 2022 •

Copy link
Copy Markdown
Member

Supercedes #2022 Fixes #2016

@jimidle Go target fails this new test:

Test: ListLabelsOnRuleRefStartOfAlt; State: Execute; java.lang.InterruptedException: 
panic: interface conversion: antlr.PredictionContext is *antlr.EmptyPredictionContext, not *antlr.ArrayPredictionContext [recovered]
	panic: interface conversion: antlr.PredictionContext is *antlr.EmptyPredictionContext, not *antlr.ArrayPredictionContext

goroutine 1 [running]:
test/parser.(*TestParser).expression.func2()
	/private/var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/GoRunner-ForkJoinPool-1-worker-7-1661633249352/parser/test_parser.go:299 +0xfe
panic({0x10ed920, 0xc00007bc80})
	/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/antlr/antlr4/runtime/Go/antlr.merge({0x113ebf0?, 0xc000014d80}, {0x113eca0?, 0xc000012048}, 0x0, 0xfffffffffffffffe?)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/prediction_context.go:407 +0x351
github.com/antlr/antlr4/runtime/Go/antlr.(*BaseATNConfigSet).Add(0xc00002acc0, {0x113f068?, 0xc000130a00}, 0x0?)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/atn_config_set.go:140 +0x21f
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc000130a00}, {0x1140138, 0xc00002acc0}, 0xc00012eb70?, 0x0, 0x75?, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1030 +0xbd
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc000130a00}, {0x1140138, 0xc00002acc0}, 0x156ba98?, 0x40?, 0x1, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc0001309b0}, {0x1140138, 0xc00002acc0}, 0xc00012ed10?, 0x0, 0x75?, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1088 +0x43d
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc0001309b0}, {0x1140138, 0xc00002acc0}, 0x156ba98?, 0x40?, 0x1, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc000130960}, {0x1140138, 0xc00002acc0}, 0xc00012eeb0?, 0x0, 0x75?, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1088 +0x43d
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc000130960}, {0x1140138, 0xc00002acc0}, 0xc000130320?, 0x0?, 0x1, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc000130910}, {0x1140138, 0xc00002acc0}, 0xc00012f0a0?, 0x0, 0xf0?, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1088 +0x43d
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc000130910}, {0x1140138, 0xc00002acc0}, 0xc00012f140?, 0x94?, 0x1, 0xffffffffffffffff, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc0001308c0}, {0x1140138, 0xc00002acc0}, 0x156ba98?, 0x40?, 0x1, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1008 +0x747
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc000130870}, {0x1140138, 0xc00002acc0}, 0xc00012f2e0?, 0x0, 0x75?, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1088 +0x43d
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc000130870}, {0x1140138, 0xc00002acc0}, 0x156ba98?, 0x40?, 0x1, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc0001305f0}, {0x1140138, 0xc00002acc0}, 0xc00012f480?, 0x0, 0x75?, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1088 +0x43d
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc0001305f0}, {0x1140138, 0xc00002acc0}, 0x8?, 0x50?, 0x1, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureWork(0xc000064300, {0x113f068, 0xc0001305a0}, {0x1140138, 0xc00002acc0}, 0x20?, 0x0, 0x0?, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1088 +0x43d
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closureCheckingStopState(0xc000064300, {0x113f068, 0xc0001305a0}, {0x1140138, 0xc00002acc0}, 0x1047994?, 0x40?, 0x1, 0x0, 0x0)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:1022 +0x34a
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).closure(...)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:969
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).computeReachSet(0xc000064300, {0x1140138, 0xc00002ab00}, 0x4, 0x1)
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:575 +0x3d5
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).execATNWithFullContext(0xc000064300, 0x1140138?, 0xc00002a980?, {0x1140138, 0xc00002aa40}, {0x113f508, 0xc00002a2c0}, 0xc00012fa40?, {0x29355e48, 0xc00006f4f0})
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:398 +0x17f
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).execATN(0xc000064300, 0xc00002a4c0, 0xc000106310, {0x113f508, 0xc00002a2c0}, 0x1, {0x29355e48?, 0xc00006f4f0})
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:251 +0xa8f
github.com/antlr/antlr4/runtime/Go/antlr.(*ParserATNSimulator).AdaptivePredict(0xc000064300, {0x113f508?, 0xc00002a2c0}, 0x4, {0x29355e48, 0xc00006f4f0})
	/Users/parrt/antlr/code/antlr4/runtime/Go/antlr/parser_atn_simulator.go:145 +0xbef
test/parser.(*TestParser).expression(0xc0000122d0, 0xc00002a2c0?)
	/private/var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/GoRunner-ForkJoinPool-1-worker-7-1661633249352/parser/test_parser.go:340 +0x507
test/parser.(*TestParser).Expression(...)
	/private/var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/GoRunner-ForkJoinPool-1-worker-7-1661633249352/parser/test_parser.go:273
main.main()
	/private/var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/GoRunner-ForkJoinPool-1-worker-7-1661633249352/Test.go:37 +0x15c
exit status 2
Test directory: /var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/GoRunner-ForkJoinPool-1-worker-7-1661633249352

@parrt

parrt commented Aug 27, 2022 •

Copy link
Copy Markdown
Member Author

@lingyv-li there is a new test and it fails for the dart target could you take a look??

@lingyv-li

Copy link
Copy Markdown
Member

Taking a look

parrt added 7 commits August 28, 2022 12:04
Signed-off-by: Terence Parr <parrt@antlr.org>
…e causing the problem.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
… AssertIsList so I'm dropping that test from the Go test suite.

How did a comment to the C++ runnerFor my future reference as to how to build things from the command line.

Signed-off-by: Terence Parr <parrt@antlr.org>
@parrt
parrt force-pushed the fix-2016-round-2 branch from c680c59 to 2bcfe15 Compare August 28, 2022 19:04
@parrt
parrt merged commit 51150ab into antlr:dev Aug 29, 2022
@jimidle

jimidle commented Aug 31, 2022

Copy link
Copy Markdown
Collaborator

Go is all good on this now. PR is waiting.

Comment on lines +8 to +25
grammar Test;

expression
@after {
<AssertIsList("$args")>
}
: op=NOT args+=expression
| args+=expression (op=AND args+=expression)+
| args+=expression (op=OR args+=expression)+
| IDENTIFIER
;

AND : 'and' ;
OR : 'or' ;
NOT : 'not' ;
IDENTIFIER : [a-zA-Z_][a-zA-Z0-9_]* ;
WS : [ \t\r\n]+ -> skip ;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, my sample from #3837 looks more succinctly:

grammar Test;

r
    : args+=r (op=PLUS args+=r)+
    | IDENTIFIER
    ;
PLUS : '+';
IDENTIFIER : [a-zA-Z_][a-zA-Z0-9_]*;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I didn't see that one there. I believe I cut and paste something from code you or someone else was proposing earlier to make that one. Are you suggesting we drop ListLabelsOnRuleRefStartOfAlt.txt because it is redundant? I think it is testing the same thing so maybe we should. Well I guess my checks to type and yours doesn't check the output :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the same, but in more short form.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK but maybe we should test the output on yours as I think you asked me to do on this test ha ha I had trouble with the output templates in so I elected to simply check weather the attribute was a list. Maybe create a PR that adds

@after {
<AssertIsList("$r")>
}

to yours and then deletes ListLabelsOnRuleRefStartOfAlt.txt?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I didn't see that one there. I believe I cut and paste something from code you or someone else was proposing earlier to make that one. Are you suggesting we drop ListLabelsOnRuleRefStartOfAlt.txt because it is redundant? I think it is testing the same thing so maybe we should. Well I guess my checks to type and yours doesn't check the output :)

Yes - I think that this code was with the original issue, so I just made the <AssertIsList()> work. Either way is fine by me. Just tell me if you wish to lose the comments generated by - or you guys can just edit them out of PR #3848 and merge it. The other code in that PR is required for the test to work and fix the bug that was causing it to fail.

@jimidle

jimidle commented Aug 31, 2022 via email

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants