Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
aa7efa74
Commit
aa7efa74
authored
Feb 02, 2020
by
POTTIER Francois
Committed by
POTTIER Francois
Feb 10, 2020
Browse files
LALR: avoid enqueueing a node twice.
parent
7d18dd12
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/LALR.ml
View file @
aa7efa74
...
...
@@ -85,8 +85,17 @@ let follow_state (msg : string) (node : node) (print : bool) =
let
queue
:
node
Queue
.
t
=
Queue
.
create
()
(* The Boolean array [queued] keeps track of which nodes are in the queue and
allows us to avoid enqueueing a node when it is already in the queue. *)
let
queued
:
bool
array
=
Array
.
make
n
false
let
schedule
node
=
Queue
.
add
node
queue
if
not
queued
.
(
node
)
then
begin
queued
.
(
node
)
<-
true
;
Queue
.
add
node
queue
end
(* -------------------------------------------------------------------------- *)
...
...
@@ -143,7 +152,14 @@ let () =
(* As a long as the queue is nonempty, examine the nodes in it. *)
let
()
=
Misc
.
qiter
examine
queue
try
while
true
do
let
node
=
Queue
.
take
queue
in
queued
.
(
node
)
<-
false
;
examine
node
done
with
Queue
.
Empty
->
()
(* -------------------------------------------------------------------------- *)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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