Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ parse-it Public

A user-friendly, opinionated parser generator for Rust

License

Notifications You must be signed in to change notification settings

Wybxc/parse-it

Repository files navigation

Parse It

A user-friendly, opinionated parser generator for Rust.

Example

use parse_it::{ParseIt, parse_it};
type Lexer = parse_it::CharLexer;
#[derive(Debug, Clone)]
pub enum Instr {
 Left,
 Right,
 Incr,
 Decr,
 Read,
 Write,
 Loop(Vec<Self>),
}
parse_it! {
 #[parser]
 mod parse {
 use super::Instr;
 pub Brainfuck -> Vec<Instr> {
 Primitive* => self,
 }
 Primitive -> Instr {
 '<' => Instr::Left,
 '>' => Instr::Right,
 '+' => Instr::Incr,
 '-' => Instr::Decr,
 ',' => Instr::Read,
 '.' => Instr::Write,
 '[' Primitive+ ']' => Instr::Loop(self)
 }
 }
}
fn main() {
 let parser = parse::Brainfuck::default();
 let src = "--[>--->->->++>-<<<<<-------]>--.>---------.>--..+++.>----.>+++++++++.<<.+++.------.<-.>>+";
 let instrs = parser.parse(src).unwrap();
 println!("{:?}", instrs);
}

Planned features

  • Parser generation
  • Lexer generation
  • Error reporting
  • Error recovery
  • Grammar lints

About

A user-friendly, opinionated parser generator for Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /