Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
1fec3725
Commit
1fec3725
authored
Jan 18, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose shift events in the incremental API.
parent
35135c20
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
11 deletions
+30
-11
CHANGES
CHANGES
+4
-0
demos/calc-incremental/calc.ml
demos/calc-incremental/calc.ml
+2
-1
src/IncrementalEngine.ml
src/IncrementalEngine.ml
+10
-7
src/engine.ml
src/engine.ml
+14
-3
No files found.
CHANGES
View file @
1fec3725
2015/01/18:
Incompatible change of the incremental API.
The incremental API now exposes shift events too.
2015/01/16:
Fixed a couple bugs in Makefile and src/Makefile which would cause
compilation and installation to fail with "TARGET=byte". (Reported
...
...
demos/calc-incremental/calc.ml
View file @
1fec3725
...
...
@@ -20,7 +20,8 @@ let rec loop lexbuf (result : int I.result) =
and
endp
=
lexbuf
.
Lexing
.
lex_curr_p
in
let
result
=
I
.
offer
result
(
token
,
startp
,
endp
)
in
loop
lexbuf
result
|
I
.
AboutToReduce
(
env
,
prod
)
->
|
I
.
Shifting
_
|
I
.
AboutToReduce
_
->
let
result
=
I
.
resume
result
in
loop
lexbuf
result
|
I
.
HandlingError
env
->
...
...
src/IncrementalEngine.ml
View file @
1fec3725
...
...
@@ -19,16 +19,18 @@ module type INCREMENTAL_ENGINE = sig
(* [InputNeeded] is an intermediate result. It means that the parser wishes
to read one token before continuing. *)
(* [Shifting] is an intermediate result. It means that the parser is taking
a shift transition. It exposes the state of the parser before and after
the transition. The Boolean parameter tells whether the parser intends to
request a new token after this transition. (It always does, except when
it is about to accept.) *)
(* [AboutToReduce] is an intermediate result. It means that the parser is
about to perform a reduction step. It does not need more input at this
point. The parser suspends itself at this point only in order to give the
user an opportunity to observe this reduction step. *)
about to perform a reduction step. It exposes the parser's current
state as well as the production that is about to be reduced. *)
(* [HandlingError] is an intermediate result. It means that the parser has
detected an error and is currently handling it, in several steps. It does
not need more input at this point. The parser suspends itself at this
point only in order to give the user an opportunity to handle this error
in a different manner, if desired. *)
detected an error and is currently handling it, in several steps. *)
type
env
...
...
@@ -36,6 +38,7 @@ module type INCREMENTAL_ENGINE = sig
type
'
a
result
=
private
|
InputNeeded
of
env
|
Shifting
of
env
*
env
*
bool
|
AboutToReduce
of
env
*
production
|
HandlingError
of
env
|
Accepted
of
'
a
...
...
src/engine.ml
View file @
1fec3725
...
...
@@ -28,6 +28,7 @@ module Make (T : TABLE) = struct
type
'
a
result
=
|
InputNeeded
of
env
|
Shifting
of
env
*
env
*
bool
|
AboutToReduce
of
env
*
production
|
HandlingError
of
env
|
Accepted
of
'
a
...
...
@@ -176,9 +177,16 @@ module Make (T : TABLE) = struct
(* Switch to state [s']. *)
let
current
=
s'
in
let
env
=
{
env
with
stack
;
current
}
in
run
env
please_discard
let
new_env
=
{
env
with
stack
;
current
=
s'
}
in
(* Expose the transition to the user. (In principle, we have a choice
between exposing the transition before we take it, after we take
it, or at some point in between. This affects the number and type
of the parameters carried by [Shifting]. Here, we choose to expose
the transition after we take it; this allows [Shifting] to carry
only three parameters, whose meaning is simple.) *)
Shifting
(
env
,
new_env
,
please_discard
)
(* --------------------------------------------------------------------------- *)
...
...
@@ -411,6 +419,8 @@ module Make (T : TABLE) = struct
let
resume
:
'
a
.
'
a
result
->
'
a
result
=
function
|
HandlingError
env
->
Obj
.
magic
error
env
|
Shifting
(
_
,
env
,
please_discard
)
->
Obj
.
magic
run
env
please_discard
|
AboutToReduce
(
env
,
prod
)
->
Obj
.
magic
reduce
env
prod
|
_
->
...
...
@@ -458,6 +468,7 @@ module Make (T : TABLE) = struct
let
triple
=
read
()
in
let
result
=
offer
result
triple
in
loop
read
result
|
Shifting
_
|
AboutToReduce
_
|
HandlingError
_
->
(* The parser has suspended itself, but does not need
...
...
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