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:
Benedikt Peetz 2024-03-27 08:10:33 +01:00
parent 508dc2bc46
commit 4e3bdf273e
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
1 changed files with 9 additions and 7 deletions

View File

@ -33,24 +33,26 @@ use crate::cli::ParseCommand;
pub fn handle(parse_command: ParseCommand, api_file: &Path) {
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 {
// These also map the path the file undergoes when it is put into the [`parse_trixy_lang`]
// function.
ParseCommand::Replace => {
let parsed = TokenStream::replace(&input);
println!("{}", parsed);
let replaced = TokenStream::replace(&input);
println!("{}", replaced);
}
ParseCommand::Tokenize => {
println!("{:#?}", input_tokens);
let tokenized = tokenize(&input);
println!("{:#?}", tokenized);
}
ParseCommand::Parse => {
let tokenized = tokenize(&input);
let parsed = parse_unchecked(tokenized);
println!("{:#?}", parsed);
}
ParseCommand::Process => {
let tokenized = tokenize(&input);
let parsed = parse_unchecked(tokenized);
let processed = process(parsed, input);
println!("{:#?}", processed);
}