authorgravatar for 11367844+lino-levan@users.noreply.github.comLino Le Van <11367844+lino-levan@users.noreply.github.com> 2024-01-19 13:38:35-08:00
committergravatar for 11367844+lino-levan@users.noreply.github.comLino Le Van <11367844+lino-levan@users.noreply.github.com> 2024-01-19 13:38:35-08:00
loge6c1cd9d28b728ce488ac72bcbe6d9ce0a212f8d
treecc9768c5b3be12af5ff8b4decd257f4b5b90c8b3
parentb948c0d8067250014cfa286538e49c419d0acb93

chore: move project forward


3 files changed, 37 insertions(+), 15 deletions(-)

crates/cli/src/main.rs+17-14
......@@ -66,7 +66,11 @@ fn main() -> Result<()> {
6666 let cli = Cli::parse();
6767
6868 match cli.command {
69 Commands::Compile { file, stdout, target: _ } => {
69 Commands::Compile {
70 file,
71 stdout,
72 target: _,
73 } => {
7074 let contents = std::fs::read_to_string(file.clone()).unwrap();
7175 let result = transpile(contents.clone())?;
7276
......@@ -85,35 +89,34 @@ fn main() -> Result<()> {
8589
8690 let rt = get_runtime(&target);
8791
88 match rt.as_str() {
92 let command = match rt.as_str() {
8993 "deno" => {
90 let output = std::process::Command::new("deno")
94 std::process::Command::new("deno")
9195 .arg("run")
9296 .arg("-A")
9397 .arg(temp_file)
94 .output()
95 .expect("Failed to execute process");
96 println!("{}", String::from_utf8_lossy(&output.stdout));
98 .spawn()
99 .expect("Failed to execute process")
97100 }
98101 "node" => {
99 let output = std::process::Command::new("node")
102 std::process::Command::new("node")
100103 .arg(temp_file)
101 .output()
102 .expect("Failed to execute process");
103 println!("{}", String::from_utf8_lossy(&output.stdout));
104 .spawn()
105 .expect("Failed to execute process")
104106 }
105107 "bun" => {
106 let output = std::process::Command::new("bun")
108 std::process::Command::new("bun")
107109 .arg("run")
108110 .arg(temp_file)
109 .output()
110 .expect("Failed to execute process");
111 println!("{}", String::from_utf8_lossy(&output.stdout));
111 .spawn()
112 .expect("Failed to execute process")
112113 }
113114 _ => {
114115 println!("Unknown runtime: {}", target);
115116 }
116117 }
118
119 command.wait().unwrap();
117120 }
118121 }
119122
crates/tokenizer/src/lib.rs+14-1
......@@ -138,7 +138,20 @@ pub fn tokenize(content: String) -> Result<Vec<Token>> {
138138 _ => tokens.push(Token::Equals),
139139 },
140140 ';' => tokens.push(Token::Semicolon),
141 '>' => tokens.push(Token::Operator(Operator::GreaterThan)),
141 '>' => match chars.peek() {
142 Some((_, '=')) => {
143 chars.next();
144 tokens.push(Token::Operator(Operator::GreaterThanOrEquals));
145 }
146 _ => tokens.push(Token::Operator(Operator::GreaterThan)),
147 },
148 '<' => match chars.peek() {
149 Some((_, '=')) => {
150 chars.next();
151 tokens.push(Token::Operator(Operator::LessThanOrEquals));
152 }
153 _ => tokens.push(Token::Operator(Operator::LessThan)),
154 },
142155 '+' => tokens.push(Token::Operator(Operator::Add)),
143156 '-' => match chars.peek() {
144157 Some((_, '>')) => {
crates/util/src/lib.rs+6
......@@ -7,6 +7,9 @@ pub enum Operator {
77 Power,
88 Equals,
99 GreaterThan,
10 LessThan,
11 GreaterThanOrEqual,
12 LessThanOrEqual,
1013}
1114
1215impl Operator {
......@@ -19,6 +22,9 @@ impl Operator {
1922 Self::Power => "**",
2023 Self::Equals => "===",
2124 Self::GreaterThan => ">",
25 Self::LessThan => "<",
26 Self::GreaterThanOrEqual => ">=",
27 Self::LessThanOrEqual => "<=",
2228 })
2329 }
2430}