This repository contains many of my parser Implementation for LeetCode problem 227. Basic Calculator II. I also posted the same content into leetcode discussion, you can check the post there directly.
A way to dive deep into the details of PEP617 is to get your hands dirty. And leetcode is one of the best online judges to verify the implementation.
If you are like me before without a background in language parsing, here is the resource I used.
- Uncode - GATE Computer Science: Compiler Design lecture: This channel covers LL(1), LR(0), SLR(1), LR(1), CLR(1), LALR(1), and Operator Precedence parser.
- Packrat Parsing: Simple, Powerful, Lazy, Linear Time by Bryan Ford: The website of Bryan Ford, author of Packrat parser, provides the paper with implementation details and haskell implementation.
Why do I pick 227. Basic Calculator II?
Firstly, Leetcode contains many parsing related questions, 227. Basic Calculator II is one of the simplest one with just enough constraints for learning, which only requires to handle 5 type of symbols: + - * / and number, and all the input strings are valid.
Secondly, before I started my study, there were only LL(1) parser and Operator Precedence parser posts in discussion, LR(0), and Packrat parser were missing. Even if you search the related simple implementation in Google or other search engines, there's actually no organized work like this. (Implement all sorts of parsers for the same problem.)
- Add CST parser for LL(1)'s non-recursive parser
- Write PEG parser from scratch