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
Open sidebar
POTTIER Francois
menhir
Commits
6b027bc8
Commit
6b027bc8
authored
Oct 02, 2019
by
POTTIER Francois
Committed by
POTTIER Francois
Jan 30, 2020
Browse files
New function [Lr0.new_numbering].
parent
efc97c8a
Changes
2
Hide whitespace changes
Inline
Sidebyside
Showing
2 changed files
with
29 additions
and
0 deletions
+29
0
src/lr0.ml
src/lr0.ml
+22
0
src/lr0.mli
src/lr0.mli
+7
0
No files found.
src/lr0.ml
View file @
6b027bc8
...
...
@@ 423,6 +423,28 @@ let subsume ((k1, toksr1) as state1) ((k2, toksr2) as state2) =
in
loop
(
Array
.
length
toksr1
)
(* A memoizer for the type [lr1state]. This code is simpleminded, but its
efficiency is sufficient: 10000 states are numbered in about 0.01s. *)
module
M
=
Memoize
.
ForOrderedType
(
struct
type
t
=
lr1state
let
compare
s1
s2
=
let
c
=
core
s1

core
s2
in
if
c
<>
0
then
c
else
compare
s1
s2
end
)
(* A facility for assigning unique numbers to LR(1) states. *)
let
new_numbering
()
=
let
m
=
ref
0
in
let
number
:
lr1state
>
int
=
M
.
memoize
(
fun
(
_
:
lr1state
)
>
Misc
.
postincrement
m
)
and
current
()
=
!
m
in
number
,
current
(* This function determines whether two (coreequivalent) states are
compatible, according to a criterion that is close to Pager's weak
compatibility criterion.
...
...
src/lr0.mli
View file @
6b027bc8
...
...
@@ 114,6 +114,13 @@ val compare: lr1state > lr1state > int
val
subsume
:
lr1state
>
lr1state
>
bool
(* A facility for assigning unique numbers to LR(1) states. The call
[new_numbering] returns a pair of functions [number, current], where
[number] maps LR(1) states to unique (freshly assigned) numbers and
[current] returns the next available number. *)
val
new_numbering
:
unit
>
(
lr1state
>
int
)
*
(
unit
>
int
)
(* A slightly modified version of Pager's weak compatibility
criterion. The two states must have the same core. *)
...
...
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