mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 15:03:46 +00:00
Move minimize logging to a new dump_syntax target
This commit is contained in:
parent
c85c864b5f
commit
b7ab25ee2e
2 changed files with 33 additions and 4 deletions
32
crates/compiler/test_syntax/src/bin/dump_syntax.rs
Normal file
32
crates/compiler/test_syntax/src/bin/dump_syntax.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
//! Dump a syntax tree for a given input file.
|
||||
//!
|
||||
//! Typical usage:
|
||||
//! `cargo run --bin dump_syntax -- full file.roc`
|
||||
|
||||
use bumpalo::Bump;
|
||||
use test_syntax::test_helpers::InputKind;
|
||||
|
||||
fn main() {
|
||||
let args = std::env::args().collect::<Vec<String>>();
|
||||
if args.len() != 3 {
|
||||
eprintln!("Usage: {} [expr|full|moduledefs|header] <input>", args[0]);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let kind = match args[1].as_str() {
|
||||
"expr" => InputKind::Expr,
|
||||
"full" => InputKind::Full,
|
||||
"moduledefs" => InputKind::ModuleDefs,
|
||||
"header" => InputKind::Header,
|
||||
_ => {
|
||||
eprintln!("Invalid input kind: {}", args[1]);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let text = std::fs::read_to_string(&args[2]).unwrap();
|
||||
let input = kind.with_text(&text);
|
||||
let arena = Bump::new();
|
||||
let output = input.parse_in(&arena);
|
||||
println!("{:#?}", output);
|
||||
}
|
|
@ -102,10 +102,7 @@ fn round_trip_once(input: Input<'_>, options: Options) -> Option<String> {
|
|||
let arena = Bump::new();
|
||||
|
||||
let actual = match input.parse_in(&arena) {
|
||||
Ok(a) => {
|
||||
println!("actual {a:#?}");
|
||||
a
|
||||
}
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
if options.minimize_initial_parse_error {
|
||||
return Some(format!("Initial parse failed: {:?}", e.normalize(&arena)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue