summaryrefslogtreecommitdiff
path: root/src/mem/slicc/parser/parser.py
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2009-08-05 03:12:39 -0700
committerGabe Black <gblack@eecs.umich.edu>2009-08-05 03:12:39 -0700
commit60d4a0f6d7328b251797b14c33fd6766b95bc1ea (patch)
tree4bc10256a2c14de46f3c1b722f983a32607b8095 /src/mem/slicc/parser/parser.py
parentda2df2fc251440d0dbd91864d74ba94a2153ca5e (diff)
parentbd7af84d5ecd037fe4ab1a66948c51d23eb0eb0d (diff)
downloadgem5-60d4a0f6d7328b251797b14c33fd6766b95bc1ea.tar.xz
Merge with head.
Diffstat (limited to 'src/mem/slicc/parser/parser.py')
-rw-r--r--src/mem/slicc/parser/parser.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mem/slicc/parser/parser.py b/src/mem/slicc/parser/parser.py
index 1c7d582ec..c042ba2c1 100644
--- a/src/mem/slicc/parser/parser.py
+++ b/src/mem/slicc/parser/parser.py
@@ -100,8 +100,15 @@ t_SEMICOLON = r';'
t_ASSIGN = r':='
t_DOT = r'\.'
-class TokenError(Exception): pass
-class ParseError(Exception): pass
+class TokenError(Exception):
+ def __init__(self, msg, t):
+ super(TokenError, self).__init__(msg)
+ self.token = t
+
+class ParseError(Exception):
+ def __init__(self, msg, t):
+ super(ParseError, self).__init__(msg)
+ self.token = t
def t_error(t):
raise TokenError("Illegal character", t)
@@ -157,7 +164,7 @@ def p_file(p):
p[0] = [ x for x in p[1] if x is not None ]
def p_error(t):
- raise ParseError(t)
+ raise ParseError("Syntax error", t)
def p_empty(p):
"empty :"
@@ -544,7 +551,7 @@ def scan(filenames):
try:
results = yacc.parse(file(filename, 'r').read())
except (TokenError, ParseError), e:
- raise type(e), tuple([filename] + [ i for i in e ])
+ sys.exit("%s: %s:%d" % (e, filename, e.token.lineno))
for result in results:
result.add(hh, cc)