operator_precedence_parsing
C89 expressions parsed with the shunting yard algorithm in Python (by bourguet)
langs
By sal55
operator_precedence_parsing | langs | |
---|---|---|
8 | 185 | |
57 | 84 | |
- | - | |
0.0 | 9.3 | |
over 2 years ago | 11 days ago | |
Python | C | |
BSD 2-clause "Simplified" License | - |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
operator_precedence_parsing
Posts with mentions or reviews of operator_precedence_parsing.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2022-12-07.
-
What are the advantages of pratt parsing over recursive descent parsing?
Pratt parsing can be considered as a refactoring of the expression part of a recursive descent parser where you have extracted the precedence and associativity into tables (that's not how it has been designed, but I've made the refactoring excercise in https://github.com/bourguet/operator_precedence_parsing where you can find a bunch of other expression parsers parsing the same language and written in a similar style for easier comparison)
-
What's the easiest way to add features to an existing programming language?
If you want a selection of expression parsing algorithms, I've a collection here showing how to parse C-like expressions with them.
-
Calculations with brackets
I've a GitHub repository with Python implementations of those showing how to parse C expressions (included the ?: operator) at https://github.com/bourguet/operator_precedence_parsing (it was started when I was wondering how Pratt related to the algorithms more often presented in the literature, my opinion is that you can consider it as a refactoring of a more classical RD parser, loosing some power but table driven and with a probable performance advantage).
-
Crafting Interpreter : parsePrecedence
You may be interested in https://github.com/bourguet/operator_precedence_parsing there is a series of files were I refactor a recursive descent parser into a Pratt one. The crucial step is IIRC between rd_to_pratt 3 and 4. The only difference in that step is in a single function.
-
How does Pratt Parsing work?
I have some time ago written a comparison between several expression parsers: https://github.com/bourguet/operator_precedence_parsing my implementation of Pratt is pratt.py in that repository.
-
Better operator precedence
Sometimes ago, I've collected a set of expression parsing algorithms (shunting yard, Pratt, ...) to compare them and I included a small discussion of the way to implement the precedence function. I tend to like having two tables -- that's allow to represent distfix structures and to get left/right associativity without needing the full matrix -- see https://github.com/bourguet/operator_precedence_parsing.
- Turing Award to Aho and Ullman for work on compilers
-
Modifying the Shunting-yard algorithm for logical, string-based & mathematical operations all-in-one?
A few years ago, I wrote several expression parsers in Python (shunting yard, expression precedence, Pratt) aiming to compare them and to provide implementations of algorithms as described in historical papers. It's on GitHub https://github.com/bourguet/operator_precedence_parsing. That may be interesting for you.
langs
Posts with mentions or reviews of langs.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-12-09.
- How does the compiler know that an already typedefed ident is meant to be a new declarator?
- Compiler Case Study
- Making Simple Concepts Hard
- What makes a language easy for writing a parser?
-
Resources to understand mojo and compilers
The code is here. Note that the input filename is hardcoded in the source code.
- Automatic import of C headers —how to deal with macros?
- How does preprocessing work in a one pass compiler?
- 'Table Data' and 'X-Macros'
- Register Window in a Stack VM Interpreter
- My New IL
What are some alternatives?
When comparing operator_precedence_parsing and langs you can also consider the following projects:
erikeidt
prolog-to-minizinc - A Prolog-to-MiniZinc translator
rakudo - 🦋 Rakudo – Raku on MoarVM, JVM, and JS
vox - Vox language compiler. AOT / JIT / Linker. Zero dependencies
zig - General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
wabt - The WebAssembly Binary Toolkit
factor - Factor programming language
c2rust - Migrate C code to Rust
xvm - Ecstasy and XVM
Cwerg - The best C-like language that can be implemented in 10kLOC.
TablaM - The practical relational programing language for data-oriented applications
futhark - :boom::computer::boom: A data-parallel functional programming language