Comments (4)
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"])],
)
from pythoncompiler.
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
from pythoncompiler.
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
from pythoncompiler.
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 😊
from pythoncompiler.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pythoncompiler.