aboutsummaryrefslogtreecommitdiff
path: root/compilador/ast/decl.py
diff options
context:
space:
mode:
Diffstat (limited to 'compilador/ast/decl.py')
-rw-r--r--compilador/ast/decl.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/compilador/ast/decl.py b/compilador/ast/decl.py
new file mode 100644
index 0000000..1c12162
--- /dev/null
+++ b/compilador/ast/decl.py
@@ -0,0 +1,26 @@
+from typing import Optional
+
+from type import Type
+from ident import Ident
+from expr import Expr
+
+# A global declaration.
+#
+# entero a = 0;
+@dataclass
+class DeclGlobal:
+ ident: Ident
+ _type: Type
+ init: Optional[Expr]
+
+# A function declaration.
+#
+# vacio main() { ... }
+@dataclass
+class DeclFunc:
+ ident: Ident
+ prototype: Type
+ body: Optional[Expr]
+
+# A Javañol declaration
+Decl = DeclGlobal | DeclFunc