Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
d1df6b87
Commit
d1df6b87
authored
Apr 03, 2017
by
POTTIER Francois
Browse files
Replaced [error_state] with [current_state_number],
which is more general, as it takes an [env].
parent
b70e708d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Engine.ml
View file @
d1df6b87
...
...
@@ -718,12 +718,8 @@ module Make (T : TABLE) = struct
env1
.
stack
==
env2
.
stack
&&
number
env1
.
current
=
number
env2
.
current
let
error_state
checkpoint
=
match
checkpoint
with
|
HandlingError
env
->
number
env
.
current
|
_
->
invalid_arg
"error_state expects HandlingError"
let
current_state_number
env
=
number
env
.
current
(* ------------------------------------------------------------------------ *)
...
...
src/IncrementalEngine.ml
View file @
d1df6b87
...
...
@@ -281,14 +281,13 @@ module type INCREMENTAL_ENGINE = sig
val
get
:
int
->
'
a
env
->
element
option
(* [error_state checkpoint] requires [checkpoint] to be of the form
[HandlingError env]. Out of [env], it extracts the automaton's current
state, and returns this state, as an integer number. (This works even if
the automaton's stack is empty, in which case the current state is an
initial state.) This number can then be used as an argument to a
[message] function that was generated by [menhir --compile-errors]. *)
val
error_state
:
'
a
checkpoint
->
int
(* [current_state_number env] returns (the integer number of) the automaton's
current state. This works even if the automaton's stack is empty, in which
case the current state is an initial state. This number can be used as an
argument to a [message] function that was generated by [menhir
--compile-errors]. *)
val
current_state_number
:
'
a
env
->
int
(* [equal env1 env2] tells whether the parser configurations [env1] and
[env2] are equal in the sense that the automaton's current state is
...
...
src/fancyDriver.ml
View file @
d1df6b87
...
...
@@ -22,10 +22,10 @@ open Parser.MenhirInterpreter (* incremental API to our parser *)
(* [fail] is invoked if a syntax error is encountered. *)
let
fail
lexbuf
checkpoint
=
let
fail
lexbuf
env
=
(* The parser has suspended itself because of a syntax error. Stop.
Find out which state the parser is currently in. *)
let
s
:
int
=
error_state
checkpoint
in
let
s
:
int
=
current_state_number
env
in
(* Display a nice error message. In principle, the table found in
[ParserMessages] should be complete, so we should obtain
a nice message. If [Not_found] is raised, we produce a generic
...
...
@@ -43,6 +43,13 @@ let fail lexbuf checkpoint =
(* Display our message and die. *)
Error
.
error
(
Positions
.
lexbuf
lexbuf
)
"syntax error.
\n
%s"
message
let
fail
lexbuf
checkpoint
=
match
checkpoint
with
|
HandlingError
env
->
fail
lexbuf
env
|
_
->
assert
false
(* this cannot happen *)
(* The entry point. *)
let
grammar
lexer
lexbuf
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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