Commit 7635e62c authored by POTTIER Francois's avatar POTTIER Francois

Terminology: a trailer is now called a postlude everywhere.

parent db3883c7
...@@ -48,16 +48,16 @@ open Positions ...@@ -48,16 +48,16 @@ open Positions
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* A grammar consists of declarations and rules, followed by an optional /* A grammar consists of declarations and rules, followed by an optional
trailer, which we do not parse. */ postlude, which we do not parse. */
grammar: grammar:
ds = declaration* PERCENTPERCENT rs = rule* t = trailer ds = declaration* PERCENTPERCENT rs = rule* t = postlude
{ {
{ {
pg_filename = ""; (* filled in by the caller *) pg_filename = ""; (* filled in by the caller *)
pg_declarations = List.flatten ds; pg_declarations = List.flatten ds;
pg_rules = rs; pg_rules = rs;
pg_trailer = t pg_postlude = t
} }
} }
...@@ -339,12 +339,12 @@ modifier: ...@@ -339,12 +339,12 @@ modifier:
{ with_poss $startpos $endpos "list" } { with_poss $startpos $endpos "list" }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* A trailer is announced by %%, but is optional. */ /* A postlude is announced by %%, but is optional. */
trailer: postlude:
EOF EOF
{ None } { None }
| p = PERCENTPERCENT /* followed by actual trailer */ | p = PERCENTPERCENT /* followed by actual postlude */
{ Some (Lazy.force p) } { Some (Lazy.force p) }
%% %%
...@@ -632,7 +632,7 @@ and char = parse ...@@ -632,7 +632,7 @@ and char = parse
(* Read until the end of the file. This is used after finding a %% (* Read until the end of the file. This is used after finding a %%
that marks the end of the grammar specification. We update the that marks the end of the grammar specification. We update the
current position as we go. This allows us to build a stretch current position as we go. This allows us to build a stretch
for the trailer. *) for the postlude. *)
and finish = parse and finish = parse
| newline | newline
...@@ -641,4 +641,3 @@ and finish = parse ...@@ -641,4 +641,3 @@ and finish = parse
{ lexeme_start_p lexbuf } { lexeme_start_p lexbuf }
| _ | _
{ finish lexbuf } { finish lexbuf }
...@@ -126,15 +126,15 @@ let join_declaration filename (grammar : grammar) decl = ...@@ -126,15 +126,15 @@ let join_declaration filename (grammar : grammar) decl =
grammar grammar
(* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *)
(* This stores an optional trailer into a grammar. (* This stores an optional postlude into a grammar.
Trailers are stored in an arbitrary order. *) Postludes are stored in an arbitrary order. *)
let join_trailer trailer grammar = let join_postlude postlude grammar =
match trailer with match postlude with
| None -> | None ->
grammar grammar
| Some trailer -> | Some postlude ->
{ grammar with p_postludes = trailer :: grammar.p_postludes } { grammar with p_postludes = postlude :: grammar.p_postludes }
(* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *)
(* We rewrite definitions when nonterminals are renamed. The (* We rewrite definitions when nonterminals are renamed. The
...@@ -573,7 +573,7 @@ let empty_grammar = ...@@ -573,7 +573,7 @@ let empty_grammar =
let join grammar pgrammar = let join grammar pgrammar =
let filename = pgrammar.pg_filename in let filename = pgrammar.pg_filename in
List.fold_left (join_declaration filename) grammar pgrammar.pg_declarations List.fold_left (join_declaration filename) grammar pgrammar.pg_declarations
$$ join_trailer pgrammar.pg_trailer $$ join_postlude pgrammar.pg_postlude
let check_parameterized_grammar_is_well_defined grammar = let check_parameterized_grammar_is_well_defined grammar =
......
...@@ -29,9 +29,9 @@ type filename = ...@@ -29,9 +29,9 @@ type filename =
(* ------------------------------------------------------------------------ *) (* ------------------------------------------------------------------------ *)
(* A trailer is a source file fragment. *) (* A postlude is a source file fragment. *)
type trailer = type postlude =
Stretch.t Stretch.t
(* ------------------------------------------------------------------------ *) (* ------------------------------------------------------------------------ *)
...@@ -185,7 +185,7 @@ type declaration = ...@@ -185,7 +185,7 @@ type declaration =
type partial_grammar = type partial_grammar =
{ {
pg_filename : filename; pg_filename : filename;
pg_trailer : trailer option; pg_postlude : postlude option;
pg_declarations : declaration Positions.located list; pg_declarations : declaration Positions.located list;
pg_rules : parameterized_rule list; pg_rules : parameterized_rule list;
} }
...@@ -196,7 +196,7 @@ type partial_grammar = ...@@ -196,7 +196,7 @@ type partial_grammar =
(* The differences with partial grammars (above) are as follows: (* The differences with partial grammars (above) are as follows:
1. the file name is gone (there could be several file names, anyway). 1. the file name is gone (there could be several file names, anyway).
2. there can be several trailers, now known as postludes. 2. there can be several postludes.
3. declarations are organized by kind: preludes, functor %parameters, 3. declarations are organized by kind: preludes, functor %parameters,
%start symbols, %types, %tokens, %on_error_reduce. %start symbols, %types, %tokens, %on_error_reduce.
4. rules are stored in a map, indexed by symbol names, instead of a list. 4. rules are stored in a map, indexed by symbol names, instead of a list.
...@@ -205,7 +205,7 @@ type partial_grammar = ...@@ -205,7 +205,7 @@ type partial_grammar =
type grammar = type grammar =
{ {
p_preludes : Stretch.t list; p_preludes : Stretch.t list;
p_postludes : trailer list; p_postludes : postlude list;
p_parameters : Stretch.t list; p_parameters : Stretch.t list;
p_start_symbols : Positions.t StringMap.t; p_start_symbols : Positions.t StringMap.t;
p_types : (parameter * Stretch.ocamltype Positions.located) list; p_types : (parameter * Stretch.ocamltype Positions.located) list;
......
...@@ -141,7 +141,7 @@ let print_branch mode f branch = ...@@ -141,7 +141,7 @@ let print_branch mode f branch =
end; end;
Printf.fprintf f "}\n" Printf.fprintf f "}\n"
let print_trailers b g = let print_postludes b g =
List.iter (fun stretch -> Printf.fprintf b "%s\n" stretch.stretch_raw_content) g.postludes List.iter (fun stretch -> Printf.fprintf b "%s\n" stretch.stretch_raw_content) g.postludes
(* Because the resolution of reduce/reduce conflicts is implicitly dictated by (* Because the resolution of reduce/reduce conflicts is implicitly dictated by
...@@ -212,7 +212,7 @@ let print mode f g = ...@@ -212,7 +212,7 @@ let print mode f g =
Printf.fprintf f "\n%%%%\n"; Printf.fprintf f "\n%%%%\n";
begin match mode with begin match mode with
| PrintNormal -> | PrintNormal ->
print_trailers f g print_postludes f g
| PrintUnitActions | PrintUnitActions
| PrintUnitActionsUnitTokens -> | PrintUnitActionsUnitTokens ->
() ()
......
...@@ -36,7 +36,7 @@ type rule = ...@@ -36,7 +36,7 @@ type rule =
type grammar = type grammar =
{ {
preludes : Stretch.t list; preludes : Stretch.t list;
postludes : Syntax.trailer list; postludes : Syntax.postlude list;
parameters : Stretch.t list; parameters : Stretch.t list;
start_symbols : StringSet.t; start_symbols : StringSet.t;
types : Stretch.ocamltype StringMap.t; types : Stretch.ocamltype StringMap.t;
......
...@@ -36,23 +36,23 @@ open Positions ...@@ -36,23 +36,23 @@ open Positions
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* A grammar consists of declarations and rules, followed by an optional /* A grammar consists of declarations and rules, followed by an optional
trailer, which we do not parse. */ postlude, which we do not parse. */
grammar: grammar:
declarations PERCENTPERCENT rules trailer declarations PERCENTPERCENT rules postlude
{ {
{ {
pg_filename = ""; (* filled in by the caller *) pg_filename = ""; (* filled in by the caller *)
pg_declarations = List.rev $1; pg_declarations = List.rev $1;
pg_rules = $3; pg_rules = $3;
pg_trailer = $4 pg_postlude = $4
} }
} }
trailer: postlude:
EOF EOF
{ None } { None }
| PERCENTPERCENT /* followed by actual trailer */ | PERCENTPERCENT /* followed by actual postlude */
{ Some (Lazy.force $1) } { Some (Lazy.force $1) }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
......
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