Skip to content

Instantly share code, notes, and snippets.

View ramizpolic's full-sized avatar
⚔️
Bitwise operations

Ramiz Polic ramizpolic

⚔️
Bitwise operations
View GitHub Profile
@benmkw
benmkw / pratt.rs
Created April 9, 2020 16:20
pratt parser (and simple interpreter), handels both associativity and precedence
// ported from https://www.craftinginterpreters.com/compiling-expressions.html#a-pratt-parser
fn main() {
let input = "10*2+3";
assert_eq!(run(input), 10 * 2 + 3);
let input = "293474*4^5-50";
assert_eq!(run(input), 300_517_376 - 50);
let input = "-50+3*2^3";
assert_eq!(run(input), -50+3*8);