Commit 1bd65ffa by POTTIER Francois

Added a magic cookie, which is checked at link time, ensuring that

a parser produced by menhir --table cannot be linked with an incorrect
version of MenhirLib.
parent 9c00fac5
2015/11/11:
The code produced by version XXXXXXXX of menhir --table can now be linked only
against a matching version of MenhirLib. If an incorrect version of MenhirLib
is installed, the OCaml compiler should complain that
[MenhirLib.StaticVersion.require_XXXXXXXX] is undefined.
2015/11/10:
Optimized the computation of $symbolstartpos, based on a couple of assumptions
about the lexer. (See the manual.)
......
......@@ -112,10 +112,12 @@ package: clean
$(HEADACHE) -h $(LIBHEAD) $$file ; \
done
# Set the version number into the files that mention it. These
# include version.ml, version.tex, META.
# include version.ml, StaticVersion.{ml,mli}, version.tex, META.
@ echo "-> Setting version to $(DATE)."
@ echo let version = \"$(DATE)\" > $(PACKAGE)/src/version.ml
@ echo version = \"$(DATE)\" >> $(PACKAGE)/src/META
@ echo "let require_$(DATE) = ()" > $(PACKAGE)/src/StaticVersion.ml
@ echo "val require_$(DATE) : unit" > $(PACKAGE)/src/StaticVersion.mli
# Copy and compile the documentation.
@ echo "-> Generating the documentation."
@ cp -r doc $(PACKAGE)
......
* Add a magic number to detect inconsistencies between Menhir and MenhirLib?
* Look for "artificial dependency" and remove them.
Make sure every module is explicitly called.
......
(* This file is overwritten when a package is created. It is supposed
to define a value of type [unit] whose name is [require_XXXXXXXX],
where [XXXXXXXX] is our 8-digit version number. *)
let require_unreleased =
()
(* This file is overwritten when a package is created. It is supposed
to define a value of type [unit] whose name is [require_XXXXXXXX],
where [XXXXXXXX] is our 8-digit version number. *)
val require_unreleased: unit
......@@ -15,3 +15,4 @@ TableFormat
InspectionTableFormat
InspectionTableInterpreter
TableInterpreter
StaticVersion
......@@ -58,6 +58,9 @@ let entry =
let start =
interpreter ^ ".start"
let staticVersion =
menhirlib ^ ".StaticVersion"
(* The following are names of internal sub-modules. *)
let basics =
......@@ -949,6 +952,19 @@ let first () =
(* ------------------------------------------------------------------------ *)
(* A reference to [MenhirLib.StaticVersion.require_XXXXXXXX], where [XXXXXXXX]
is our 8-digit version number. This ensures that the generated code can be
linked only with an appropriate version of MenhirLib. This is important
because we use unsafe casts, and a version mismatch could cause a crash. *)
let versiondef = {
valpublic = true;
valpat = PUnit;
valval = EVar (staticVersion ^ ".require_" ^ Version.version);
}
(* ------------------------------------------------------------------------ *)
(* Let's put everything together. *)
open UnparameterizedSyntax
......@@ -960,6 +976,15 @@ let program =
[ SIFunctor (grammar.parameters,
(* Make a reference to [MenhirLib.StaticVersion.require_XXXXXXXX], where
[XXXXXXXX] is our 8-digit version number. This ensures that the
generated code can be linked only with an appropriate version of
MenhirLib. This is important because we use unsafe casts, and a
version mismatch could cause a crash. *)
SIComment "This generated code requires the following version of MenhirLib:" ::
SIValDefs (false, [ versiondef ]) ::
(* 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 sub-module is used again below, as part of the
......
(* This file is overwritten when a package is created. The version
string is defined as an 8-digit version number [XXXXXXXX]. *)
(* During development, [version] is defined as ["unreleased"]. This
must match the name of the variable [version_unreleased] in the
module [StaticVersion]. *)
let version =
"<unreleased>" (* to be overridden when a package is created *)
"unreleased"
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