Commit d3bf0458 authored by bguillaum's avatar bguillaum

add more checking around "lex_rule"

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@8891 7838e531-6607-4d57-9587-6c381814729c
parent 392bef9b
......@@ -328,13 +328,13 @@ rule:
rule_loc = snd id_loc;
}
}
| doc=option(COMMENT) LEX_RULE id_loc=simple_id_with_loc param=option(param) LACC p=pos_item n=list(neg_item) cmds=commands RACC lex_par=option(lex_par)
| doc=option(COMMENT) LEX_RULE id_loc=simple_id_with_loc param=param LACC p=pos_item n=list(neg_item) cmds=commands RACC lex_par=option(lex_par)
{
{ Ast.rule_id = fst id_loc;
pos_basic = p;
neg_basics = n;
commands = cmds;
param = param;
param = Some param;
lex_par = lex_par;
rule_doc = begin match doc with Some d -> d | None -> [] end;
rule_loc = snd id_loc;
......
......@@ -333,10 +333,12 @@ module Rule = struct
let nb_pv = List.length pat_vars in
let nb_cv = List.length cmd_vars in
(* first: load lexical parameters given in the same file at the end of the rule definition *)
let local_param = match rule_ast.Ast.lex_par with
| None -> None
| Some lines -> Some (Lex_par.from_lines ~loc:rule_ast.Ast.rule_loc nb_pv nb_cv lines) in
(* second: load lexical parameters given in external files *)
let full_param = List.fold_left
(fun acc file ->
match acc with
......@@ -346,6 +348,11 @@ module Rule = struct
(full_param, pat_vars, cmd_vars) in
(match (param, pat_vars) with
| (None, _::_) -> Error.build ~loc:rule_ast.Ast.rule_loc "Missing lexical parameters in rule \"%s\"" rule_ast.Ast.rule_id
| _ -> ()
);
let (pos, pos_table) = build_pos_basic domain ~pat_vars ~locals rule_ast.Ast.pos_basic in
let (negs,_) =
List.fold_left
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment