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
6e4b8abf
Commit
6e4b8abf
authored
Sep 12, 2019
by
POTTIER Francois
Browse files
New function [Lr0.incoming_edges].
parent
2bd96cd5
Pipeline
#93297
passed with stages
in 25 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lr0.ml
View file @
6e4b8abf
...
...
@@ -244,6 +244,25 @@ let outgoing_edges node : node SymbolMap.t =
let
outgoing_symbols
node
:
Symbol
.
t
list
=
SymbolMap
.
domain
(
InfiniteArray
.
get
_transitions
node
)
(* Efficient access to the predecessors of an LR(0) state requires building
a reversed graph. This is done on the first invocation of the function
[predecessors]. Our measurements show that it typically takes less than
0.01s anyway. *)
let
predecessors
:
node
list
array
Lazy
.
t
=
lazy
(
let
predecessors
=
Array
.
make
n
[]
in
for
source
=
0
to
n
-
1
do
SymbolMap
.
iter
(
fun
_symbol
(
target
,
_
)
->
predecessors
.
(
target
)
<-
source
::
predecessors
.
(
target
)
)
(
InfiniteArray
.
get
_transitions
source
)
done
;
predecessors
)
let
incoming_edges
(
c
:
node
)
:
node
list
=
(
Lazy
.
force
predecessors
)
.
(
c
)
(* ------------------------------------------------------------------------ *)
(* Help for building the LR(1) automaton. *)
...
...
src/lr0.mli
View file @
6e4b8abf
...
...
@@ -43,6 +43,7 @@ val items: node -> Item.Set.t
incoming symbol) if and only if it is a start node. *)
val
incoming_symbol
:
node
->
Symbol
.
t
option
val
incoming_edges
:
node
->
node
list
(* The outgoing edges of a node. *)
...
...
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