aboutsummaryrefslogtreecommitdiff
path: root/mparser.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-06-02 14:25:35 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-06-02 14:25:35 +0300
commitb63c493844261e533edfcb30ca76d2f3412ae0cb (patch)
treeb8aeeeb8dacc61bbd3ea4dbacf1dad52d85b5068 /mparser.py
parentc3972d512a3d3da9b3c5442cde7ebef6740195e1 (diff)
downloadmeson-b63c493844261e533edfcb30ca76d2f3412ae0cb.zip
meson-b63c493844261e533edfcb30ca76d2f3412ae0cb.tar.gz
meson-b63c493844261e533edfcb30ca76d2f3412ae0cb.tar.bz2
Better error reporting for parsing errors.
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)