let rec check_gram entry =
function
| Snterm e ->
if ( != ) e.egram entry.egram
then
(eprintf
"Error: entries \"%s\" and \"%s\" do not belong to the same grammar.\n"
entry.ename e.ename;
flush Pervasives.stderr;
failwith "Grammar.extend error")
else ()
| Snterml (e, _) ->
if ( != ) e.egram entry.egram
then
(eprintf
"Error: entries \"%s\" and \"%s\" do not belong to the same grammar.\n"
entry.ename e.ename;
flush Pervasives.stderr;
failwith "Grammar.extend error")
else ()
| Smeta (_, sl, _) -> List.iter (check_gram entry) sl
| Slist0sep (s, t) ->
(check_gram entry t; check_gram entry s)
| Slist1sep (s, t) ->
(check_gram entry t; check_gram entry s)
| Slist0 s | Slist1 s | Sopt s | Stry s ->
check_gram entry s
| Stree t -> tree_check_gram entry t
| Snext | Sself | Stoken _ | Skeyword _ -> ()
and tree_check_gram entry =
function
| Node { node = n; brother = bro; son = son } ->
(check_gram entry n;
tree_check_gram entry bro;
tree_check_gram entry son)
| LocAct (_, _) | DeadEnd -> ()