Crates.io | keyword-parser |
lib.rs | keyword-parser |
version | 0.0.3 |
source | src |
created_at | 2022-03-01 13:59:57.915349 |
updated_at | 2022-03-13 05:54:58.142115 |
description | Keyword parser for combine. |
homepage | https://gitlab.com/fton/keyword-parser |
repository | https://gitlab.com/fton/keyword-parser |
max_upload_size | |
id | 541549 |
size | 13,805 |
This package provide keyword parser using with combine.
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);
This package is in the very early stage.