-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added external rules to parse inline body's (ie blocks)
Still fails to parse the following: var p = func(): if true: pass else: pass
- Loading branch information
1 parent
86e8d44
commit 6f615af
Showing
5 changed files
with
370 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
take(func name(): | ||
print('hello') | ||
return 1 | ||
pass | ||
1 + 1 | ||
, | ||
"" | ||
) | ||
|
||
take(func name(): | ||
1 + 1; pass | ||
, "") | ||
|
||
take(func name(): | ||
pass | ||
pass, "") | ||
|
||
take(func name(): "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Verified with v4.0.beta17.official [c40020513] | ||
|
||
# FIXME: tree-sitter-gdscript can't parse this yet. | ||
var p = func(): if true: pass else: pass | ||
# If stmts can be inline. (They do not eval to their last expr.) | ||
t(func(): if true: 'string' else: 100) | ||
|
||
|
||
|
||
# GDScript v2 cannot parse this: | ||
#if true: print(1); print(2) else: print(3); print(4) | ||
|
||
# But, can parse this: | ||
# prints: | ||
# 1 | ||
# 2 | ||
var p = func(): if true: print(1); print(2) else: print(3); print(4) | ||
|
||
# prints: | ||
# outer 3 | ||
#var c = func(): if true: if false: print('inner 1'); print('inner 2') else: print('outer 3') else: print(4) | ||
|
||
# some whitespace handling between statement groups. | ||
# returns: 2 | ||
var x = func hello(): var b = 2; return b; | ||
|
||
if true: print('a') ; print('b'); | ||
else: print('c'); var a: int = 0; a + 1; return a | ||
# prints: | ||
# a | ||
# b | ||
|
||
# func bodies end at a comma. remaining args can follow. | ||
# no newline needed. | ||
take(func(): var a = 2; return x, 1) | ||
take(func(): | ||
print("hello world") | ||
pass, "") | ||
|
||
# func bodies also end at a paren. | ||
t(func(): | ||
print('hello') | ||
1 + 1) | ||
|
||
# These are valid. | ||
t(func(): | ||
pass | ||
) | ||
|
||
t( | ||
func(): pass, | ||
func(): | ||
pass | ||
) | ||
|
||
# types can be specified | ||
var d = func(hello: int, string: String) -> int: | ||
return string.length() + hello | ||
|
||
t(func name(a: int, b: int) -> int: return a + b) | ||
t(func name(a: int, b: int) -> int: | ||
return a + b, "last argument") |
Oops, something went wrong.