Skip to content

Commit 236a9bc

Browse files
committed
feat: inline if statements
1 parent 0eee0a9 commit 236a9bc

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

.vscode/launch.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "lldb",
6+
"request": "launch",
7+
"name": "Debug script.tsh",
8+
"cargo": {
9+
"args": [
10+
"build",
11+
"--bin=lang_cli",
12+
"--package=lang_cli"
13+
],
14+
"filter": {
15+
"name": "lang_cli",
16+
"kind": "bin"
17+
}
18+
},
19+
"args": [
20+
"script.tsh"
21+
],
22+
"cwd": "${workspaceFolder}"
23+
},
24+
{
25+
"type": "node-terminal",
26+
"name": "JavaScript Debug Terminal",
27+
"request": "launch",
28+
"cwd": "${workspaceFolder}"
29+
}
30+
]
31+
}

packages/engine/src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl<'a> Parser<'a> {
252252
}
253253

254254
fn parse_inline_block(&mut self) -> ParserResult<WithCursor<Block>> {
255-
let Some(next) = self.next() else {
255+
let Some(next) = self.peek().cloned() else {
256256
return Err(ParserErrorKind::ExpectedStatement);
257257
};
258258

script.tsh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
var test
2-
3-
if a {
4-
test = 5
5-
} else if true {
6-
test = 10
7-
} else {
8-
test = 15
9-
}
10-
11-
var cool = test - 10
1+
if true: test = 5
2+
else if false: test = 10
3+
else: test = 15

0 commit comments

Comments
 (0)