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

Get token values for a lexer rule #16

Closed
ssdimmanuel opened this issue Jun 11, 2018 · 1 comment
Closed

Get token values for a lexer rule #16

ssdimmanuel opened this issue Jun 11, 2018 · 1 comment

Comments

@ssdimmanuel
Copy link

ssdimmanuel commented Jun 11, 2018

First of all many thanks for making the auto-completion feature available. It saved me lot of work.
I am able to use the CodeCompletionCore and get the list of tokens rules and token names (using vocabulary). But is there a way to extract the actual values used in the grammar?
For ex: l have the following lexer rule
AndorOr: ‘&’ | ‘|’ ;
From the CodeCompletionCore I can get AndorOr . How can I get the values & , | ?

@mike-lischke
Copy link
Owner

There's no built-in support to directly return the values a lexer rule is made of. Keep in mind that can be complex, involving other lexer rules (also fragment rules), predicates etc.

You could use a symbol table to get that info (still not perfect) or do an LL1 walk over the lexer ATN for a given rule (see the LL1Analyzer class, which does this for parser rules).

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

No branches or pull requests

2 participants