You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
deferror(self, p):
ifp:
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?
The text was updated successfully, but these errors were encountered:
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.
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:
Am I just understanding the docs wrong or is there not supposed to be an error token generated when I call errok?
The text was updated successfully, but these errors were encountered: