1 stable release

1.0.0 Jun 6, 2024

#2261 in Parser implementations

Download history 1/week @ 2024-06-24 9/week @ 2024-07-29 1/week @ 2024-08-12 18/week @ 2024-08-26 9/week @ 2024-09-16 28/week @ 2024-09-23 14/week @ 2024-09-30

51 downloads per month
Used in 3 crates (via wagon-parser)

Apache-2.0

67KB
1K SLoC

WAGon Lexer

Lexer for the WAGon DSL.


lib.rs:

WAGon Lexers

Provides lexers for the WAGon DSL, as well as helper iterators which can switch between lexers on the fly. Most likely, all you will care about are LexerBridge and Tokens.

Example

let s = r#"
meta: "data";
============
S -> A;
"#;
use wagon_lexer::{Tokens, LexerBridge, LexResult};
use wagon_ident::Ident;

let lexer = LexerBridge::new(s);
let tokens: Vec<LexResult> = lexer.collect();
assert_eq!(tokens, vec![
Ok(Tokens::MetadataToken(Metadata::Identifier("meta".into()))), 
Ok(Tokens::MetadataToken(Metadata::Colon)),
Ok(Tokens::MathToken(Math::LitString("data".to_string()))),
Ok(Tokens::MathToken(Math::Semi)),
Ok(Tokens::MetadataToken(Metadata::Delim)),
Ok(Tokens::ProductionToken(Productions::Identifier(Ident::Unknown("S".to_string())))),
Ok(Tokens::ProductionToken(Productions::Produce)),
Ok(Tokens::ProductionToken(Productions::Identifier(Ident::Unknown("A".to_string())))),
Ok(Tokens::ProductionToken(Productions::Semi))
])

Dependencies

~4.5MB
~82K SLoC