Commit 5d0f7ded authored by Bruno Guillaume's avatar Bruno Guillaume

Add global in pattern (TBC)

parent bfedc8ba
......@@ -174,7 +174,10 @@ module Ast = struct
pat_const: const list;
}
let empty_basic = { pat_nodes=[]; pat_edges=[]; pat_const=[]; }
type pattern = {
pat_glob: string list;
pat_pos: basic;
pat_negs: basic list;
}
......@@ -227,7 +230,7 @@ module Ast = struct
let new_pat_pos = complete_basic [] pattern.pat_pos in
let aux = new_pat_pos.pat_nodes in
let new_pat_negs = List.map (complete_basic aux) pattern.pat_negs in
{ pat_pos = new_pat_pos; pat_negs = new_pat_negs;}
{ pattern with pat_pos = new_pat_pos; pat_negs = new_pat_negs;}
type concat_item =
| Qfn_or_lex_item of pointed
......
......@@ -123,7 +123,10 @@ module Ast : sig
pat_const: const list;
}
val empty_basic: basic
type pattern = {
pat_glob: string list;
pat_pos: basic;
pat_negs: basic list;
}
......
......@@ -181,6 +181,7 @@ and standard target = parse
| "without" { WITHOUT }
| "commands" { COMMANDS }
| "global" { GLOBAL }
| "add_edge" { ADD_EDGE }
| "del_edge" { DEL_EDGE }
......
......@@ -80,6 +80,7 @@ let localize t = (t,get_loc ())
%token PATTERN /* pattern */
%token WITHOUT /* without */
%token COMMANDS /* commands */
%token GLOBAL /* global */
%token STRAT /* strat */
%token PACKAGE /* package */
%token RULE /* rule */
......@@ -283,7 +284,7 @@ rule:
| Some l -> l @ final_lexicons
| None -> final_lexicons in
{ Ast.rule_id = fst id_loc;
pattern = Ast.complete_pattern { Ast.pat_pos = p; Ast.pat_negs = n };
pattern = Ast.complete_pattern { Ast.pat_glob = ["TODO"]; Ast.pat_pos = p; Ast.pat_negs = n };
commands = cmds;
lexicon_info = lexicons;
rule_doc = begin match doc with Some d -> d | None -> [] end;
......@@ -301,6 +302,12 @@ external_lexicon:
final_lexicon:
| final_lexicon = LEX_PAR { (fst final_lexicon, Ast.Final (snd final_lexicon)) }
glob_decl:
| GLOBAL l=delimited(LACC, separated_list_final_opt(SEMIC,glob_item),RACC) { l }
glob_item:
| item = ID { item }
pos_item:
| PATTERN i=pn_item { i }
......@@ -668,7 +675,14 @@ concat_item:
/* ISOLATED PATTERN (grep mode) */
/*=============================================================================================*/
pattern:
| p=pos_item n=list(neg_item) EOF { Ast.complete_pattern {Ast.pat_pos=p; pat_negs=n} }
| g=option (glob_decl) p=option(pos_item) n=list(neg_item) EOF
{ Ast.complete_pattern {
Ast.pat_glob = (match g with None -> [] | Some x -> x);
Ast.pat_pos = (match p with None -> Ast.empty_basic | Some x -> x);
Ast.pat_negs = n;
}
}
/*=============================================================================================*/
/* Constituent tree (à la Sequoia) */
......@@ -680,7 +694,6 @@ pst:
| LPAREN pos=ID ff=ID RPAREN { Grew_ast.Ast.T (get_loc(), pos, [Grew_ast.Ast.Leaf (get_loc(), ff)]) }
| LPAREN cat=ID daugthers=nonempty_list (pst) RPAREN { Grew_ast.Ast.T (get_loc(), cat, daugthers) }
/*=============================================================================================*/
/*=============================================================================================*/
/*=============================================================================================*/
......
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