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

self.errok() still creates an error token #102

Open
dscarr3000 opened this issue Oct 12, 2022 · 1 comment
Open

self.errok() still creates an error token #102

dscarr3000 opened this issue Oct 12, 2022 · 1 comment

Comments

@dscarr3000
Copy link

I've been using SLY to write a parser for a fake programming language and I think I've encountered an issue. When trying to do some error handling I created an error method matching what was used in the docs.

def error(self, p):
    if p:
        print("Syntax error at token", p.type)
        # Just discard the token and tell the parser it's okay.
        self.errok()
    else:
        print("Syntax error at EOF")

However, the docs say that self.errok() will "prevent an error token from being generated". This doesn't appear to be the case, when I test my parser with bad input I'm getting multiple error tokens happening. Here is my output:

python3 KXICompiler.py -p <<EOF
void kxi2022 main() {
        int i  0;
}
EOF
Syntax error at token INT
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token error
Syntax error at token INT
Syntax error at token SEMI_COLON
Syntax error at token RIGHT_CURLY_BRACE
Syntax error at EOF

Am I just understanding the docs wrong or is there not supposed to be an error token generated when I call errok?

@dabeaz
Copy link
Owner

dabeaz commented Oct 12, 2022

Let me look into it. This isn't a feature I've used much. I will compare against PLY and Bison.

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