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
837b9b6d
Commit
837b9b6d
authored
Jan 14, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed the function [view] to [stack].
Defined the type [stack] as an abbreviation for [element stream].
parent
ff9d5915
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
24 deletions
+33
-24
demos/calc-inspection/Printers.ml
demos/calc-inspection/Printers.ml
+1
-1
demos/calc-inspection/Printers.mli
demos/calc-inspection/Printers.mli
+2
-2
demos/calc-inspection/calc.ml
demos/calc-inspection/calc.ml
+2
-2
doc/main.tex
doc/main.tex
+1
-1
src/IncrementalEngine.ml
src/IncrementalEngine.ml
+19
-13
src/engine.ml
src/engine.ml
+8
-5
No files found.
demos/calc-inspection/Printers.ml
View file @
837b9b6d
...
...
@@ -95,7 +95,7 @@ module Make
)
stack
()
let
buffer_env
b
env
=
buffer_stack
b
(
I
.
view
env
)
buffer_stack
b
(
I
.
stack
env
)
let
print_stack
stack
=
with_buffer
buffer_stack
stack
...
...
demos/calc-inspection/Printers.mli
View file @
837b9b6d
...
...
@@ -19,8 +19,8 @@ module Make
printer. They use [print_element] if provided by the user; otherwise
they use [print_element_as_symbol]. *)
val
buffer_stack
:
Buffer
.
t
->
I
.
element
I
.
stream
->
unit
val
print_stack
:
I
.
element
I
.
stream
->
string
val
buffer_stack
:
Buffer
.
t
->
I
.
stack
->
unit
val
print_stack
:
I
.
stack
->
string
val
buffer_env
:
Buffer
.
t
->
I
.
env
->
unit
val
print_env
:
I
.
env
->
string
...
...
demos/calc-inspection/calc.ml
View file @
837b9b6d
...
...
@@ -75,8 +75,8 @@ module P =
(* Debugging. *)
let
dump
env
=
Printf
.
fprintf
stderr
"Stack
view
:
\n
%s
\n
%!"
(
P
.
print_env
env
);
begin
match
Lazy
.
force
(
I
.
view
env
)
with
Printf
.
fprintf
stderr
"Stack:
\n
%s
\n
%!"
(
P
.
print_env
env
);
begin
match
Lazy
.
force
(
I
.
stack
env
)
with
|
I
.
Nil
->
()
|
I
.
Cons
(
I
.
Element
(
current
,
_
,
_
,
_
)
,
_
)
->
...
...
doc/main.tex
View file @
837b9b6d
...
...
@@ -1952,7 +1952,7 @@ At this time, because the type \verb+env+ is opaque, the state of the parser
cannot be inspected by the user. We plan to offer an inspection API in the
near future.
% TEMPORARY
view
% TEMPORARY
stack
% TEMPORARY symbol
% TEMPORARY document the inspection API
...
...
src/IncrementalEngine.ml
View file @
837b9b6d
...
...
@@ -66,15 +66,6 @@ module type INCREMENTAL_ENGINE = sig
type
'
a
lr1state
(* An element is a pair of a non-initial state [s] and a semantic value [v]
associated with the incoming symbol of this state. The idea is, the value
[v] was pushed onto the stack just before the state [s] was entered. Thus,
for some type ['a], the type [s] has type ['a lr1state] and the value [v]
has type ['a]. In other words, the type [element] is an existential type. *)
type
element
=
|
Element
:
'
a
lr1state
*
'
a
*
Lexing
.
position
*
Lexing
.
position
->
element
(* A stream is a list whose elements are produced on demand. *)
type
'
a
stream
=
...
...
@@ -92,12 +83,27 @@ module type INCREMENTAL_ENGINE = sig
val
foldr
:
(
'
a
->
'
b
->
'
b
)
->
'
a
stream
->
'
b
->
'
b
(* The parser's state can be viewed as a stream of elements. This stream is
(* An element is a pair of a non-initial state [s] and a semantic value [v]
associated with the incoming symbol of this state. The idea is, the value
[v] was pushed onto the stack just before the state [s] was entered. Thus,
for some type ['a], the type [s] has type ['a lr1state] and the value [v]
has type ['a]. In other words, the type [element] is an existential type. *)
type
element
=
|
Element
:
'
a
lr1state
*
'
a
*
Lexing
.
position
*
Lexing
.
position
->
element
(* The parser's stack is (or, more precisely, can be viewed as) a stream of
elements. *)
type
stack
=
element
stream
(* The parser's stack, a stream of elements, can be examined. This stream is
empty if the parser is in an initial state; otherwise, it is non-empty.
The
parser's current LR(1) state is the one found in the top element of
this stream
. *)
The
LR(1) automaton's current state is the one found in the top element
of the stack
. *)
val
view
:
env
->
element
stream
val
stack
:
env
->
stack
end
...
...
src/engine.ml
View file @
837b9b6d
...
...
@@ -531,11 +531,14 @@ module Make (T : TABLE) = struct
type
element
=
|
Element
:
'
a
lr1state
*
'
a
*
Lexing
.
position
*
Lexing
.
position
->
element
type
stack
=
element
stream
(* If [current] is the current state and [cell] is the top stack cell,
then [
view
cell current] is a view of the parser's state as a stream
then [
stack
cell current] is a view of the parser's state as a stream
of elements. *)
let
rec
view
cell
current
:
element
stream
=
let
rec
stack
cell
current
:
element
stream
=
lazy
(
(* The stack is empty iff the top stack cell is its own successor. In
that case, the current state [current] should be an initial state
...
...
@@ -559,11 +562,11 @@ module Make (T : TABLE) = struct
cell
.
startp
,
cell
.
endp
)
in
Cons
(
element
,
view
next
cell
.
state
)
Cons
(
element
,
stack
next
cell
.
state
)
)
let
view
env
:
element
stream
=
view
env
.
stack
env
.
current
let
stack
env
:
element
stream
=
stack
env
.
stack
env
.
current
end
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