dparser
dparser copied to clipboard
Simplifying rust example generates warnings
If you apply this patch and build the rust example, it will cause warnings in generated files, which I don't seem to have any control over.
Warnings
warning: unused import: `dparser_lib::bindings::*`
--> /Users/dave/src/dparser/rust/target/debug/build/example-4d9bfc540e29f338/out/actions.rs:2:5
|
2 | use dparser_lib::bindings::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `std::os::raw::c_void`
--> /Users/dave/src/dparser/rust/target/debug/build/example-4d9bfc540e29f338/out/actions.rs:5:5
|
5 | use std::os::raw::c_void;
| ^^^^^^^^^^^^^^^^^^^^
Patch
diff --git a/rust/example/src/main.rs b/rust/example/src/main.rs
index b9fd99e..c917552 100644
--- a/rust/example/src/main.rs
+++ b/rust/example/src/main.rs
@@ -7,7 +7,7 @@ unsafe extern "C" {
}
fn main() {
- let input_string = "a x b uvu";
+ let input_string = "xxx";
println!("Parsing input: '{}'", input_string);
@@ -15,7 +15,7 @@ fn main() {
let mut parser: Parser<GlobalsStruct, NodeStruct> =
{ Parser::new(&raw mut parser_tables_gram) };
parser.set_save_parse_tree(true);
- let mut initial_globals = GlobalsStruct { a: 0, b: 0 };
+ let mut initial_globals = GlobalsStruct { /*a: 0, b: 0*/ };
let result: Option<ParseNodeWrapper<'_, Parser<GlobalsStruct, NodeStruct>>> =
parser.parse(input_string, &mut initial_globals);
diff --git a/rust/example/src/my_grammar.g b/rust/example/src/my_grammar.g
index c2be3d8..ac50d59 100644
--- a/rust/example/src/my_grammar.g
+++ b/rust/example/src/my_grammar.g
@@ -1,22 +1,20 @@
{
-use dparser_lib;
#[derive(Debug, Default)]
pub struct GlobalsStruct {
- a: i32,
- b: i32,
}
#[derive(Debug, Default, Clone)]
pub struct NodeStruct {
x: i32,
- y: i32,
}
-
-pub const INDEX_OF_A:u32 = ${nterm A};
-
}
+test: (a | b)*;
+a: 'xx' $term 2;
+b: 'x' $term 1;
+
+/*
start: S T {
println!("start: S global a {} x {}", $g.a, $0.x);
*$$ = $0.clone();
@@ -63,3 +61,4 @@ T: U* {
};
U: 'u' | 'v';;
+*/