aboutsummaryrefslogtreecommitdiff
path: root/compilador/astree
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-25 19:07:58 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-25 19:07:58 -0600
commit4b2fad150a292f882cee408d7f9746715225f7cb (patch)
treefe02aa65491aeec869e5c5427e2229fc1633bbf7 /compilador/astree
parentea2d6ab3cc66e69d423e502407f272f634c3e070 (diff)
downloadjavanol-4b2fad150a292f882cee408d7f9746715225f7cb.tar.gz
javanol-4b2fad150a292f882cee408d7f9746715225f7cb.tar.bz2
javanol-4b2fad150a292f882cee408d7f9746715225f7cb.zip
Se añade `retornar', `detener' y `continuar'
Diffstat (limited to 'compilador/astree')
-rw-r--r--compilador/astree/expr.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/compilador/astree/expr.py b/compilador/astree/expr.py
index c074553..527e606 100644
--- a/compilador/astree/expr.py
+++ b/compilador/astree/expr.py
@@ -49,6 +49,13 @@ class BinarithmExpr:
lvalue: Expr
rvalue: Expr
+# A break expression.
+#
+# detener
+@dataclass
+class BreakExpr:
+ pass
+
# A function call expression.
#
# foo(bar)
@@ -68,6 +75,13 @@ class CallExpr:
class CompoundExpr:
exprs: List[Expr]
+# A continue expression.
+#
+# continuar
+@dataclass
+class ContinueExpr:
+ pass
+
# A scalar value.
Value = bool | str | int | type(None)
@@ -115,7 +129,9 @@ class ReadExpr:
# A return statement.
#
# retorna a
-ReturnExpr = Optional[Expr]
+@dataclass
+class ReturnExpr:
+ expr: Optional[Expr]
# A while expression.
#
@@ -126,6 +142,7 @@ class WhileExpr:
body: Expr
# A Javañol expression.
-Expr = (AccessExpr | AssignExpr | BinarithmExpr | CallExpr |
- ConstantExpr | ForExpr | IfExpr | CompoundExpr |
- PrintExpr | ReadExpr | ReturnExpr)
+Expr = (AccessExpr | AssignExpr | BinarithmExpr | BreakExpr |
+ CallExpr | ConstantExpr | ContinueExpr | ForExpr |
+ IfExpr | CompoundExpr | PrintExpr | ReadExpr |
+ ReturnExpr)