Commit a9eb4f36 authored by POTTIER Francois's avatar POTTIER Francois

Change [Error] to [Basics.Error] in the generated code,

so as to avoid OCaml's warning 41.
parent f3c6c75a
2016/06/23:
A small change in the generated code (both in the code and table back-ends) so
as to avoid OCaml's warning 41. The warning would arise (when compiling a
generated parser with OCaml 4.03) because Menhir's exception [Error] has the
same name as the data constructor [Error] in OCaml's pervasive library.
(Reported by Bernhard Schommer.)
2016/05/18:
Anonymous rules now work also when used inside a parameterized rule.
(This did not work until now.) When an anonymous rule is hoisted out
......
......@@ -1636,13 +1636,7 @@ let program =
[ SIFunctor (grammar.parameters,
SIExcDefs [ excdef ] ::
SIValDefs (false, [ excvaldef ]) ::
interface_to_structure (
tokentypedef grammar
) @
mbasics grammar @
SITypeDefs [ envtypedef; statetypedef ] ::
......@@ -1687,4 +1681,3 @@ let () =
Time.tick "Producing abstract syntax"
end
......@@ -209,9 +209,34 @@ let parse_error =
let errorval =
EVar parse_error
let basics =
"Basics"
let excvaldef = {
valpublic = false;
valpat = PVar parse_error;
valval = EData (Interface.excname, [])
valval = EData (basics ^ "." ^ Interface.excname, [])
(* 2016/06/23 We now use the qualified name [Basics.Error], instead of
just [Error], so as to avoid OCaml's warning 41. *)
}
(* ------------------------------------------------------------------------ *)
(* Define the internal sub-module [Basics], which contains the definitions
of the exception [Error] and of the type [token]. Then, include this
sub-module. This is used both in the code and table back-ends. *)
let mbasics grammar = [
SIModuleDef (basics, MStruct (
SIExcDefs [ Interface.excdef ] ::
interface_to_structure (
TokenType.tokentypedef grammar
)
));
SIInclude (MVar basics);
SIValDefs (false, [ excvaldef ]);
]
......@@ -109,11 +109,17 @@ val destructuretokendef: string -> typ -> bool -> (Terminal.t -> expr) -> valdef
(* A global variable holds the exception [Error]. *)
(* The definition of this global variable. *)
val excvaldef: valdef
(* A reference to this global variable. *)
val errorval: expr
(* ------------------------------------------------------------------------ *)
(* The structure items [mbasics grammar] define and include the internal
sub-module [Basics], which contains the definitions of the exception
[Error] and of the type [token]. Then, they define the global variable
mentioned above, which holds the exception [Error]. *)
val basics: string
val mbasics: UnparameterizedSyntax.grammar -> structure
......@@ -63,9 +63,6 @@ let staticVersion =
(* The following are names of internal sub-modules. *)
let basics =
"Basics"
let tables =
"Tables"
......@@ -990,16 +987,7 @@ let program =
sub-module. This sub-module is used again below, as part of the
application of the functor [TableInterpreter.Make]. *)
SIModuleDef (basics, MStruct (
SIExcDefs [ excdef ] ::
interface_to_structure (
tokentypedef grammar
)
)) ::
SIInclude (MVar basics) ::
SIValDefs (false, [ excvaldef ]) ::
mbasics grammar @
(* In order to avoid hiding user-defined identifiers, only the
exception [Error] and the type [token] should be defined (at
......@@ -1101,4 +1089,3 @@ let () =
Time.tick "Producing abstract syntax"
end
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