mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 23:30:00 -04:00
fix rewriter
This commit is contained in:
parent
f53bc623ff
commit
3462785c39
3 changed files with 89 additions and 8 deletions
31
rewriter/src/main.rs
Normal file
31
rewriter/src/main.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
#![allow(clippy::print_stdout)]
|
||||
use std::{env, path::Path};
|
||||
|
||||
use oxc_allocator::Allocator;
|
||||
use oxc_ast::{
|
||||
ast::{AssignmentTarget, Class, Function, IdentifierReference, MemberExpression, TSImportType},
|
||||
visit::walk,
|
||||
Visit,
|
||||
};
|
||||
use oxc_parser::Parser;
|
||||
use oxc_span::{SourceType, Span};
|
||||
use oxc_syntax::scope::ScopeFlags;
|
||||
|
||||
pub mod rewrite;
|
||||
|
||||
use rewrite::rewrite;
|
||||
|
||||
// Instruction:
|
||||
// create a `test.js`,
|
||||
// run `cargo run -p oxc_parser --example visitor`
|
||||
// or `cargo watch -x "run -p oxc_parser --example visitor"`
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let name = env::args().nth(1).unwrap_or_else(|| "test.js".to_string());
|
||||
let path = Path::new(&name);
|
||||
let source_text = std::fs::read_to_string(path)?;
|
||||
|
||||
println!("{}", rewrite(&source_text));
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue