From be52c75ea9dfbbdedf4a8cd1f5df82c2d60fb9d5 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 22 Aug 2008 22:19:49 -0300 Subject: [PATCH] Renombrar SyntaxError por ParserError para que no se pise con Python --- taller/ejercicios/ej1-20082/tp.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/taller/ejercicios/ej1-20082/tp.py b/taller/ejercicios/ej1-20082/tp.py index 413f2ae..79c9b2c 100755 --- a/taller/ejercicios/ej1-20082/tp.py +++ b/taller/ejercicios/ej1-20082/tp.py @@ -96,7 +96,7 @@ class Message: # Fin "AST" -class SyntaxError(Exception): +class ParserError(Exception): pass def skip(str, to_skip, current=None, val=''): @@ -113,7 +113,7 @@ def parse_attr(str): return (None, str) (tok, val, str) = skip(str, SP, tok, val) if tok != ID and tok != ARR: - raise SyntaxError('ID or ARR expected, got %s' % tokstr[tok]) + raise ParserError('ID or ARR expected, got %s' % tokstr[tok]) # tipo is_array = False if tok == ARR: @@ -122,15 +122,15 @@ def parse_attr(str): # sp (tok, val, str) = tokenize(str) if tok != SP: - raise SyntaxError('SP expected, got %s' % tokstr[tok]) + raise ParserError('SP expected, got %s' % tokstr[tok]) (tok, val, str) = skip(str, SP, tok, val) # nombre if tok != ID: - raise SyntaxError('ID expected, got %s' % tokstr[tok]) + raise ParserError('ID expected, got %s' % tokstr[tok]) attr = Attr(type_name, is_array, val) (tok, val, str) = skip(str, SP) if tok != EOL: - raise SyntaxError('EOL expected, got %s' % tokstr[tok]) + raise ParserError('EOL expected, got %s' % tokstr[tok]) return (attr, str) def parse_message(str): @@ -139,12 +139,12 @@ def parse_message(str): if tok == EOF: return (None, str) elif tok != ID: - raise SyntaxError('ID expected, got %s' % tokstr[tok]) + raise ParserError('ID expected, got %s' % tokstr[tok]) msg = Message(val) dprint('parse_message(): msg = %s', msg) (tok, val, str) = skip(str, SP) if tok != EOL: - raise SyntaxError('EOL expected, got %s' % tokstr[tok]) + raise ParserError('EOL expected, got %s' % tokstr[tok]) # ya tengo EOL, vienen atributos (o fin de mensaje) (attr, str) = parse_attr(str) while attr: -- 2.43.0