From ad514f56b6cda288e605c44990ef16d30e6dee53 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 2 Sep 2021 23:31:39 +0200 Subject: 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). --- isabelle-dump/src/main.rs | 71 ----------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 isabelle-dump/src/main.rs (limited to 'isabelle-dump/src/main.rs') 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::>() - .join(""); - println!("{}", rendered); - } - _ => { - eprintln!("could not parse file (probably spurious \\, <, or >)"); - std::process::exit(1); - } - } - } - _ => break, - } - } -} -- cgit v1.2.3