diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-02 14:25:35 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-02 14:25:35 +0300 |
commit | b63c493844261e533edfcb30ca76d2f3412ae0cb (patch) | |
tree | b8aeeeb8dacc61bbd3ea4dbacf1dad52d85b5068 /mparser.py | |
parent | c3972d512a3d3da9b3c5442cde7ebef6740195e1 (diff) | |
download | meson-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.py | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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) |