dsl: add 'int ;' declarations

This commit is contained in:
Alex Bates 2021-02-06 05:20:19 +00:00
parent 51ec14b78d
commit 3e2a5c20f9

View File

@ -39,6 +39,7 @@ script_parser = Lark(r"""
| stmt_no_semi
?stmt: call
| var_decl
| "goto" label -> label_goto
| "return" -> return_stmt
| "break" -> break_stmt
@ -103,6 +104,8 @@ script_parser = Lark(r"""
loop_stmt: "loop" [expr] block
loop_until_stmt: "loop" block "until" "(" expr cond_op expr ")"
var_decl: ("int"|"float") variable
?expr: c_const_expr
| ESCAPED_STRING
| SIGNED_INT
@ -597,6 +600,9 @@ class Compile(Transformer):
name = tree.children[0]
return self.alloc.variables.index(name) - 30000000
def var_decl(self, tree):
return []
def label_decl(self, tree):
if len(tree.children) == 1:
label = tree.children[0]