diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-11-25 21:29:55 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-11-25 21:29:55 -0600 |
commit | 6b27930ef9c3eaede8d0c283ffa8376c40145f80 (patch) | |
tree | e2f2f8a25defb68283910edea33768054f435bc9 /compilador/parse/expr.py | |
parent | 4b2fad150a292f882cee408d7f9746715225f7cb (diff) | |
download | javanol-6b27930ef9c3eaede8d0c283ffa8376c40145f80.tar.gz javanol-6b27930ef9c3eaede8d0c283ffa8376c40145f80.tar.bz2 javanol-6b27930ef9c3eaede8d0c283ffa8376c40145f80.zip |
¡Otra vez hay renderizador de AST!
Diffstat (limited to 'compilador/parse/expr.py')
-rw-r--r-- | compilador/parse/expr.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compilador/parse/expr.py b/compilador/parse/expr.py index 6608f6a..2401f30 100644 --- a/compilador/parse/expr.py +++ b/compilador/parse/expr.py @@ -33,7 +33,8 @@ class ParseExpr: error = self.parser.synassert( isinstance(obj, AccessExpr), - "Se esperaba un objeto como destino de la asignación.") + "Se esperaba un objeto como destino de la asignación.", + numlinea = tok.numlinea) if type(error) is Error: return error @@ -88,7 +89,7 @@ class ParseExpr: # Expresión expr = self.expr() if type(expr) is Error: - return epr + return expr args.append(expr) @@ -136,12 +137,10 @@ class ParseExpr: def constant(self) -> (Expr | Error): tok: LexToken = self.parser.lex() expr: Optional[ConstantExpr] = None - if tok.tipo == Token.STRING_LIT: - expr: str = tok.valor + if tok.tipo in [Token.STRING_LIT, Token.BOOLEAN_LIT]: + expr = Value(value = tok.valor) elif tok.tipo == Token.INT_LIT: expr = NumberConstant(value = tok.valor) - elif tok.tipo == Token.BOOLEAN_LIT: - expr: bool = tok.valor else: return Error(msg = "Se esperaba una constante.", numlinea = tok.numlinea) return expr @@ -260,7 +259,7 @@ class ParseExpr: if type(ident) is Error: return ident - return ReadExpr(expr = ident) + return ReadExpr(expr = AccessExpr(ident = ident)) def plain_expression(self) -> (Expr | Error): tok: LexToken = self.parser.peek() @@ -281,7 +280,7 @@ class ParseExpr: ident = ParseIdent(self.parser).ident() if type(ident) is Error: return ident - return ident + return AccessIdentifier(ident = ident) def unarithm(self) -> (Expr | Error): if self.parser._try(Token.L_BRACKET): |