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

foo_all() getters output children that are not of the kind foo #56

Open
dmitrii-ubskii opened this issue Aug 22, 2022 · 0 comments · May be fixed by #58
Open

foo_all() getters output children that are not of the kind foo #56

dmitrii-ubskii opened this issue Aug 22, 2022 · 0 comments · May be fixed by #58

Comments

@dmitrii-ubskii
Copy link

I encountered this issue while implementing grammarVisitorCompat using antlr-rust v0.3.0-beta.

Consider the following grammar:

grammar all_test;

list: GET VAR_ ( ',' VAR_ )* ;
GET: 'get';
VAR_: '$' [a-zA-Z0-9][a-zA-Z0-9_-]* ;

WS : [ \t\r\n]+ -> channel(HIDDEN) ;

When parsing the input, we would like to collect all the variables into a list. I.e,, when parsing the string "get $abc, $def", we expect to parse that into ["$abc", "$def"].

Using ctx.VAR__all() (where ctx is the &ListContext argument of visit_list()) results in the following output: "get", "$abc", ",", "$def"

Note that, at the same time, ctx.VAR_(i) produces the expected result:

ctx.VAR_(0) == Some($abc);
ctx.VAR_(1) == Some($def);
ctx.VAR_(2) == None;

The entire MRE can be found at https://github.com/dmitrii-ubskii/antlr-rust-all-issue

@dmitrii-ubskii dmitrii-ubskii changed the title ..._all() getters output more tokens than they should foo_all() getters output children that are not of the kind foo Aug 22, 2022
@newca12 newca12 linked a pull request Aug 27, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant