diff options
author | stuebinm | 2021-09-02 23:31:39 +0200 |
---|---|---|
committer | stuebinm | 2021-09-03 00:02:16 +0200 |
commit | ad514f56b6cda288e605c44990ef16d30e6dee53 (patch) | |
tree | bec6de5f4bdabf432c7045394af15ba96f525546 /isabelle-dump/src/main.rs | |
parent | 715001ba92799839afc97d92c9f0a79924085a69 (diff) |
remove grmtools
the parser using grmtools was way oversized for just doing escape
sequences, and only really existed since I wanted to play around with
it.
The new implementation depends on no external crates, uses just an iter
wrapped into a nicely composable function, and appears to be exactly
equivalent (but faster).
Diffstat (limited to 'isabelle-dump/src/main.rs')
-rw-r--r-- | isabelle-dump/src/main.rs | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/isabelle-dump/src/main.rs b/isabelle-dump/src/main.rs deleted file mode 100644 index 891108f..0000000 --- a/isabelle-dump/src/main.rs +++ /dev/null @@ -1,71 +0,0 @@ -use std::io::{self, BufRead, Write}; - -use lrlex::lrlex_mod; -use lrpar::lrpar_mod; - -#[derive(Debug)] -pub enum Isabelle { - Symbol(String), - Text(String), -} - - -lrlex_mod!("calc.l"); -lrpar_mod!("calc.y"); - - -symbolmacro::make_symbols!(); - - -fn main() { - // Get the `LexerDef` for the `calc` language. - let lexerdef = calc_l::lexerdef(); - let stdin = io::stdin(); - loop { - io::stdout().flush().ok(); - match stdin.lock().lines().next() { - Some(Ok(ref l)) => { - if l.trim().is_empty() { - println!(""); - continue; - } - let lexer = lexerdef.lexer(l); - let (res, errs) = calc_y::parse(&lexer); - for e in errs { - eprintln!( - "{}", - e.pp(&lexer, &calc_y::token_epp) - ); - } - match res { - Some(r) => { - //eprintln!("Result: {:?}", r); - let rendered = r - .unwrap() - .iter() - .map(|token| match token { - Isabelle::Text(ref t) => - t, - Isabelle::Symbol(name) => - symbol(name) - .unwrap_or_else(|| { - Box::leak( - format!("\\<{}>", name) - .into() - ) - }) - }) - .collect::<Vec<&str>>() - .join(""); - println!("{}", rendered); - } - _ => { - eprintln!("could not parse file (probably spurious \\, <, or >)"); - std::process::exit(1); - } - } - } - _ => break, - } - } -} |