Skip to content

Commit

Permalink
Add support for 'is not' type test
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Aug 24, 2024
1 parent d9d162c commit e6179e8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [4.3.1] 2024-08-24

### Added
- Added support for "is not" type test

## [4.3.0] 2024-08-18

### Added
Expand Down
6 changes: 3 additions & 3 deletions gdtoolkit/parser/gdscript.lark
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ not_in_op: "not" "in"
!?pow_expr: type_test ("**" asless_type_test)*
| actual_type_cast ("**" asless_type_test)+
!?asless_pow_expr: asless_type_test ("**" asless_type_test)*
!?type_test: await_expr ("is" TYPE_HINT)*
| actual_type_cast ("is" TYPE_HINT)+
!?asless_type_test: await_expr ("is" TYPE_HINT)*
!?type_test: await_expr (("is" | "is not") TYPE_HINT)*
| actual_type_cast (("is" | "is not") TYPE_HINT)+
!?asless_type_test: await_expr (("is" | "is not") TYPE_HINT)*
!?await_expr: ("await")* call_expr
?call_expr: attr_expr
| (NAME | GET | SET) _call_arglist -> standalone_call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ class X:
var x = 1 is int is bool
var y = 1 is int is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool is bool
print([1,2.1] is Array[int])
var z = 1 is not int
var z1 = 1 is not int is not bool is not bool is not bool is not bool is not bool is not bool is not bool is not bool is not bool
14 changes: 14 additions & 0 deletions tests/formatter/input-output-pairs/type_test_expressions.out.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ class X:
is bool
)
print([1, 2.1] is Array[int])
var z = 1 is not int
var z1 = (
1
is not int
is not bool
is not bool
is not bool
is not bool
is not bool
is not bool
is not bool
is not bool
is not bool
)
1 change: 1 addition & 0 deletions tests/valid-gd-scripts/expressions.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func foo():
~8
5 ** 5
x is int
x is not int
x is Xyz # TODO: fix/remove x.Type
x is Zyx.Qwe # TODO: fix/remove x.Type
x.attr
Expand Down

0 comments on commit e6179e8

Please sign in to comment.