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
0a0f45f1
Commit
0a0f45f1
authored
Jan 14, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved more code from [Calc] to [Printers].
parent
235c1b47
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
27 deletions
+38
-27
demos/calc-inspection/Makefile
demos/calc-inspection/Makefile
+1
-1
demos/calc-inspection/Printers.ml
demos/calc-inspection/Printers.ml
+27
-12
demos/calc-inspection/Printers.mli
demos/calc-inspection/Printers.mli
+8
-2
demos/calc-inspection/calc.ml
demos/calc-inspection/calc.ml
+2
-12
No files found.
demos/calc-inspection/Makefile
View file @
0a0f45f1
...
...
@@ -9,7 +9,7 @@ endif
# We assume that menhirLib has been installed in such a
# way that ocamlfind knows about it.
MENHIRFLAGS
:=
--table
--inspection
MENHIRFLAGS
:=
--table
--inspection
-v
-la
2
# -- infer is automatically added by ocamlbuild.
OCAMLBUILD
:=
ocamlbuild
-use-ocamlfind
-use-menhir
-menhir
"
$(MENHIR)
$(MENHIRFLAGS)
"
-package
menhirLib
...
...
demos/calc-inspection/Printers.ml
View file @
0a0f45f1
...
...
@@ -10,6 +10,7 @@ module Make
let
arrow
=
" -> "
let
dot
=
"."
let
space
=
" "
let
newline
=
"
\n
"
open
User
...
...
@@ -33,18 +34,6 @@ module Make
print_symbols
(
i
-
1
)
symbols
end
(* Printing an item. *)
let
print_item
(
prod
,
i
)
=
print_symbol
(
I
.
lhs
prod
);
print
arrow
;
print_symbols
i
(
I
.
rhs
prod
)
(* Printing a production (without a dot). *)
let
print_production
prod
=
print_item
(
prod
,
-
1
)
(* Printing an element as a symbol. *)
let
print_element_as_symbol
element
=
...
...
@@ -71,5 +60,31 @@ module Make
print
space
)
stack
()
(* Printing an item. *)
let
print_item
(
prod
,
i
)
=
print_symbol
(
I
.
lhs
prod
);
print
arrow
;
print_symbols
i
(
I
.
rhs
prod
);
print
newline
(* Printing a production (without a dot). *)
let
print_production
prod
=
print_item
(
prod
,
-
1
)
(* Printing the current LR(1) state. *)
let
print_current_state
env
=
print
"Current LR(1) state: "
;
match
Lazy
.
force
(
I
.
stack
env
)
with
|
I
.
Nil
->
print
"<some initial state>"
;
print
newline
|
I
.
Cons
(
I
.
Element
(
current
,
_
,
_
,
_
)
,
_
)
->
print
(
string_of_int
(
Obj
.
magic
current
));
(* TEMPORARY safe conversion needed *)
print
newline
;
List
.
iter
print_item
(
I
.
items
current
)
end
demos/calc-inspection/Printers.mli
View file @
0a0f45f1
...
...
@@ -33,13 +33,19 @@ module Make
val
print_stack
:
I
.
stack
->
unit
(* Printing an item. *)
(* Printing an item.
(Ending with a newline.)
*)
val
print_item
:
I
.
item
->
unit
(* Printing a production. *)
(* Printing a production.
(Ending with a newline.)
*)
val
print_production
:
I
.
production
->
unit
(* Printing the current LR(1) state. The current state is first displayed
as a number; then the list of its LR(0) items is printed. (Ending with
a newline.) *)
val
print_current_state
:
I
.
env
->
unit
end
demos/calc-inspection/calc.ml
View file @
0a0f45f1
...
...
@@ -75,18 +75,8 @@ module P =
let
dump
env
=
P
.
print_stack
(
I
.
stack
env
);
Printf
.
fprintf
stderr
"
\n
%!"
;
begin
match
Lazy
.
force
(
I
.
stack
env
)
with
|
I
.
Nil
->
()
|
I
.
Cons
(
I
.
Element
(
current
,
_
,
_
,
_
)
,
_
)
->
Printf
.
fprintf
stderr
"Current state: %d
\n
%!"
(
Obj
.
magic
current
);
let
items
=
I
.
items
current
in
List
.
iter
(
fun
item
->
P
.
print_item
item
;
Printf
.
fprintf
stderr
"
\n
%!"
)
items
end
;
print_newline
()
P
.
print_current_state
env
;
Printf
.
fprintf
stderr
"
\n
%!"
(* The loop which drives the parser. At each iteration, we analyze a
result produced by the parser, and act in an appropriate manner. *)
...
...
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