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