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