Skip to content

Commit a1b8ea7

Browse files
committed
most of expressions handled
1 parent 7ae1d75 commit a1b8ea7

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

gdscript.lark

+14-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,20 @@ comparison: bitw_or (comp_op bitw_or)*
6060
comp_op: ">" | "<" | "==" | "!=" | "<=" | ">="
6161
bitw_or: bitw_xor ("|" bitw_xor)*
6262
bitw_xor: bitw_and ("^" bitw_and)*
63-
bitw_and: atom ("&" atom)*
64-
atom: NAME | literal
63+
bitw_and: shift_expr ("&" shift_expr)*
64+
shift_expr: subtr_expr (("<<"|">>") subtr_expr)*
65+
subtr_expr: addn_expr ("-" addn_expr)*
66+
addn_expr: mdr_expr ("+" mdr_expr)*
67+
mdr_expr: neg_expr (("*" | "/" | "%") neg_expr)*
68+
neg_expr: "-" neg_expr | bitw_not
69+
bitw_not: "~" bitw_not | type_test
70+
type_test: attr_expr ("is" atom)*
71+
attr_expr: subscr_expr ("." NAME)*
72+
subscr_expr: call_expr ["[" atom "]"] // TODO: expr inside []
73+
call_expr: atom ["(" ")"] // TODO: expr(s,) inside ()
74+
atom: "(" expr ")"
75+
| NAME
76+
| literal
6577
literal: NUMBER
6678

6779
TYPE: NAME

makefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
all:
2+
pytest -v

scripts/expressions.gd

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
func bar():
2+
pass
13
func foo():
24
var x
35
1 if true else 2
@@ -17,3 +19,17 @@ func foo():
1719
3 | 3
1820
6 ^ 5
1921
8 & 7
22+
5 >> 7
23+
7 << 5
24+
5 - 6
25+
6 + 7
26+
7 * 7
27+
7 / 8
28+
6 % 3
29+
-8
30+
~8
31+
x is int
32+
x.attr
33+
x[10]
34+
bar()
35+
(2+2)

0 commit comments

Comments
 (0)