3 releases
0.0.3 | Mar 13, 2022 |
---|---|
0.0.2 | Mar 2, 2022 |
0.0.1 | Mar 1, 2022 |
#220 in Parser tooling
Used in physical-quantity
14KB
249 lines
Description
This package provide keyword parser using with combine.
Usage
use ::keyword_parser::transition::*;
use ::transition_table::*;
use ::combine::EasyParser;
const UNITS_TBL: [(&str, u8); 27] = [
// L
("m", 1),
("inch", 2),
("もしもし", 3),
// M
("g", 4),
("lb", 5),
// T
("s", 6),
("Hz", 7),
// θ
("K", 8),
("\u{00B0}R", 9), // °R
("\u{00B0}F", 10), // °F
("\u{2109}", 11), // ℉
("\u{00B0}C", 12), // °C
("\u{2103}", 13), // ℃
// N
("mol", 14),
// I
("A", 15),
// J
("cd", 16),
// Force
("N", 17),
("gf", 18),
("lbf", 19),
// Pressure
("Pa", 20),
("ata", 21),
("psi", 22),
// Energy
("J", 23),
("cal", 24),
("Btu", 25),
("W", 26),
("Wh", 27),
];
let tree = Entry::<char, _>::new(UNITS_TBL.iter());
let tbl: Vec<Transition<_, _, _>> = tree.into();
let mut p = keyword(&tbl);
let i = p.easy_parse("もしもし").map(|x| x.0).unwrap();
assert_eq!(UNITS_TBL[i].1, 3);
Project status
This package is in the very early stage.
Dependencies
~755KB
~15K SLoC