Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getters in context objects can go wrong when some alternatives have labels and some do not #13

Closed
parrt opened this issue Feb 15, 2012 · 2 comments

Comments

@parrt
Copy link
Member

parrt commented Feb 15, 2012

It gets ugly when you only partially label the alternatives and rule because it can cause type collisions with overridden methods. For unlabeled alternatives, we get getters in the main context object. The context objects for labeled alternatives are subclasses of that context. We might have a collision when we override:

e : e '+' e -> Add
   | '(' e ')'
   | ID
   ;

The unlabeled alternatives get methods in eContext:

public eContext e() { }
public Token ID() { }

But in the AddContext, we find an override with a different return type:

public List<eContext> e() { }

since e can have multiple values in that context. I'm not sure how to resolve.

sharwell referenced this issue in sharwell/antlr4 Feb 15, 2012
Several fixes on the latest updates
@parrt
Copy link
Member Author

parrt commented Feb 15, 2012

I think i'll force all or none for labels

@sharwell
Copy link
Member

This was originally fixed in 100b530, then patched into 725b105 and merged into master in pull request #16.

parrt added a commit that referenced this issue Jun 30, 2015
parrt pushed a commit that referenced this issue Jun 30, 2015
parrt pushed a commit that referenced this issue Jun 30, 2015
parrt pushed a commit that referenced this issue Nov 7, 2016
Additionally a warning was fixed (std::move prevents copy elision)
@ericvergnaud ericvergnaud mentioned this issue Nov 8, 2016
rrevenantt added a commit to rrevenantt/antlr4 that referenced this issue Sep 23, 2020
f8beaf8b6 fixed visitor architecture
f8da12f9e update readme and use rustfmt for formatting
d28736137 Fix `enterXXX` listener calls for alternative labels (antlr#13)
f0a2da766 fully finished support for zero-copy, generic token, and generic underlying data.
fdbf64f0f finished generic token support(almost, amend this)
d765c850a preliminary byte parser support, almost fully refotmatted with rustfmt
6bb617b51 more flexible tree structure and listener can have any lifetime now, more type safety
1188be780 zero-copy done, input stream changed accordingly.
2e75727b8 zero-copy, input_stream rewritten, docs improved
679319354 wip zero-copy, almost done, most of the tests passing
7833ab8fe wip zerocopy, compiles/passes tests successfully, only parse tree changes remaining
466b370dc wip zerocopy x2, lib compiles successfully
97cb6f8e5 wip zerocopy, compiles successfully
d8078f5fa minor adjustments
6aa622437 added proper build.rs, first change for next version - generic over token type
5bf0b080f fixed sometimes missing hash for prediction context
REVERT: 13d5a35cd fixed sometimes missing hash for prediction context

git-subtree-dir: runtime/Rust
git-subtree-split: f8beaf8b6d54cffa9d262abc54ef8d89511544d3
nmeylan pushed a commit to nmeylan/antlr4 that referenced this issue May 14, 2022
Rust target, named alternatives/childs
Almost full Rust target support,
Rust target implementation
All Rust target tests passing, added CI, and target related docs

fix testsuite, some cleanup

Squashed 'runtime/Rust/' changes from 307b806d9..a44046d9e

a44046d9e some cleanup, documentation and performace optimization

git-subtree-dir: runtime/Rust
git-subtree-split: a44046d9eb6feb0405383aa846a709128a20e5ec

add CI and CD

add CI and CD

minor fix

Squashed 'runtime/Rust/' changes from a44046d9e..b94028f34

b94028f34 update README, fix for getter on optional rule

git-subtree-dir: runtime/Rust
git-subtree-split: b94028f34b12e49a861a931194ed6de008094eb5

Squashed 'runtime/Rust/' changes from b94028f34..13d5a35cd

13d5a35cd fixed sometimes missing hash for prediction context
d562544f2 update README
20491fc2f update README, fix for getter on optional rule
REVERT: b94028f34 update README, fix for getter on optional rule

git-subtree-dir: runtime/Rust
git-subtree-split: 13d5a35cd3b11763f73278633290a23d2f61caf1

rust target v0.2, visitor, zero-copy, custom tokens

Squashed 'runtime/Rust/' changes from 13d5a35cd..f8beaf8b6

f8beaf8b6 fixed visitor architecture
f8da12f9e update readme and use rustfmt for formatting
d28736137 Fix `enterXXX` listener calls for alternative labels (antlr#13)
f0a2da766 fully finished support for zero-copy, generic token, and generic underlying data.
fdbf64f0f finished generic token support(almost, amend this)
d765c850a preliminary byte parser support, almost fully refotmatted with rustfmt
6bb617b51 more flexible tree structure and listener can have any lifetime now, more type safety
1188be780 zero-copy done, input stream changed accordingly.
2e75727b8 zero-copy, input_stream rewritten, docs improved
679319354 wip zero-copy, almost done, most of the tests passing
7833ab8fe wip zerocopy, compiles/passes tests successfully, only parse tree changes remaining
466b370dc wip zerocopy x2, lib compiles successfully
97cb6f8e5 wip zerocopy, compiles successfully
d8078f5fa minor adjustments
6aa622437 added proper build.rs, first change for next version - generic over token type
5bf0b080f fixed sometimes missing hash for prediction context
REVERT: 13d5a35cd fixed sometimes missing hash for prediction context

git-subtree-dir: runtime/Rust
git-subtree-split: f8beaf8b6d54cffa9d262abc54ef8d89511544d3

update CI

added proper downcasting, more generic input and error strategy, fixed context downcasting for predicates

Squashed 'runtime/Rust/' changes from f8beaf8b6..73e3450fe

73e3450fe remove redundant generation artifacts
b39c86a1a update dependencies
57775f2fa updated documentation and readme
be1ccd343 support downcasting in parser code, fixed some warnings
b054ca838 remove unnecessary boxing from apis, make ErrorStrategy generic to allow more inlining

git-subtree-dir: runtime/Rust
git-subtree-split: 73e3450fefc210949328d6cfd2cb0dc960e5972c

fixed cargo flags for CI

Rust target: support arbitrary visitor lifetime

Squashed 'runtime/Rust/' changes from 73e3450fe..bc5460134

bc5460134 rewrite visitor architecture to support arbitrary visitor lifetime
fa24927d5 exclude build.rs from package
8a0b33619 remove unused functions

git-subtree-dir: runtime/Rust
git-subtree-split: bc546013454e49badcdbb520e21a271054edf486

refactorings for 0.2 release, fix for separate file lexer and parser

move rust target to submodule

Use fork antlr-rust
nmeylan pushed a commit to nmeylan/antlr4 that referenced this issue May 14, 2022
Rust target, named alternatives/childs
Almost full Rust target support,
Rust target implementation
All Rust target tests passing, added CI, and target related docs

fix testsuite, some cleanup

Squashed 'runtime/Rust/' changes from 307b806d9..a44046d9e

a44046d9e some cleanup, documentation and performace optimization

git-subtree-dir: runtime/Rust
git-subtree-split: a44046d9eb6feb0405383aa846a709128a20e5ec

add CI and CD

add CI and CD

minor fix

Squashed 'runtime/Rust/' changes from a44046d9e..b94028f34

b94028f34 update README, fix for getter on optional rule

git-subtree-dir: runtime/Rust
git-subtree-split: b94028f34b12e49a861a931194ed6de008094eb5

Squashed 'runtime/Rust/' changes from b94028f34..13d5a35cd

13d5a35cd fixed sometimes missing hash for prediction context
d562544f2 update README
20491fc2f update README, fix for getter on optional rule
REVERT: b94028f34 update README, fix for getter on optional rule

git-subtree-dir: runtime/Rust
git-subtree-split: 13d5a35cd3b11763f73278633290a23d2f61caf1

rust target v0.2, visitor, zero-copy, custom tokens

Squashed 'runtime/Rust/' changes from 13d5a35cd..f8beaf8b6

f8beaf8b6 fixed visitor architecture
f8da12f9e update readme and use rustfmt for formatting
d28736137 Fix `enterXXX` listener calls for alternative labels (antlr#13)
f0a2da766 fully finished support for zero-copy, generic token, and generic underlying data.
fdbf64f0f finished generic token support(almost, amend this)
d765c850a preliminary byte parser support, almost fully refotmatted with rustfmt
6bb617b51 more flexible tree structure and listener can have any lifetime now, more type safety
1188be780 zero-copy done, input stream changed accordingly.
2e75727b8 zero-copy, input_stream rewritten, docs improved
679319354 wip zero-copy, almost done, most of the tests passing
7833ab8fe wip zerocopy, compiles/passes tests successfully, only parse tree changes remaining
466b370dc wip zerocopy x2, lib compiles successfully
97cb6f8e5 wip zerocopy, compiles successfully
d8078f5fa minor adjustments
6aa622437 added proper build.rs, first change for next version - generic over token type
5bf0b080f fixed sometimes missing hash for prediction context
REVERT: 13d5a35cd fixed sometimes missing hash for prediction context

git-subtree-dir: runtime/Rust
git-subtree-split: f8beaf8b6d54cffa9d262abc54ef8d89511544d3

update CI

added proper downcasting, more generic input and error strategy, fixed context downcasting for predicates

Squashed 'runtime/Rust/' changes from f8beaf8b6..73e3450fe

73e3450fe remove redundant generation artifacts
b39c86a1a update dependencies
57775f2fa updated documentation and readme
be1ccd343 support downcasting in parser code, fixed some warnings
b054ca838 remove unnecessary boxing from apis, make ErrorStrategy generic to allow more inlining

git-subtree-dir: runtime/Rust
git-subtree-split: 73e3450fefc210949328d6cfd2cb0dc960e5972c

fixed cargo flags for CI

Rust target: support arbitrary visitor lifetime

Squashed 'runtime/Rust/' changes from 73e3450fe..bc5460134

bc5460134 rewrite visitor architecture to support arbitrary visitor lifetime
fa24927d5 exclude build.rs from package
8a0b33619 remove unused functions

git-subtree-dir: runtime/Rust
git-subtree-split: bc546013454e49badcdbb520e21a271054edf486

refactorings for 0.2 release, fix for separate file lexer and parser

move rust target to submodule

Use fork antlr-rust
byblakeorriver pushed a commit to byblakeorriver/antlr4 that referenced this issue Apr 27, 2023
f8beaf8b6 fixed visitor architecture
f8da12f9e update readme and use rustfmt for formatting
d28736137 Fix `enterXXX` listener calls for alternative labels (antlr#13)
f0a2da766 fully finished support for zero-copy, generic token, and generic underlying data.
fdbf64f0f finished generic token support(almost, amend this)
d765c850a preliminary byte parser support, almost fully refotmatted with rustfmt
6bb617b51 more flexible tree structure and listener can have any lifetime now, more type safety
1188be780 zero-copy done, input stream changed accordingly.
2e75727b8 zero-copy, input_stream rewritten, docs improved
679319354 wip zero-copy, almost done, most of the tests passing
7833ab8fe wip zerocopy, compiles/passes tests successfully, only parse tree changes remaining
466b370dc wip zerocopy x2, lib compiles successfully
97cb6f8e5 wip zerocopy, compiles successfully
d8078f5fa minor adjustments
6aa622437 added proper build.rs, first change for next version - generic over token type
5bf0b080f fixed sometimes missing hash for prediction context
REVERT: 13d5a35cd fixed sometimes missing hash for prediction context

git-subtree-dir: runtime/Rust
git-subtree-split: f8beaf8b6d54cffa9d262abc54ef8d89511544d3
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants