Commit 88220d13 authored by POTTIER Francois's avatar POTTIER Francois

Removed the file [InternalSyntax].

parent d43802e0
......@@ -2,4 +2,4 @@
which could be produced by either ocamlyacc or Menhir. *)
val grammar :
(Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Syntax.grammar
(Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Syntax.partial_grammar
......@@ -29,7 +29,7 @@ open Positions
/* ------------------------------------------------------------------------- */
/* Start symbol. */
%start <Syntax.grammar> grammar
%start <Syntax.partial_grammar> grammar
/* ------------------------------------------------------------------------- */
/* Priorities. */
......
type grammar =
{
p_preludes : Stretch.t list;
p_postludes : Syntax.trailer list;
p_parameters : Stretch.t list;
p_start_symbols : Positions.t StringMap.t;
p_types : (Syntax.parameter * Stretch.ocamltype Positions.located) list;
p_tokens : Syntax.token_properties StringMap.t;
p_rules : Syntax.parameterized_rule StringMap.t;
p_on_error_reduce : Syntax.parameter list;
}
open Positions
open Syntax
open UnparameterizedSyntax
open InternalSyntax
open Misc
(* Inference for non terminals. *)
......@@ -249,7 +248,7 @@ let rec parameter_type env = function
[Star] otherwise it is the flexible variable. *)
star_variable
let check_grammar p_grammar =
let check_grammar (p_grammar : Syntax.grammar) =
(* [n] is the grammar size. *)
let n = StringMap.cardinal p_grammar.p_rules in
......
......@@ -10,6 +10,4 @@
sanitized via [Misc.normalize] when printed in a context where a
valid identifier is expected. *)
val expand : InternalSyntax.grammar -> UnparameterizedSyntax.grammar
val expand : Syntax.grammar -> UnparameterizedSyntax.grammar
open Misc
open Syntax
open InternalSyntax
open Positions
(* ------------------------------------------------------------------------- *)
......@@ -432,7 +431,7 @@ let iter_on_only_used_symbols f t =
| _ -> ())
t
let symbols_of grammar (pgrammar : Syntax.grammar) =
let symbols_of grammar (pgrammar : Syntax.partial_grammar) =
let tokens = grammar.p_tokens in
let symbols_of_rule symbols prule =
let rec store_except_rule_parameters =
......
open Syntax
val join_partial_grammars :
Syntax.grammar list -> InternalSyntax.grammar
partial_grammar list -> grammar
(* The type [partial_grammar] describes the abstract syntax that is produced
by the parsers (yacc-parser and fancy-parser).
The type [grammar] describes the abstract syntax that is obtained after one
or more partial grammars are joined (see [PartialGrammar]). It differs in
that declarations are organized in a more useful way and a number of
well-formedness checks have been performed. *)
(* ------------------------------------------------------------------------ *)
(* Terminals and nonterminal symbols are strings. Identifiers
(which are used to refer to a symbol's semantic value) are
strings. A file name is a string. *)
......@@ -17,16 +27,24 @@ type identifier =
type filename =
string
(* ------------------------------------------------------------------------ *)
(* A trailer is a source file fragment. *)
type trailer =
Stretch.t
(* ------------------------------------------------------------------------ *)
(* OCaml semantic actions are represented as stretches. *)
type action =
Action.t
(* ------------------------------------------------------------------------ *)
(* Information about tokens. *)
type token_associativity =
LeftAssoc
| RightAssoc
......@@ -52,6 +70,8 @@ type token_properties =
mutable tk_is_declared : bool;
}
(* ------------------------------------------------------------------------ *)
type parameter =
| ParameterVar of symbol Positions.located
| ParameterApp of symbol Positions.located * parameters
......@@ -123,10 +143,22 @@ type parameterized_rule =
pr_branches : parameterized_branch list;
}
type grammar =
type partial_grammar =
{
pg_filename : filename;
pg_declarations : declaration Positions.located list;
pg_rules : parameterized_rule list;
pg_trailer : trailer option;
}
type grammar =
{
p_preludes : Stretch.t list;
p_postludes : trailer list;
p_parameters : Stretch.t list;
p_start_symbols : Positions.t StringMap.t;
p_types : (parameter * Stretch.ocamltype Positions.located) list;
p_tokens : token_properties StringMap.t;
p_rules : parameterized_rule StringMap.t;
p_on_error_reduce : parameter list;
}
......@@ -20,7 +20,7 @@ open Positions
%token <Stretch.t Lazy.t> PERCENTPERCENT
%token <Syntax.identifier option array -> Syntax.action> ACTION
%start grammar
%type <Syntax.grammar> grammar
%type <Syntax.partial_grammar> grammar
/* These declarations solve a shift-reduce conflict in favor of
shifting: when the declaration of a non-terminal symbol begins with
......
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