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 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'compilador/parse/base.py') 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) -- cgit v1.2.3