gr_grs_parser.mly 23.2 KB
Newer Older
pj2m's avatar
pj2m committed
1
2
%{

bguillaum's avatar
bguillaum committed
3
4
open Grew_ast
open Grew_utils
pj2m's avatar
pj2m committed
5

6
(* Some intermediate sum types used in sub-functions when building the ast *)
pj2m's avatar
pj2m committed
7
type pat_item = 
bguillaum's avatar
bguillaum committed
8
9
10
  | Pat_node of Ast.node
  | Pat_edge of Ast.edge
  | Pat_const of Ast.const
pj2m's avatar
pj2m committed
11
12

type graph_item =
bguillaum's avatar
bguillaum committed
13
14
  | Graph_node of Ast.node
  | Graph_edge of Ast.edge
pj2m's avatar
pj2m committed
15
16
17
18
19

let get_loc () = (!Parser_global.current_file,!Parser_global.current_line+1)
let localize t = (t,get_loc ())
%}

20
21
22
23
24
25
26
27
28
29
%token LACC                        /* { */
%token RACC                        /* } */
%token LBRACKET                    /* [ */
%token RBRACKET                    /* ] */
%token LPAREN                      /* ( */
%token RPAREN                      /* ) */
%token DDOT                        /* : */
%token COMA                        /* , */
%token SEMIC                       /* ; */
%token STAR                        /* * */
bguillaum's avatar
bguillaum committed
30
%token PLUS                        /* + */
31
32
33
34
35
36
37
38
39
40
41
%token EQUAL                       /* = */
%token DISEQUAL                    /* <> */
%token PIPE                        /* | */
%token GOTO_NODE                   /* -> */
%token LTR_EDGE_LEFT               /* -[ */
%token LTR_EDGE_LEFT_NEG           /* -[^ */
%token LTR_EDGE_RIGHT              /* ]-> */
%token RTL_EDGE_LEFT               /* <-[ */
%token RTL_EDGE_RIGHT              /* ]- */
%token LONGARROW                   /* ==> */

42
%token INCLUDE                     /* include */
43
%token FEATURES                    /* features */
bguillaum's avatar
bguillaum committed
44
45
%token FEATURE                     /* feature */
%token FILE                        /* file */
46
47
48
49
50
51
52
53
%token LABELS                      /* labels */
%token BAD_LABELS                  /* bad_labels */
%token MATCH                       /* match */
%token WITHOUT                     /* without */
%token COMMANDS                    /* commands */
%token MODULE                      /* module */
%token CONFLUENT                   /* confluent */
%token RULE                        /* rule */
bguillaum's avatar
bguillaum committed
54
%token LEX_RULE                    /* lex_rule */
55
%token FILTER                      /* filter */
56
57
58
59
60
61
%token SEQUENCES                   /* sequences */
%token GRAPH                       /* graph */

%token DEL_EDGE                    /* del_edge */
%token ADD_EDGE                    /* add_edge */
%token MERGE                       /* merge */
62
63
%token SHIFT_IN                    /* shift_in */
%token SHIFT_OUT                   /* shift_out */
64
65
66
67
68
%token SHIFT                       /* shift */
%token DEL_NODE                    /* del_node */
%token ADD_NODE                    /* add_node */
%token DEL_FEAT                    /* del_feat */

69
70
%token <string> PAT                /* $id */
%token <string> CMD                /* @id */
bguillaum's avatar
bguillaum committed
71

72
%token <string>  IDENT             /* indentifier */
73
%token <Grew_ast.Ast.qfn> QFN      /* ident.ident */
74
75
76
%token <string>  STRING
%token <int>     INT
%token <string>  COMMENT
pj2m's avatar
pj2m committed
77

78
%token EOF                         /* end of file */
pj2m's avatar
pj2m committed
79

bguillaum's avatar
bguillaum committed
80
81
82
%start <Grew_ast.Ast.grs_with_include> grs_with_include
%start <Grew_ast.Ast.grs> grs
%start <Grew_ast.Ast.gr> gr
83
%start <Grew_ast.Ast.module_or_include list> included
pj2m's avatar
pj2m committed
84
85
86
87
88
89
90
%%

/*=============================================================================================*/
/*  GREW GRAPH                                                                                 */
/*=============================================================================================*/

