From fb014cc35a50ff0487973446aaa67224d2343f19 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 8 Aug 2003 13:16:39 +0000 Subject: [PATCH] * src/ltlparse/ltlparse.yy: Handle and diagnose mismatched parentheses. * src/ltltest/parseerr.test: Add some examples. --- ChangeLog | 9 +++++++-- src/ltlparse/ltlparse.yy | 14 +++++++++++--- src/ltltest/parseerr.test | 6 ++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19532d0b4..918e1ec74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,16 @@ -2003-08-07 Alexandre Duret-Lutz +2003-08-08 Alexandre Duret-Lutz + + * src/ltlparse/ltlparse.yy: Handle and diagnose mismatched parentheses. + * src/ltltest/parseerr.test: Add some examples. + +2003-08-07 Alexandre Duret-Lutz * wrap/python/cgi/ltl2tgba.in: Convert GIFs to PNGs. Restrict the size of dot's output to 1024x1024. * src/tgbaalgos/dotty.cc (dotty_bfs::start): Do not preset the size of the graph. Set height=0 for the invisible state. -2003-08-06 Alexandre Duret-Lutz +2003-08-06 Alexandre Duret-Lutz * src/ltlparse/ltlparse.yy: Fix precedence OP_OR < OP_XOR < OP_AND. * src/ltlast/binop.cc (binop::instance): Order operands for diff --git a/src/ltlparse/ltlparse.yy b/src/ltlparse/ltlparse.yy index 72fa09af6..ac35a3b17 100644 --- a/src/ltlparse/ltlparse.yy +++ b/src/ltlparse/ltlparse.yy @@ -120,11 +120,19 @@ subformula: ATOMIC_PROP "treating this parenthetical block as false")); $$ = constant::false_instance(); } - | PAR_OPEN subformula many_errors PAR_CLOSE - { error_list.push_back(parse_error(@3, - "unexpected input ignored")); + | PAR_OPEN subformula many_errors_diagnosed PAR_CLOSE + { $$ = $2; } + | PAR_OPEN subformula many_errors_diagnosed END_OF_INPUT + { error_list.push_back(parse_error(@1 + @2, + "missing closing parenthesis")); $$ = $2; } + | PAR_OPEN many_errors_diagnosed END_OF_INPUT + { error_list.push_back(parse_error(@$, + "missing closing parenthesis, " + "treating this parenthetical block as false")); + $$ = constant::false_instance(); + } | OP_NOT subformula { $$ = unop::instance(unop::Not, $2); } | subformula OP_AND subformula diff --git a/src/ltltest/parseerr.test b/src/ltltest/parseerr.test index a00618ac8..01f1619f1 100755 --- a/src/ltltest/parseerr.test +++ b/src/ltltest/parseerr.test @@ -51,3 +51,9 @@ check 'a U (b c) U e R (f g <=> h)' \ 'binop(R, binop(U, binop(U, AP(a), AP(b)), AP(e)), AP(f))' check 'a U ((c) U e) R (<=> f g)' \ 'binop(R, binop(U, AP(a), binop(U, AP(c), AP(e))), constant(0))' + +# Missing parentheses +check 'a & (a + b' 'multop(And, AP(a), multop(Or, AP(a), AP(b)))' +check 'a & (a + b c' 'multop(And, AP(a), multop(Or, AP(a), AP(b)))' +check 'a & (+' 'multop(And, constant(0), AP(a))' +check 'a & (' 'multop(And, constant(0), AP(a))'