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

EOF leaf not included in parent tree source interval #896

Closed
parrt opened this issue Jun 11, 2015 · 1 comment
Closed

EOF leaf not included in parent tree source interval #896

parrt opened this issue Jun 11, 2015 · 1 comment

Comments

@parrt
Copy link
Member

parrt commented Jun 11, 2015

Test case shows issue. Tree shows <EOF> but source interval doesn't include it. Whoops. Culprit is Parser:

    public void exitRule() {
        _ctx.stop = _input.LT(-1); <-- ooops; doesn't count EOF

Issue is that consume() of EOF doesn't move p in token stream so LT(-1) doesn't include it. Not sure of best solution. Must detect match of EOF. Can't test LT(1)==EOF as that can't distinguish "about to match EOF" from "matched EOF".

@parrt
Copy link
Member Author

parrt commented Jun 11, 2015

I use this in a subclass; seems to work:

    public void exitRule() {
        if ( matchedEOF ) _ctx.stop = _input.LT(1);
        else _ctx.stop = _input.LT(-1);

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