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
Sadly I didn't come across this error. Can you please give more information about this issue? Your system specs and what version of each lib are you using?
The warnings are coming up because you forgot to pass a list of precedents to your ParserGenerator
Easy enough fix, just update your Parser class to reflect this: pg = ParserGenerator( # A list of all token names, accepted by the parser. ['NUMBER', 'OPEN_PARENS', 'CLOSE_PARENS', 'PLUS', 'MINUS', 'MUL', 'DIV' ], # A list of precedence rules with ascending precedence, to # disambiguate ambiguous production rules. precedence=[ ('left', ['PLUS', 'MINUS']), ('left', ['MUL', 'DIV']) ] )
code from https://rply.readthedocs.io/en/latest/users-guide/parsers.html
Oh, I didn't use precedents because I chose to do a more theoretical approach, solving this issue in the EBNF. I'll look into it to solve this warning.
The grammar you used in the article doesn't solve this problem, though. You'd have to use different productions for different operators. If you want to combine them like you did, you do have to provide a precedence list, and the generator will handle splitting up the productions for you.
Here's what fixes the issue for the code in the article.
self.pg = ParserGenerator(
# A list of all token names accepted by the parser.
[
"NUMBER",
"PRINT",
"OPEN_PAREN",
"CLOSE_PAREN",
"SEMI_COLON",
"SUM",
"SUB",
],
precedence=[("left", ["SUM", "SUB"])],
)
Activity
marcelogdeandrade commentedon Feb 20, 2019
Sadly I didn't come across this error. Can you please give more information about this issue? Your system specs and what version of each lib are you using?
Thank you for reporting it 😊
NoahGWood commentedon Feb 22, 2019
The warnings are coming up because you forgot to pass a list of precedents to your ParserGenerator
Easy enough fix, just update your Parser class to reflect this:
pg = ParserGenerator( # A list of all token names, accepted by the parser. ['NUMBER', 'OPEN_PARENS', 'CLOSE_PARENS', 'PLUS', 'MINUS', 'MUL', 'DIV' ], # A list of precedence rules with ascending precedence, to # disambiguate ambiguous production rules. precedence=[ ('left', ['PLUS', 'MINUS']), ('left', ['MUL', 'DIV']) ] )code from https://rply.readthedocs.io/en/latest/users-guide/parsers.html
marcelogdeandrade commentedon Feb 27, 2019
Oh, I didn't use precedents because I chose to do a more theoretical approach, solving this issue in the EBNF. I'll look into it to solve this warning.
Thanks for the help
haferburg commentedon Oct 27, 2019
The grammar you used in the article doesn't solve this problem, though. You'd have to use different productions for different operators. If you want to combine them like you did, you do have to provide a precedence list, and the generator will handle splitting up the productions for you.
Here's what fixes the issue for the code in the article.