summaryrefslogtreecommitdiff
path: root/src/parser.rs
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-28 11:46:19 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-28 11:52:48 +0800
commit8306b2c99a6af2b22732c612cbd9b202ddc1251f (patch)
treee917793726c1ad75f56617e17fc201dbf812ace9 /src/parser.rs
parentf36abead9d948b65abc87c0aea43bbfa987442da (diff)
fix(parser, tokenizer): println and throw startswith instead of whole str
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/parser.rs b/src/parser.rs
index fbeacc5..8e2b63c 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -75,7 +75,17 @@ pub fn process(strs: SplitWithMetadata<'_>) -> Vec<Expr<'_>> {
// TODO: fix one line if else as not delimited by {}
for s in str.split_whitespace() {
- if let Some(token) = tokenizer::parse(s) {
+ if let Some(token) = tokenizer::parse(if let len = s.len() {
+ if s.starts_with("println") {
+ "println"
+ } else if s.starts_with("throw") {
+ "throw"
+ } else {
+ s
+ }
+ } else {
+ s
+ }) {
match token {
If(t) => {
if let Some(ExprT::Decision((_, Scope::If(If::Else)))) = exp {