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