hoa: add some error recovery
* src/hoaparse/hoaparse.yy: Here. * src/tgbatest/hoaparse.test: More tests.
This commit is contained in:
parent
4043ad2ccf
commit
1c8b58d69f
2 changed files with 93 additions and 7 deletions
|
|
@ -144,6 +144,16 @@ hoa: header "--BODY--" body "--END--"
|
|||
res.h->loc = @$;
|
||||
YYACCEPT;
|
||||
}
|
||||
hoa: error "--END--"
|
||||
{
|
||||
res.h->loc = @$;
|
||||
YYACCEPT;
|
||||
}
|
||||
hoa: error ENDOFFILE
|
||||
{
|
||||
res.h->loc = @$;
|
||||
YYACCEPT;
|
||||
}
|
||||
hoa: ENDOFFILE { YYABORT; }
|
||||
|
||||
string_opt: | STRING
|
||||
|
|
@ -173,12 +183,18 @@ header: format-version header-items
|
|||
}
|
||||
}
|
||||
|
||||
format-version: "HOA:" { res.h->loc = @1; } IDENTIFIER
|
||||
{
|
||||
if (*$3 != "v1")
|
||||
error(@$, "unsupported version of the HOA format");
|
||||
delete $3;
|
||||
}
|
||||
version: IDENTIFIER
|
||||
{
|
||||
if (*$1 != "v1")
|
||||
error(@$, "unsupported version of the HOA format");
|
||||
delete $1;
|
||||
}
|
||||
|
||||
format-version: "HOA:" { res.h->loc = @1; } version
|
||||
| error "HOA:"
|
||||
{ error(@1, "ignoring leading garbage");
|
||||
res.h->loc = @2; }
|
||||
version
|
||||
|
||||
header-items: | header-items header-item
|
||||
header-item: "States:" INT
|
||||
|
|
@ -295,6 +311,7 @@ header-item: "States:" INT
|
|||
" be ignored)");
|
||||
delete $1;
|
||||
}
|
||||
| error
|
||||
|
||||
ap-names: | ap-names ap-name
|
||||
ap-name: STRING
|
||||
|
|
@ -500,6 +517,8 @@ state: state-name labeled-edges
|
|||
res.cur_guard = res.guards.begin();
|
||||
}
|
||||
}
|
||||
| error
|
||||
|
||||
state-name: "State:" state-label_opt checked-state-num string_opt acc-sig_opt
|
||||
{
|
||||
res.cur_state = $3;
|
||||
|
|
@ -517,6 +536,11 @@ label: '[' label-expr ']'
|
|||
res.cur_label = bdd_from_int($2);
|
||||
bdd_delref($2);
|
||||
}
|
||||
| '[' error ']'
|
||||
{
|
||||
error(@$, "ignoring this invalid label");
|
||||
res.cur_label = bddtrue;
|
||||
}
|
||||
state-label_opt: { res.has_state_label = false; }
|
||||
| label { res.has_state_label = true;
|
||||
res.state_label_loc = @1;
|
||||
|
|
@ -547,6 +571,10 @@ acc-sig_opt:
|
|||
res.ignore_acc_silent = true;
|
||||
}
|
||||
}
|
||||
| '{' error '}'
|
||||
{
|
||||
error(@$, "ignoring this invalid acceptance set");
|
||||
}
|
||||
acc-sets:
|
||||
{
|
||||
$$ = spot::acc_cond::mark_t(0U);
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ EOF
|
|||
expecterr input <<EOF
|
||||
input:5.19: number is larger than the count of acceptance sets...
|
||||
input:5.1-13: ... declared here.
|
||||
input:12.1-7: unsupported version of the HOA format
|
||||
input:12.6-7: unsupported version of the HOA format
|
||||
input:12.1-7: missing 'Acceptance:' header
|
||||
EOF
|
||||
|
||||
|
|
@ -560,3 +560,61 @@ State: 1
|
|||
EOF
|
||||
|
||||
diff expected input.out
|
||||
|
||||
|
||||
# Error recovery
|
||||
|
||||
cat >input <<EOF
|
||||
HOA: v1
|
||||
States: 2
|
||||
Start: 0
|
||||
AP: 0
|
||||
acc-name: Buchi
|
||||
Acceptance: 1 Inf(0)
|
||||
--BODY--
|
||||
State: 0 {a} /* not a digit */
|
||||
[t] 1
|
||||
State: 1
|
||||
[a] 0 /* not a digit */
|
||||
--END--
|
||||
HOA: v1
|
||||
Acceptance: 1 Inf(0)
|
||||
States: 2
|
||||
Start: 0
|
||||
AP: 0
|
||||
acc-name: Buchi
|
||||
--BODY--
|
||||
State: 0 {0}
|
||||
[t] "f" 1 /* WTF? */
|
||||
State: 1
|
||||
[t] 0
|
||||
--END--
|
||||
some garbage HOA: v1
|
||||
Acceptance: 1 Inf(0)
|
||||
States: 2
|
||||
Start: 0
|
||||
AP: 0
|
||||
acc-name: Buchi
|
||||
--BODY--
|
||||
Stat: 0 {0} /* not State: */
|
||||
[t] 1
|
||||
State: 1
|
||||
[t] 0
|
||||
--END--
|
||||
this is complete garbage!
|
||||
--END--
|
||||
and even more garbage
|
||||
EOF
|
||||
|
||||
expecterr input <<EOF
|
||||
input:8.11: syntax error, unexpected identifier, expecting integer or '}'
|
||||
input:8.10-12: ignoring this invalid acceptance set
|
||||
input:11.2: syntax error, unexpected identifier
|
||||
input:11.1-3: ignoring this invalid label
|
||||
input:21.5-7: syntax error, unexpected string, expecting integer
|
||||
input:25.1-4: syntax error, unexpected identifier, expecting end of file or HOA:
|
||||
input:25.1-12: ignoring leading garbage
|
||||
input:32.1-5: syntax error, unexpected header name, expecting --END-- or State:
|
||||
input:37.1-4: syntax error, unexpected identifier, expecting end of file or HOA:
|
||||
input:39.1-3: syntax error, unexpected identifier, expecting end of file or HOA:
|
||||
EOF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue