Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
899b2889
Commit
899b2889
authored
Sep 12, 2019
by
POTTIER Francois
Browse files
New function [Lr0.compare].
parent
2294287c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lr0.ml
View file @
899b2889
...
...
@@ -363,6 +363,20 @@ let equal ((k1, toksr1) as state1) ((k2, toksr2) as state2) =
in
loop
(
Array
.
length
toksr1
)
(* A total order on states. *)
let
compare
((
k1
,
toksr1
)
as
state1
)
((
k2
,
toksr2
)
as
state2
)
=
assert
(
k1
=
k2
&&
well_formed
state1
&&
well_formed
state2
);
let
rec
loop
i
=
if
i
=
0
then
0
else
let
i
=
i
-
1
in
let
c
=
TerminalSet
.
compare
toksr1
.
(
i
)
toksr2
.
(
i
)
in
if
c
<>
0
then
c
else
loop
i
in
loop
(
Array
.
length
toksr1
)
(* Subsumption between states. *)
let
subsume
((
k1
,
toksr1
)
as
state1
)
((
k2
,
toksr2
)
as
state2
)
=
...
...
src/lr0.mli
View file @
899b2889
...
...
@@ -88,6 +88,12 @@ val reductions: lr1state -> (TerminalSet.t * Production.index) list
val
equal
:
lr1state
->
lr1state
->
bool
(* A total order on states. The two states must have the same core.
This is an arbitrary total order; it has nothing to do with set
inclusion, which is a partial order; see [subsume] below. *)
val
compare
:
lr1state
->
lr1state
->
int
(* Subsumption between states. The two states must have the same
core. Then, one subsumes the other if and only if their lookahead
sets are (pointwise) in the subset relation. *)
...
...
@@ -128,4 +134,3 @@ val restrict: TerminalSet.t -> lr1state -> lr1state
val
print_concrete
:
string
->
concretelr1state
->
string
val
print
:
string
->
lr1state
->
string
val
print_closure
:
string
->
lr1state
->
string
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