GithubHelp home page GithubHelp logo

Arithmetic expression example about nom HOT 7 CLOSED

rust-bakery avatar rust-bakery commented on August 25, 2024 4
Arithmetic expression example

from nom.

Comments (7)

Geal avatar Geal commented on August 25, 2024 5

There is now an example of arithmetic expression parsing, although not based on a Pratt parser. Parser combinators embed the precedence rules in the way functions refer to each other.

from nom.

Geal avatar Geal commented on August 25, 2024 2

ok, so, I gave it some thought. It would be possible to use nom as a lexer, and let a Pratt parser handle precedence.

I have been thinking for some time about adding multiple parsing systems over nom, like GLL, LL, etc. Hammer is an example of parser combinators used with different parsing backends.

from nom.

epage avatar epage commented on August 25, 2024 2

FYI #1690 is the issue for tracking the status of built-in Pratt Parser support.

from nom.

Geal avatar Geal commented on August 25, 2024 1

from nom.

emberian avatar emberian commented on August 25, 2024

I'm trying to write a generic Pratt parser using Nom, and arriving at difficulty. Since parsers must be a function (I think?) and not something implementing a trait, there is nowhere for the parser to store the state on token precedence.

from nom.

emberian avatar emberian commented on August 25, 2024

I'm honestly not even sure how you would use Nom in the traditional context of parsing a context-free language.

from nom.

lazarljubenovic avatar lazarljubenovic commented on August 25, 2024

This is the first result when you Google "rust nom pratt parse". Has anything changed since 2015? I was hoping to find a recipe for “you can write your expression rule as a Pratt parser (by hand), and then this is how you integrate it into nom for the rest of the grammar“.

from nom.

Related Issues (20)

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.