Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
48ba456c
Commit
48ba456c
authored
Sep 25, 2015
by
POTTIER Francois
Browse files
Improved --compare-messages to also compare the messages (if non-default).
parent
9ac0d3bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/LRijkstra.ml
View file @
48ba456c
...
...
@@ -1143,13 +1143,13 @@ let display (nt, w, s') : unit =
blank line, followed with a proposed error message, followed with
another blank line. *)
Printf
.
printf
"%s: %s
\n
# Length: %d
\n
# Leads to an error in state: %d.
\n
%s
\n
%s
\n
\n
"
"%s: %s
\n
# Length: %d
\n
# Leads to an error in state: %d.
\n
%s
\n
%s
\n
"
(
Nonterminal
.
print
false
nt
)
(
W
.
print
w
)
(
W
.
length
w
)
(
Lr1
.
number
s'
)
(
Lr0
.
print_closure
"# "
(
Lr1
.
state
s'
))
"Syntax error."
Interpret
.
default_message
(* Perform the forward search. *)
...
...
src/LRijkstra.mli
View file @
48ba456c
...
...
@@ -3,8 +3,8 @@
an error, a minimal path (starting in some initial state) that actually
triggers this error. *)
(* The result of this analysis is
written to the standard output channel.
No result is returned. *)
(* The result of this analysis is
a [.messages] file. It is written to the
standard output channel.
No result is returned. *)
module
Run
(
X
:
sig
(* If [verbose] is set, produce various messages on [stderr]. *)
...
...
src/interpret.ml
View file @
48ba456c
...
...
@@ -461,6 +461,9 @@ let () =
state that appears on the left-hand side appears on the right-hand side as
well. *)
let
default_message
=
"<YOUR SYNTAX ERROR MESSAGE HERE>
\n
"
let
()
=
Settings
.
compare_errors
|>
Option
.
iter
(
fun
(
filename1
,
filename2
)
->
...
...
@@ -484,15 +487,23 @@ let () =
(* Check that [table1] is a subset of [table2], that is, for every state
[s] in the domain of [table1], [s] is mapped by [table1] and [table2]
to the same error message. *)
to the same error message. As an exception, if the message found in
[table1] is the default message, then no comparison takes place. This
allows using [--list-errors] and [--compare-errors] in conjunction to
ensure that a [.messages] file is complete, without seeing warnings
about different messages. *)
table1
|>
Lr1
.
NodeMap
.
iter
(
fun
s
((
poss1
,
_
)
,
message1
)
->
let
(
poss2
,
_
)
,
message2
=
Lr1
.
NodeMap
.
find
s
table2
in
if
message1
<>
message2
then
Error
.
warning
(
poss1
@
poss2
)
(
Printf
.
sprintf
"These sentences lead to an error in state %d.
\n
\
The corresponding messages in
\"
%s
\"
and
\"
%s
\"
differ."
(
Lr1
.
number
s
)
filename1
filename2
)
if
message1
<>
default_message
then
try
let
(
poss2
,
_
)
,
message2
=
Lr1
.
NodeMap
.
find
s
table2
in
if
message1
<>
message2
then
Error
.
warning
(
poss1
@
poss2
)
(
Printf
.
sprintf
"These sentences lead to an error in state %d.
\n
\
The corresponding messages in
\"
%s
\"
and
\"
%s
\"
differ."
(
Lr1
.
number
s
)
filename1
filename2
)
with
Not_found
->
()
);
if
Error
.
errors
()
then
exit
1
;
...
...
src/interpret.mli
View file @
48ba456c
(* This module is in charge of handling the [--interpret] option,
if it is present. It offers no functionality. *)
(* This module is in charge of handling several command line options, namely
[--interpret], [--interpret-error], [--compile-errors], [--compare-errors].
If any of these options is present, the execution of Menhir stops here. *)
(* This default error message is produced by [--list-errors] when it creates a
[.messages] file, and is recognized by [--compare-errors] when it compares
two such files. *)
val
default_message
:
string
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment