From 7635e62c95dc9c1c932cd1fea0cc809fad3876de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pottier?= Date: Thu, 25 Aug 2016 15:45:56 +0200 Subject: [PATCH] Terminology: a trailer is now called a postlude everywhere. --- src/fancy-parser.mly | 12 ++++++------ src/lexer.mll | 3 +-- src/partialGrammar.ml | 14 +++++++------- src/syntax.mli | 10 +++++----- src/unparameterizedPrinter.ml | 4 ++-- src/unparameterizedSyntax.ml | 2 +- src/yacc-parser.mly | 10 +++++----- 7 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/fancy-parser.mly b/src/fancy-parser.mly index b13240e9..52ea0358 100644 --- a/src/fancy-parser.mly +++ b/src/fancy-parser.mly @@ -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) } %% diff --git a/src/lexer.mll b/src/lexer.mll index 5ea539e1..5a849422 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -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 } - diff --git a/src/partialGrammar.ml b/src/partialGrammar.ml index 80901411..28391f92 100644 --- a/src/partialGrammar.ml +++ b/src/partialGrammar.ml @@ -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 = diff --git a/src/syntax.mli b/src/syntax.mli index 26113ce2..c5b88552 100644 --- a/src/syntax.mli +++ b/src/syntax.mli @@ -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; diff --git a/src/unparameterizedPrinter.ml b/src/unparameterizedPrinter.ml index 479aa1ef..92743310 100644 --- a/src/unparameterizedPrinter.ml +++ b/src/unparameterizedPrinter.ml @@ -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 -> () diff --git a/src/unparameterizedSyntax.ml b/src/unparameterizedSyntax.ml index 5f62e1b2..efd9fc80 100644 --- a/src/unparameterizedSyntax.ml +++ b/src/unparameterizedSyntax.ml @@ -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; diff --git a/src/yacc-parser.mly b/src/yacc-parser.mly index b6ddff59..a206447d 100644 --- a/src/yacc-parser.mly +++ b/src/yacc-parser.mly @@ -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) } /* ------------------------------------------------------------------------- */ -- GitLab