Commit c51a331f authored by Bruno Guillaume's avatar Bruno Guillaume

Fix rule_dir access for lexical rules

parent 48b9e9a7
......@@ -334,6 +334,7 @@ module Ast = struct
lex_par: string list option; (* lexical parameters in the file *)
rule_doc:string list;
rule_loc: Loc.t;
rule_dir: string option; (* the real folder where the file is defined *)
}
type modul = {
......
......@@ -164,6 +164,7 @@ module Ast : sig
lex_par: string list option; (* lexical parameters in the file *)
rule_doc:string list;
rule_loc: Loc.t;
rule_dir: string option; (* the real folder where the file is defined *)
}
type modul = {
......
......@@ -644,7 +644,7 @@ module New_grs = struct
let rec build_decl ?domain = function
| New_ast.Package (loc, name, decl_list) -> Package (name, List.map build_decl decl_list)
| New_ast.Rule ast_rule -> Rule (Rule.build ?domain "TODO" ast_rule)
| New_ast.Rule ast_rule -> Rule (Rule.build ?domain "TODO: remove this arg (old grs)" ast_rule)
| New_ast.Strategy (loc, name, ast_strat) -> Strategy (name, ast_strat)
| _ -> Error.bug "[build_decl] Inconsistent ast for new_grs"
......
......@@ -95,6 +95,14 @@ module Loader = struct
Ast.strategies = grs_wi.Ast.strategies_wi;
}
let rec check_duplicate_id id = function
| [] -> None
| New_ast.Rule r :: _ when r.Ast.rule_id = id -> Some r.Ast.rule_loc
......@@ -140,7 +148,8 @@ module Loader = struct
grs
with Sys_error msg -> Error.parse ~loc:(Loc.file file) "[Grew_loader.Loader.grs] %s" msg
let rec unfold_new_grs dir top new_ast_grs = List.fold_left
let rec unfold_new_grs dir top new_ast_grs =
List.fold_left
(fun acc decl -> match decl with
| New_ast.Import filename ->
let real_file = unlink dir filename in
......@@ -157,6 +166,10 @@ module Loader = struct
unfolded_sub @ acc
| New_ast.Features _ when not top -> Error.build "Non top features declaration"
| New_ast.Labels _ when not top -> Error.build "Non top labels declaration"
| New_ast.Package (loc, name, decls) ->
New_ast.Package (loc, name, unfold_new_grs dir top decls) :: acc
| New_ast.Rule ast_rule ->
New_ast.Rule {ast_rule with Ast.rule_dir = Some dir} :: acc
| x -> x :: acc
) [] new_ast_grs
......
......@@ -345,6 +345,7 @@ rule:
lex_par = None;
rule_doc = begin match doc with Some d -> d | None -> [] end;
rule_loc = snd id_loc;
rule_dir = None;
}
}
| doc=option(COMMENT) 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)
......@@ -356,6 +357,7 @@ rule:
lex_par = lex_par;
rule_doc = begin match doc with Some d -> d | None -> [] end;
rule_loc = snd id_loc;
rule_dir = None;
}
}
......
......@@ -489,7 +489,11 @@ module Rule = struct
parse_pat_vars vars
(* ====================================================================== *)
let build ?domain dir rule_ast =
let build ?domain deprecated_dir rule_ast =
let dir = match rule_ast.Ast.rule_dir with
| Some d -> d
| None -> deprecated_dir in
let (param, pat_vars, cmd_vars) =
match rule_ast.Ast.param with
......
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