From 43ca3b1370fcb9e7cb8c3126ebf4e6ed7833fc13 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Fri, 25 Nov 2022 13:18:01 -0600 Subject: Se limpian comentarios --- compilador/parse/base.py | 25 +++++++++++++++++-------- compilador/parse/decl.py | 8 -------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/compilador/parse/base.py b/compilador/parse/base.py index 49742e6..9ee673b 100644 --- a/compilador/parse/base.py +++ b/compilador/parse/base.py @@ -15,9 +15,11 @@ class BaseParser: def __init__(self, iterador: NanoIter): self.iterador: NanoIter = iterador - ''' Requires the next token to have a matching ltok. Returns that - token, or an error. ''' def want(self, *want: Token) -> (LexToken | Error): + '''Requires the next token to have a matching ltok. Returns + that token, or an error. + + ''' tok: LexToken = self.lex() if len(want) == 0: return tok @@ -27,10 +29,12 @@ class BaseParser: return Error.syntax(tok.tipo, want, tok.numlinea) - ''' Looks for a matching ltok from the lexer, and if not present, - unlexes the token and returns void. If found, the token is - consumed from the lexer and is returned. ''' def _try(self, *want: Token) -> (LexToken | NoReturn): + '''Looks for a matching ltok from the lexer, and if not + present, unlexes the token and returns void. If found, the + token is consumed from the lexer and is returned. + + ''' tok: LexToken = self.lex() if len(want) == 0: return tok @@ -39,9 +43,11 @@ class BaseParser: return tok self.unlex() - ''' Looks for a matching ltok from the lexer, unlexes the token, - and returns it; or void if it was not an ltok. ''' def peek(self, *want: Token) -> (LexToken | NoReturn): + '''Looks for a matching ltok from the lexer, unlexes the + token, and returns it; or void if it was not an ltok. + + ''' tok: LexToken = self.iterador.peek() if len(want) == 0: return tok @@ -55,7 +61,10 @@ class BaseParser: def unlex(self): self.iterador.back() - ''' Returns a syntax error if cond is false and void otherwise ''' def synassert(self, cond: bool, msg: str) -> (Error | NoReturn): + '''Returns a syntax error if cond is false and void + otherwise. + + ''' if not cond: return Error(msg = msg) diff --git a/compilador/parse/decl.py b/compilador/parse/decl.py index 4a752f0..93666fc 100644 --- a/compilador/parse/decl.py +++ b/compilador/parse/decl.py @@ -58,12 +58,6 @@ class ParseDecl: if type(proto) is Error: return proto - # ; - # semicolon = self.parser.want(Token.SEMICOLON) - # if type(semicolon) is Error: - # return semicolon - # self.parser.unlex() - return DeclFunc(ident = ident, prototype = proto, body = None) @@ -96,8 +90,6 @@ class ParseDecl: def decls(self) -> (List[Decl] | Error): decls: List[Decl] = [] while not self.parser.peek(Token.EOF): - # print(self.parser.peek()) - # print(next(self.parser.iterador)) decl = self.decl() if type(decl) is Error: return decl -- cgit v1.2.3