gr: 
91
92
93
        | GRAPH LACC items = separated_list(SEMIC,option(gr_item)) RACC EOF 
            {
             {
bguillaum's avatar
bguillaum committed
94
95
              Ast.nodes = List_.opt_map (function Some (Graph_node n) -> Some n | _ -> None) items;
              Ast.edges = List_.opt_map (function Some (Graph_edge n) -> Some n | _ -> None) items;
96
97
98
            }
           }
                  
pj2m's avatar
pj2m committed
99
gr_item:
100
        | id = IDENT position = option(delimited(LPAREN,index,RPAREN)) feats = delimited(LBRACKET,separated_list(COMA,node_features),RBRACKET) 
bguillaum's avatar
bguillaum committed
101
            { Graph_node (localize {Ast.node_id = id; position=position; fs=feats}) }
pj2m's avatar
pj2m committed
102

103
        | n1 = IDENT labels = delimited(LTR_EDGE_LEFT_NEG,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
104
            { Graph_edge (localize {Ast.edge_id = None; src=n1; edge_labels=labels; tar=n2; negative=true; }) }
pj2m's avatar
pj2m committed
105

106
        | n1 = IDENT labels = delimited(LTR_EDGE_LEFT,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
107
            { Graph_edge (localize {Ast.edge_id = None; src=n1; edge_labels=labels; tar=n2; negative=false; }) }
pj2m's avatar
pj2m committed
108
109

index:
110
        | INT { $1 }
pj2m's avatar
pj2m committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125










/*=============================================================================================*/
/*  GREW GRAPH SYSTEM REWRITING                                                                */
/*=============================================================================================*/


126
127
128
129
130
131
132
133
134
135
grs_with_include:
        | f = features_group g = global_labels m = module_or_include_list s = sequences EOF 
            {
             { Ast.domain_wi=List_.opt f; 
               labels_wi=g; 
               modules_wi=m; 
               sequences_wi=s;
             }
           }
     
pj2m's avatar
pj2m committed
136
grs:
137
138
139
140
141
142
143
144
        | f = features_group g = global_labels m = modules s = sequences EOF 
            {
             { Ast.domain=List_.opt f; 
               labels=g; 
               modules=m; 
               sequences=s;
             }
           }
145
146
147
148
149
       
module_or_include_list:
        | x = list(module_or_include) { x }

module_or_include:
bguillaum's avatar
bguillaum committed
150
        | m = grew_module        { Ast.Modul m }
151
        | INCLUDE sub = subfile SEMIC { Ast.Includ sub } 
pj2m's avatar
pj2m committed
152

153
154
subfile:
        | f = STRING  { localize f }
pj2m's avatar
pj2m committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168

/*=============================================================================================*/
/*                                                                                             */
/* FEATURES DOMAIN DEFINITION                                                                  */
/*                                                                                             */
/* features {                                                                                  */
/*      cat: n, np, v, adj;                                                                    */
/*      mood: inf, ind, subj, pastp, presp;                                                    */
/*      lemma: *; phon: *                                                                      */
/* }                                                                                           */
/*                                                                                             */
/*=============================================================================================*/

features_group:
169
170
        | FEATURES x = features { x }
        
pj2m's avatar
pj2m committed
171
%inline features:
172
173
        | LACC x = separated_nonempty_list(SEMIC,option(feature)) RACC { x }
        
pj2m's avatar
pj2m committed
174
%inline feature:
175
176
177
        | name = feature_name DDOT values = features_values 
            { 
              if List.length values == 1 && List.hd values = "*"
bguillaum's avatar
bguillaum committed
178
179
              then Ast.Open name 
              else Ast.Closed (name,List.sort Pervasives.compare values)
180
            }
pj2m's avatar
pj2m committed
181
182

feature_name:
183
        | word = IDENT { word }
pj2m's avatar
pj2m committed
184
185

features_values:
186
187
        | STAR { ["*"] }
        | x = separated_nonempty_list(COMA,feature_value) { x }
pj2m's avatar
pj2m committed
188
189
190
191
192
193
194
195
196
197
198


/*=============================================================================================*/
/*                                                                                             */
/* GLOBAL LABELS DEFINITION                                                                    */
/*                                                                                             */
/* labels { OBJ, SUBJ, DE_OBJ, ANT }                                                           */
/*                                                                                             */
/*=============================================================================================*/

%inline labels:
199
200
        | x = delimited(LACC,separated_nonempty_list(COMA,label),RACC) { x }
        
pj2m's avatar
pj2m committed
201
%inline label:
202
        | x = IDENT color = option(ddot_color)  { (x, color) }
pj2m's avatar
pj2m committed
203
204

ddot_color:
205
        | DDOT color = IDENT { color }
pj2m's avatar
pj2m committed
206
207

global_labels:
208
        | LABELS x = labels { x }
pj2m's avatar
pj2m committed
209
210
211
212
213
214
215
216
217
218
219
220


/*=============================================================================================*/
/*                                                                                             */
/* MODULE DEFINITION                                                                           */
/*                                                                                             */
/* module p7_to_p7p-mc {                                                                       */
/*   ...                                                                                       */
/* }                                                                                           */
/*                                                                                             */
/*=============================================================================================*/

221
included:
222
        | x = list (module_or_include) EOF { x }
223

pj2m's avatar
pj2m committed
224
modules:
225
226
        | x = list(grew_module) { x }
        
pj2m's avatar
pj2m committed
227
grew_module: 
228
229
230
231
232
233
234
235
        | doc = option(module_doc) MODULE conf = boption(CONFLUENT) id = module_id LACC l = option(local_labels) b = option(local_bad_labels) r = option(rules) RACC 
           {
            { Ast.module_id = fst id; 
              local_labels = begin match l with None -> [] | Some l -> l; end;
              bad_labels = begin match b with None -> [] | Some b -> b; end;
              rules = begin match r with None -> [] | Some r -> r; end;
              confluent = conf;
              module_doc = (match doc with Some d -> d | None -> "");
236
237
              mod_loc = (!Parser_global.current_file, snd id);
              mod_dir = "";
238
239
            }
          }
pj2m's avatar
pj2m committed
240
241

module_id:
242
        | id = IDENT { (id,!Parser_global.current_line+1) }
pj2m's avatar
pj2m committed
243
244

module_doc:
245
        | comment = COMMENT { comment } 
pj2m's avatar
pj2m committed
246
247
248
249
250
251
252
253
254
255
256
257
258

/*=============================================================================================*/
/*                                                                                             */
/* LOCAL LABELS DEFINITION                                                                     */
/*                                                                                             */
/* labels {ANT_TMP}                                                                            */
/*                                                                                             */
/* bad_labels { SUJ, OBJ }                                                                     */
/*=============================================================================================*/



local_labels:
259
        | LABELS x = labels { x }
pj2m's avatar
pj2m committed
260
261

local_bad_labels:
262
263
        | BAD_LABELS x = bad_labels { x }
         
pj2m's avatar
pj2m committed
264
%inline bad_labels:
265
        | x = delimited(LACC,separated_nonempty_list(COMA,IDENT),RACC) { x }
pj2m's avatar
pj2m committed
266
267
268
269
270
271
272
273
274
275
276
277
278



/*=============================================================================================*/
/*                                                                                             */
/* RULES DEFINITION                                                                            */
/*                                                                                             */
/* rule ant_prorel_init {                                                                      */
/*   ...                                                                                       */
/* }                                                                                           */
/*=============================================================================================*/

rules:
279
        | r = list(rule) { r }
pj2m's avatar
pj2m committed
280
281

rule: 
282
283
        | doc = option(rule_doc) RULE id = rule_id LACC p = pos_item n = list(neg_item) cmds = commands RACC 
            { 
bguillaum's avatar
bguillaum committed
284
              { Ast.rule_id = fst id;
285
286
                pos_pattern = p;
                neg_patterns = n;
bguillaum's avatar
bguillaum committed
287
288
                commands = List_.opt cmds;
                param = None;
289
290
291
292
                rule_doc = begin match doc with Some d -> d | None -> "" end;
                rule_loc = (!Parser_global.current_file,snd id);
              }
            }         
bguillaum's avatar
bguillaum committed
293
294
295
296
297
298
299
300
301
302
303
        | doc = option(rule_doc) LEX_RULE id = rule_id param=option(param) LACC p = pos_item n = list(neg_item) cmds = commands RACC 
            { 
              { Ast.rule_id = fst id;
                pos_pattern = p;
                neg_patterns = n;
                commands = List_.opt cmds;
                param = param;
                rule_doc = begin match doc with Some d -> d | None -> "" end;
                rule_loc = (!Parser_global.current_file,snd id);
              }
            }         
304
305
306
307
308
309
310
311
312
313
314
315
        | doc = option(rule_doc) FILTER id = rule_id LACC p = pos_item n = list(neg_item) RACC 
            { 
              { Ast.rule_id = fst id;
                pos_pattern = p;
                neg_patterns = n;
                commands = [];
                param = None;
                rule_doc = begin match doc with Some d -> d | None -> "" end;
                rule_loc = (!Parser_global.current_file,snd id);
              }
            }
 
bguillaum's avatar
bguillaum committed
316
317
318
319
320
321
322
param:
        | LPAREN FEATURE vars = separated_nonempty_list(COMA,var) SEMIC FILE file=STRING RPAREN { (file,vars) }

var:
        | i = PAT {i}
        | i = CMD {i}

pj2m's avatar
pj2m committed
323
pos_item:
324
        | MATCH i = pn_item { i }
pj2m's avatar
pj2m committed
325
326

neg_item:
327
328
        | WITHOUT i = pn_item { i }
          
pj2m's avatar
pj2m committed
329
pn_item: 
330
331
332
333
334
335
336
337
338
        | l = delimited(LACC,separated_nonempty_list(SEMIC,option(pat_item)),RACC)
            {
             {
              Ast.pat_nodes = List_.opt_map (function Some (Pat_node n) -> Some n | _ -> None) l;
              Ast.pat_edges = List_.opt_map (function Some (Pat_edge n) -> Some n | _ -> None) l;
              Ast.pat_const = List_.opt_map (function Some (Pat_const n) -> Some n | _ -> None) l;
            }
           }
        
pj2m's avatar
pj2m committed
339
rule_id:
340
        | id = IDENT { (id,!Parser_global.current_line+1) }
pj2m's avatar
pj2m committed
341
342

rule_doc:
343
344
        | comment = COMMENT { comment } 
        
pj2m's avatar
pj2m committed
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/*=============================================================================================*/
/*                                                                                             */
/* MATCH DEFINITION                                                                            */
/*                                                                                             */
/* match {                                                                                     */
/*      P [cat = prorel];                                                                      */
/*      N -> P;                                                                                */
/*                                                                                             */
/*      without { P -[ANT]-> * }                                                               */
/*      without { P -[ANT_TMP]-> * }                                                           */
/*    }                                                                                        */
/*                                                                                             */
/*=============================================================================================*/


pat_item:
361
362
363
        | n = pat_node { Pat_node n }
        | e = pat_edge { Pat_edge e }
        | c = pat_const { Pat_const c }
pj2m's avatar
pj2m committed
364

365
pat_node:
366
        | id = IDENT feats = delimited(LBRACKET,separated_list(COMA,node_features),RBRACKET) 
bguillaum's avatar
bguillaum committed
367
            { localize ({Ast.node_id = id; position=None; fs= feats}) }
pj2m's avatar
pj2m committed
368
369
370
371
372




node_features:
373
        | name = IDENT EQUAL STAR 
bguillaum's avatar
bguillaum committed
374
            { localize {Ast.kind = Ast.Disequality []; name=name; } } 
375
        | name = IDENT EQUAL values = separated_nonempty_list(PIPE,feature_value) 
bguillaum's avatar
bguillaum committed
376
            { localize {Ast.kind = Ast.Equality values; name=name; } } 
377
        | name = IDENT DISEQUAL values = separated_nonempty_list(PIPE,feature_value) 
bguillaum's avatar
bguillaum committed
378
379
380
            { localize {Ast.kind = Ast.Disequality values; name=name; } } 
        | name = IDENT EQUAL p = PAT
            { localize {Ast.kind = Ast.Param p; name=name; } } 
pj2m's avatar
pj2m committed
381
382

feature_value:
383
384
        | v = IDENT { v }
        | v = STRING { v }
385
        | v = INT { string_of_int v }
pj2m's avatar
pj2m committed
386

387
pat_edge:
388
        (* "e: A -> B" OR "e: A -[*]-> B" *)
389
        | id = edge_id n1 = IDENT GOTO_NODE n2 = IDENT
bguillaum's avatar
bguillaum committed
390
        | id = edge_id n1 = IDENT LTR_EDGE_LEFT_NEG STAR LTR_EDGE_RIGHT n2 = IDENT
bguillaum's avatar
bguillaum committed
391
               { localize ({Ast.edge_id = Some id; src=n1; edge_labels=[]; tar=n2; negative=true}) }
392
393
394

        (* "A -> B" *)
        | n1 = IDENT GOTO_NODE n2 = IDENT
bguillaum's avatar
bguillaum committed
395
               { localize ({Ast.edge_id = None; src=n1; edge_labels=[]; tar=n2; negative=true}) }
396
397
398

        (* "e: A -[^X|Y]-> B" *)
        | id = edge_id n1 = IDENT labels = delimited(LTR_EDGE_LEFT_NEG,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
399
            { localize ({Ast.edge_id = Some id; src=n1; edge_labels=labels; tar=n2; negative=true}) }
400
401
402
            
        (* "A -[^X|Y]-> B"*)
        | n1 = IDENT labels = delimited(LTR_EDGE_LEFT_NEG,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
403
            { localize ({Ast.edge_id = None; src=n1; edge_labels=labels; tar=n2; negative=true}) }
pj2m's avatar
pj2m committed
404

405
406
        (* "e: A -[X|Y]-> B" *)
        | id = edge_id n1 = IDENT labels = delimited(LTR_EDGE_LEFT,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
407
            { localize ({Ast.edge_id = Some id; src=n1; edge_labels=labels; tar=n2; negative=false}) }       
pj2m's avatar
pj2m committed
408

409
410
        (* "A -[X|Y]-> B" *)
        | n1 = IDENT labels = delimited(LTR_EDGE_LEFT,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
411
            { localize ({Ast.edge_id = None; src=n1; edge_labels=labels; tar=n2; negative=false}) }
pj2m's avatar
pj2m committed
412
413
414


edge_id:
415
416
        | id = IDENT DDOT { id }
                
pj2m's avatar
pj2m committed
417

418
pat_const:
bguillaum's avatar
bguillaum committed
419
        (* "A -[X|Y]-> *" *)
420
        | n1 = IDENT labels = delimited(LTR_EDGE_LEFT,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) STAR
bguillaum's avatar
bguillaum committed
421
            { localize (Ast.Start (n1,labels)) }
bguillaum's avatar
bguillaum committed
422
423
424

        (* "A -> *" *)
        | n1 = IDENT GOTO_NODE STAR
bguillaum's avatar
bguillaum committed
425
            { localize (Ast.No_out n1) }
bguillaum's avatar
bguillaum committed
426
427

        (* "* -[X|Y]-> A" *)
428
        | STAR labels = delimited(LTR_EDGE_LEFT,separated_nonempty_list(PIPE,IDENT),LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
429
            { localize (Ast.End (n2,labels)) }
pj2m's avatar
pj2m committed
430

bguillaum's avatar
bguillaum committed
431
432
        (* "* -> A" *)
        | STAR GOTO_NODE n2 = IDENT
bguillaum's avatar
bguillaum committed
433
            { localize (Ast.No_in n2) }
pj2m's avatar
pj2m committed
434

435
        | qfn1 = QFN EQUAL qfn2 = QFN
bguillaum's avatar
bguillaum committed
436
            { localize (Ast.Feature_eq (qfn1, qfn2)) }
437

pj2m's avatar
pj2m committed
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
/*=============================================================================================*/
/*                                                                                             */
/* COMMANDS DEFINITION                                                                         */
/*                                                                                             */
/* commands {                                                                                  */
/*      del_edge A -[OBJ]-> B;                                                                 */
/*      del_edge e;                                                                            */
/*                                                                                             */
/*      add_edge A -[ATS]-> B;                                                                 */
/*                                                                                             */
/*      shift A ==> B;                                                                         */
/*                                                                                             */
/*      del_node A;                                                                            */
/*                                                                                             */
/*      add_node D: <-[SUJ]- A;                                                                */
/*                                                                                             */
/*      A.mood = inf;                                                                          */
/*                                                                                             */
/*      B.tense = A.tense;                                                                     */
/*                                                                                             */
/*      del_feat A.tense;                                                                      */
/* }                                                                                           */
/*                                                                                             */
/*=============================================================================================*/


commands:
465
        | COMMANDS x = delimited(LACC,separated_nonempty_list(SEMIC,option(command)),RACC) { x }
pj2m's avatar
pj2m committed
466
467

command:
468
        | DEL_EDGE n = IDENT
bguillaum's avatar
bguillaum committed
469
            { localize (Ast.Del_edge_name n) }
470
        | DEL_EDGE n1 = IDENT label = delimited(LTR_EDGE_LEFT,IDENT,LTR_EDGE_RIGHT) n2 = IDENT 
bguillaum's avatar
bguillaum committed
471
            { localize (Ast.Del_edge_expl (n1,n2,label)) }
472
        | ADD_EDGE n1 = IDENT label = delimited(LTR_EDGE_LEFT,IDENT,LTR_EDGE_RIGHT) n2 = IDENT
bguillaum's avatar
bguillaum committed
473
            { localize (Ast.Add_edge (n1,n2,label)) }
474
        | SHIFT_IN n1 = IDENT LONGARROW n2 = IDENT 
bguillaum's avatar
bguillaum committed
475
            { localize (Ast.Shift_in (n1,n2)) }
476
        | SHIFT_OUT n1 = IDENT LONGARROW n2 = IDENT 
bguillaum's avatar
bguillaum committed
477
            { localize (Ast.Shift_out (n1,n2)) }
478
        | SHIFT n1 = IDENT LONGARROW n2 = IDENT 
bguillaum's avatar
bguillaum committed
479
            { localize (Ast.Shift_edge (n1,n2)) }
480
        | MERGE n1 = IDENT LONGARROW n2 = IDENT 
bguillaum's avatar
bguillaum committed
481
            { localize (Ast.Merge_node (n1,n2)) }
bguillaum's avatar
bguillaum committed
482
        | DEL_NODE n = IDENT
bguillaum's avatar
bguillaum committed
483
            { localize (Ast.Del_node n) }
484
        | ADD_NODE n1 = IDENT DDOT label = delimited(RTL_EDGE_LEFT,IDENT,RTL_EDGE_RIGHT) n2 = IDENT 
bguillaum's avatar
bguillaum committed
485
            { localize (Ast.New_neighbour (n1,n2,label)) }
486
        | DEL_FEAT qfn = QFN 
bguillaum's avatar
bguillaum committed
487
            { localize (Ast.Del_feat qfn) }
488
        | qfn = QFN EQUAL items = separated_nonempty_list (PLUS, concat_item)
bguillaum's avatar
bguillaum committed
489
            { localize (Ast.Update_feat (qfn, items)) }
490
491

concat_item:
492
493
        | qfn = QFN    { Ast.Qfn_item qfn }
        | s = IDENT    { Ast.String_item s }
bguillaum's avatar
bguillaum committed
494
        | s = STRING   { Ast.String_item s }
495
        | p = CMD      { Ast.Param_item p }
pj2m's avatar
pj2m committed
496
497
498
499
500
501
502
503
504
505

/*=============================================================================================*/
/*                                                                                             */
/* SEQUENCE DEFINITION                                                                         */
/*                                                                                             */
/* sequence { ant; p7_to_p7p-mc}                                                               */
/*                                                                                             */
/*=============================================================================================*/

sequences:
506
        | SEQUENCES seq = delimited(LACC,list(sequence),RACC) { seq }
pj2m's avatar
pj2m committed
507
508

sequence:
509
510
511
512
513
514
515
516
        | doc = option(COMMENT) id = sequence_id mod_names = delimited(LACC,separated_nonempty_list(SEMIC,option( IDENT)),RACC) 
            { 
              { Ast.seq_name = fst id; 
                seq_mod = List_.opt mod_names ; 
                seq_doc = begin match doc with Some d -> d | None -> "" end; 
                seq_loc = (!Parser_global.current_file,snd id);
              } 
            }
pj2m's avatar
pj2m committed
517
518

sequence_id:
519
        | id = IDENT { (id,!Parser_global.current_line+1) }
pj2m's avatar
pj2m committed
520
521

%%