forked from rrevenantt/antlr4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'runtime/Rust/' changes from 13d5a35cd..f8beaf8b6
f8beaf8b6 fixed visitor architecture f8da12f9e update readme and use rustfmt for formatting d28736137 Fix `enterXXX` listener calls for alternative labels (antlr#13) f0a2da766 fully finished support for zero-copy, generic token, and generic underlying data. fdbf64f0f finished generic token support(almost, amend this) d765c850a preliminary byte parser support, almost fully refotmatted with rustfmt 6bb617b51 more flexible tree structure and listener can have any lifetime now, more type safety 1188be780 zero-copy done, input stream changed accordingly. 2e75727b8 zero-copy, input_stream rewritten, docs improved 679319354 wip zero-copy, almost done, most of the tests passing 7833ab8fe wip zerocopy, compiles/passes tests successfully, only parse tree changes remaining 466b370dc wip zerocopy x2, lib compiles successfully 97cb6f8e5 wip zerocopy, compiles successfully d8078f5fa minor adjustments 6aa622437 added proper build.rs, first change for next version - generic over token type 5bf0b080f fixed sometimes missing hash for prediction context REVERT: 13d5a35cd fixed sometimes missing hash for prediction context git-subtree-dir: runtime/Rust git-subtree-split: f8beaf8b6d54cffa9d262abc54ef8d89511544d3
- Loading branch information
1 parent
a8b42a1
commit 9786981
Showing
5 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use std::convert::TryInto; | ||
use std::env; | ||
use std::env::VarError; | ||
use std::error::Error; | ||
use std::fs::{read_dir, DirEntry, File}; | ||
use std::io::Write; | ||
use std::path::Path; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let grammars = vec![ | ||
"CSV", | ||
"ReferenceToATN", | ||
"XMLLexer", | ||
"SimpleLR", | ||
"Labels", | ||
"FHIRPath", | ||
]; | ||
let additional_args = vec![Some("-visitor"), None, None, None, None]; | ||
let antlr_path = "/home/rrevenantt/dev/antlr4/tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar"; | ||
|
||
for (grammar, arg) in grammars.into_iter().zip(additional_args) { | ||
//ignoring error because we do not need to run anything when deploying to crates.io | ||
let _ = gen_for_grammar(grammar, antlr_path, arg); | ||
} | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
println!("cargo:rerun-if-changed=/home/rrevenantt/dev/antlr4/tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar"); | ||
} | ||
|
||
fn gen_for_grammar( | ||
grammar_file_name: &str, | ||
antlr_path: &str, | ||
additional_arg: Option<&str>, | ||
) -> Result<(), Box<Error>> { | ||
// let out_dir = env::var("OUT_DIR").unwrap(); | ||
// let dest_path = Path::new(&out_dir); | ||
|
||
let input = env::current_dir().unwrap().join("grammars"); | ||
let file_name = grammar_file_name.to_owned() + ".g4"; | ||
|
||
let c = Command::new("java") | ||
.current_dir(input) | ||
.arg("-cp") | ||
.arg(antlr_path) | ||
.arg("org.antlr.v4.Tool") | ||
.arg("-Dlanguage=Rust") | ||
.arg("-o") | ||
.arg("../tests/gen") | ||
.arg(&file_name) | ||
.args(additional_arg) | ||
.spawn() | ||
.expect("antlr tool failed to start") | ||
.wait_with_output()?; | ||
// .unwrap() | ||
// .stdout; | ||
// eprintln!("xx{}",String::from_utf8(x).unwrap()); | ||
|
||
println!("cargo:rerun-if-changed=grammars/{}", file_name); | ||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
edition = "2018" | ||
fn_single_line = true |