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
daa8b955
Commit
daa8b955
authored
Dec 27, 2014
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified [calc-incremental] to do a quick test of the [view] function.
parent
ed8b8965
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
demos/calc-incremental/calc.ml
demos/calc-incremental/calc.ml
+18
-0
No files found.
demos/calc-incremental/calc.ml
View file @
daa8b955
...
...
@@ -3,6 +3,21 @@
module
I
=
Parser
.
MenhirInterpreter
(* The length of a stream. *)
let
rec
length
xs
=
match
Lazy
.
force
xs
with
|
I
.
Nil
->
0
|
I
.
Cons
(
_
,
xs
)
->
1
+
length
xs
(* A measure of the stack height. Used as a primitive way of
testing the [view] function. *)
let
height
env
=
length
(
I
.
view
env
)
(* Define the loop which drives the parser. At each iteration,
we analyze a result produced by the parser, and act in an
appropriate manner. *)
...
...
@@ -10,6 +25,9 @@ module I =
let
rec
loop
linebuf
(
result
:
int
I
.
result
)
=
match
result
with
|
I
.
InputNeeded
env
->
(* TEMPORARY *)
if
false
then
Printf
.
fprintf
stderr
"Stack height: %d
\n
%!"
(
height
env
);
(* The parser needs a token. Request one from the lexer,
and offer it to the parser, which will produce a new
result. Then, repeat. *)
...
...
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