This repository was archived by the owner on Jan 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
41 lines (31 loc) · 1.37 KB
/
build.rs
File metadata and controls
41 lines (31 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use cfgrammar::yacc::YaccKind;
use lrlex::LexerBuilder;
use lrpar::CTParserBuilder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(r"cargo:rustc-link-search=/usr/local/lib/");
// '.error_on_conflicts(true)' does not print the conflicts that occur, which makes the error
// hard to debug. Instead, we print the conflicts ourselves below.
let mut parser_builder = CTParserBuilder::new()
.yacckind(YaccKind::Grmtools)
.error_on_conflicts(false);
let lex_rule_ids_map = parser_builder.process_file_in_src("parser.y")?;
if let Some(conflicts) = parser_builder.conflicts() {
println!("{}", conflicts.3.pp(conflicts.0));
panic!("Found shift-reduce or reduce-reduce conflicts (described above).");
}
LexerBuilder::new()
.rule_ids_map(lex_rule_ids_map)
.process_file_in_src("lexer.l")?;
let mut parser_builder = CTParserBuilder::new()
.yacckind(YaccKind::Grmtools)
.error_on_conflicts(false);
let lex_rule_ids_map = parser_builder.process_file_in_src("grift.y")?;
if let Some(conflicts) = parser_builder.conflicts() {
println!("{}", conflicts.3.pp(conflicts.0));
panic!("Found shift-reduce or reduce-reduce conflicts (described above).");
}
LexerBuilder::new()
.rule_ids_map(lex_rule_ids_map)
.process_file_in_src("grift.l")?;
Ok(())
}