https://github.com/cfsamson/examples-parsers
For now, just a playground for exploring different parsing techniques.
https://github.com/cfsamson/examples-parsers
Last synced: 1 day ago
JSON representation
For now, just a playground for exploring different parsing techniques.
- Host: GitHub
- URL: https://github.com/cfsamson/examples-parsers
- Owner: cfsamson
- Created: 2019-12-30T17:24:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-30T17:25:08.000Z (over 5 years ago)
- Last Synced: 2025-02-09T22:25:01.540Z (4 months ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Parsers in Rust
This is just playing around with some simple parsing techniques. I try to
make them as simple as possible. This is probably not a "best practice" when
it comes to implementing proper parsers.I'm just parsing simple math expressions. The goal is to have input like this:
```
1 + 2 + 4
2 * 100
```Turned in to a simple AST where each line is a `parent` with the numbers and
operators as child nodes.1. Recursive descent parser
I've implemented these just loosely following any patterns. First the input
is lexed into a token stream. Then this stream is parsed. There is currently no
need to do any backtracing or anything fancy.Loosely inspired by this: https://adriann.github.io/rust_parser.html
2. Recursive ascent parser
This is planning on using the recursive ascent parser based on this article:
https://www.abubalay.com/blog/2018/04/08/recursive-ascent3. Using parser generators
This excellent article outlines how to use parser generators:
https://bodil.lol/parser-combinators/
https://matklad.github.io/2018/06/06/modern-parser-generator.html## Status
Work in progress. Maybe some day I'll write about this, I don't know yet.
This is currenty me just playing around.