fix(binary/parse): Actually only perform the other steps, if asked for it
Otherwise, the lexing functionality becomes useless, if the Trixy file can't be parsed and processed.
This commit is contained in:
parent
508dc2bc46
commit
4e3bdf273e
|
@ -33,24 +33,26 @@ use crate::cli::ParseCommand;
|
||||||
pub fn handle(parse_command: ParseCommand, api_file: &Path) {
|
pub fn handle(parse_command: ParseCommand, api_file: &Path) {
|
||||||
let input = fs::read_to_string(api_file).unwrap();
|
let input = fs::read_to_string(api_file).unwrap();
|
||||||
|
|
||||||
let input_tokens = tokenize(&input);
|
|
||||||
let parsed = parse_unchecked(input_tokens.clone());
|
|
||||||
let processed = process(parsed.clone(), input.clone());
|
|
||||||
|
|
||||||
match parse_command {
|
match parse_command {
|
||||||
// These also map the path the file undergoes when it is put into the [`parse_trixy_lang`]
|
// These also map the path the file undergoes when it is put into the [`parse_trixy_lang`]
|
||||||
// function.
|
// function.
|
||||||
ParseCommand::Replace => {
|
ParseCommand::Replace => {
|
||||||
let parsed = TokenStream::replace(&input);
|
let replaced = TokenStream::replace(&input);
|
||||||
println!("{}", parsed);
|
println!("{}", replaced);
|
||||||
}
|
}
|
||||||
ParseCommand::Tokenize => {
|
ParseCommand::Tokenize => {
|
||||||
println!("{:#?}", input_tokens);
|
let tokenized = tokenize(&input);
|
||||||
|
println!("{:#?}", tokenized);
|
||||||
}
|
}
|
||||||
ParseCommand::Parse => {
|
ParseCommand::Parse => {
|
||||||
|
let tokenized = tokenize(&input);
|
||||||
|
let parsed = parse_unchecked(tokenized);
|
||||||
println!("{:#?}", parsed);
|
println!("{:#?}", parsed);
|
||||||
}
|
}
|
||||||
ParseCommand::Process => {
|
ParseCommand::Process => {
|
||||||
|
let tokenized = tokenize(&input);
|
||||||
|
let parsed = parse_unchecked(tokenized);
|
||||||
|
let processed = process(parsed, input);
|
||||||
println!("{:#?}", processed);
|
println!("{:#?}", processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue