aboutsummaryrefslogtreecommitdiff
path: root/mparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'mparser.py')
-rw-r--r--mparser.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mparser.py b/mparser.py
index 27bec58..d13a1f0 100644
--- a/mparser.py
+++ b/mparser.py
@@ -17,6 +17,12 @@
import ply.lex as lex
import ply.yacc as yacc
import nodes
+from coredata import MesonException
+
+class ParserException(MesonException):
+ def __init__(self, text, lineno):
+ MesonException.__init__(self, text)
+ self.lineno = lineno
reserved = {'true' : 'TRUE',
'false' : 'FALSE',
@@ -90,8 +96,7 @@ def t_EOL_CONTINUE(t):
t.lexer.lineno += 1
def t_error(t):
- print("Illegal character '%s'" % t.value[0])
- t.lexer.skip(1)
+ raise ParserException("Illegal character '%s'." % t.value[0], t.lineno)
# Yacc part
@@ -228,7 +233,7 @@ def p_error(t):
txt = 'NONE'
else:
txt = t.value
- print('Parser errored out at: ' + txt)
+ raise ParserException('Parser errored out at: %s.' % txt, t.lineno)
def test_lexer():
s = """hello = (something) # this = (that)