Files
not-python/build.rs
Alek Ratzloff 38b7124fe2 Add rerun_except crate, and small example code
* rerun_except will ensure a build doesn't rerun if a *.not file is
  modified, which it would otherwise do
* Add examples/expr.not with some basic assignment statements and
  function calls

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-17 13:26:38 -07:00

25 lines
813 B
Rust

use cfgrammar::yacc::YaccKind;
use lrlex::LexerBuilder;
use lrpar::CTParserBuilder;
use rerun_except::rerun_except;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Skip rerunning if it's just *.not files that have changed
rerun_except(&["*.not"]).unwrap();
// Build parser + lexer
let mut parser_builder = CTParserBuilder::new()
.yacckind(YaccKind::Grmtools)
.error_on_conflicts(false);
let lex_rule_ids_map = parser_builder
.process_file_in_src("syn/parser.y")?;
if let Some((grm, _, _, conflicts)) = parser_builder.conflicts() {
eprintln!("{}", conflicts.pp(grm));
return Err("conflicts in parser".into());
}
LexerBuilder::new()
.rule_ids_map(lex_rule_ids_map)
.process_file_in_src("syn/lexer.l")?;
Ok(())
}