Fix wrong space at define macro usage
This commit is contained in:
parent
0ae50c97d6
commit
048e39755f
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.4.4...Unreleased) - ReleaseDate
|
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.4.4...Unreleased) - ReleaseDate
|
||||||
|
|
||||||
|
* [Fix] wrong space at define macro usage
|
||||||
|
|
||||||
## [v0.4.4](https://github.com/dalance/sv-parser/compare/v0.4.3...v0.4.4) - 2019-11-22
|
## [v0.4.4](https://github.com/dalance/sv-parser/compare/v0.4.3...v0.4.4) - 2019-11-22
|
||||||
|
|
||||||
* [Fix] \`resetall wrongly clear define list
|
* [Fix] \`resetall wrongly clear define list
|
||||||
|
@ -501,6 +501,8 @@ fn resolve_text_macro_usage<T: AsRef<Path>, U: AsRef<Path>>(
|
|||||||
}
|
}
|
||||||
// separator is required
|
// separator is required
|
||||||
replaced.push_str(" ");
|
replaced.push_str(" ");
|
||||||
|
// remove leading whitespace
|
||||||
|
replaced = String::from(replaced.trim_start());
|
||||||
|
|
||||||
let (replaced, new_defines) =
|
let (replaced, new_defines) =
|
||||||
preprocess_str(&replaced, path.as_ref(), &defines, include_paths)?;
|
preprocess_str(&replaced, path.as_ref(), &defines, include_paths)?;
|
||||||
@ -628,7 +630,7 @@ module a ();
|
|||||||
r##"
|
r##"
|
||||||
module a ();
|
module a ();
|
||||||
|
|
||||||
always @(posedge clk) begin if (!(!(a[i].b && c[i]))) begin $display ("xxx(()[]]{}}}", a[i].b, c[i])
|
always @(posedge clk) begin if (!(!(a[i].b && c[i]))) begin $display ("xxx(()[]]{}}}", a[i].b, c[i])
|
||||||
; end end ;
|
; end end ;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
@ -648,8 +650,8 @@ endmodule
|
|||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
$display("`HI, world");
|
$display("`HI, world");
|
||||||
$display( "`HI, world" );
|
$display("`HI, world" );
|
||||||
$display( "Hello, x" );
|
$display("Hello, x" );
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
"##
|
"##
|
||||||
@ -666,7 +668,7 @@ endmodule
|
|||||||
|
|
||||||
module a;
|
module a;
|
||||||
initial begin
|
initial begin
|
||||||
$display( "left side: \"right side\"" );
|
$display("left side: \"right side\"" );
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
"##
|
"##
|
||||||
|
@ -6,6 +6,7 @@ use std::{cmp, process};
|
|||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use sv_parser::parse_sv;
|
use sv_parser::parse_sv;
|
||||||
use sv_parser_error::ErrorKind;
|
use sv_parser_error::ErrorKind;
|
||||||
|
use sv_parser_pp::preprocess::preprocess;
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
@ -19,6 +20,10 @@ struct Opt {
|
|||||||
#[structopt(short = "t", long = "tree")]
|
#[structopt(short = "t", long = "tree")]
|
||||||
pub tree: bool,
|
pub tree: bool,
|
||||||
|
|
||||||
|
/// Show preprocesed text
|
||||||
|
#[structopt(short = "p", long = "pp")]
|
||||||
|
pub pp: bool,
|
||||||
|
|
||||||
/// Quiet
|
/// Quiet
|
||||||
#[structopt(short = "q", long = "quiet")]
|
#[structopt(short = "q", long = "quiet")]
|
||||||
pub quiet: bool,
|
pub quiet: bool,
|
||||||
@ -29,6 +34,15 @@ fn main() {
|
|||||||
let mut defines = HashMap::new();
|
let mut defines = HashMap::new();
|
||||||
let mut exit = 0;
|
let mut exit = 0;
|
||||||
for path in &opt.files {
|
for path in &opt.files {
|
||||||
|
if opt.pp {
|
||||||
|
match preprocess(&path, &defines, &opt.includes) {
|
||||||
|
Ok((preprocessed_text, new_defines)) => {
|
||||||
|
println!("{}", preprocessed_text.text());
|
||||||
|
defines = new_defines;
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
match parse_sv(&path, &defines, &opt.includes) {
|
match parse_sv(&path, &defines, &opt.includes) {
|
||||||
Ok((syntax_tree, new_defines)) => {
|
Ok((syntax_tree, new_defines)) => {
|
||||||
if opt.tree {
|
if opt.tree {
|
||||||
@ -53,6 +67,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
process::exit(exit);
|
process::exit(exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user