Coder Social home page Coder Social logo

Comments (4)

haferburg avatar haferburg commented on July 20, 2024 2

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.

NoahGWood avatar NoahGWood commented on July 20, 2024 1

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.

marcelogdeandrade avatar marcelogdeandrade commented on July 20, 2024 1

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.

marcelogdeandrade avatar marcelogdeandrade commented on July 20, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.