feat(parser/bin): Allow `lex` as an alias to `tokenize`
This commit is contained in:
parent
a4513e8c51
commit
21b0ce1c01
|
@ -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) {
|
||||||
|
|
Reference in New Issue