feat(parser/bin): Allow `lex` as an alias to `tokenize`

This commit is contained in:
Benedikt Peetz 2024-03-24 19:28:27 +01:00
parent a4513e8c51
commit 21b0ce1c01
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
1 changed files with 9 additions and 1 deletions

View File

@ -51,6 +51,14 @@ pub enum Command {
/// The file containing the trixy code to tokenize
file: PathBuf,
},
#[clap(value_parser)]
/// Only try to tokenize the file
Lex {
#[clap(value_parser)]
/// The file containing the trixy code to tokenize
file: PathBuf,
},
/// Check syntax, without type checking
Parse {
#[clap(value_parser)]
@ -75,7 +83,7 @@ pub enum Command {
pub fn main() {
let args = Args::parse();
match args.subcommand {
Command::Tokenize { file } => {
Command::Tokenize { file } | Command::Lex { file } => {
let input = fs::read_to_string(file).unwrap();
let input_tokens = match TokenStream::lex(&input) {