From 7a03228880ae2b1fcd66f80f6474512e8564319d Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 21 Nov 2014 11:05:24 +0100 Subject: [PATCH] hoa: add alias support * src/hoaparse/hoaparse.yy: Here. * src/tgbatest/hoaparse.test: Test it. --- src/hoaparse/hoaparse.yy | 22 +++++++++++-- src/tgbatest/hoaparse.test | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 3 deletions(-) diff --git a/src/hoaparse/hoaparse.yy b/src/hoaparse/hoaparse.yy index c45340bba..19b97cd69 100644 --- a/src/hoaparse/hoaparse.yy +++ b/src/hoaparse/hoaparse.yy @@ -32,6 +32,7 @@ #include #include #include +#include #include "ltlast/constant.hh" #include "public.hh" @@ -48,6 +49,7 @@ std::vector guards; std::vector::const_iterator cur_guard; std::vector declared_states; // States that have been declared. + std::unordered_map alias; spot::location states_loc; spot::location ap_loc; spot::location state_label_loc; @@ -238,6 +240,12 @@ header-item: "States:" INT } | "Alias:" ANAME label-expr { + if (!res.alias.emplace(*$2, bdd_from_int($3)).second) + { + std::ostringstream o; + o << "ignoring redefinition of alias @" << *$2; + error(@$, o.str()); + } delete $2; bdd_delref($3); } @@ -352,10 +360,18 @@ label-expr: 't' } | ANAME { + auto i = res.alias.find(*$1); + if (i == res.alias.end()) + { + error(@$, "unknown alias @" + *$1); + $$ = 1; + } + else + { + $$ = i->second.id(); + bdd_addref($$); + } delete $1; - error(@1, "aliases are not yet supported"); - YYABORT; - $$ = 0; } | '!' label-expr { diff --git a/src/tgbatest/hoaparse.test b/src/tgbatest/hoaparse.test index df3cc96f3..a263dde06 100755 --- a/src/tgbatest/hoaparse.test +++ b/src/tgbatest/hoaparse.test @@ -322,3 +322,67 @@ EOF expecterr input <input <input <