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
ea998e61
Commit
ea998e61
authored
Sep 18, 2019
by
POTTIER Francois
Browse files
Refactoring in [Lr1]: record a node's incoming symbol when an edge is traversed.
parent
257c79c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lr1.ml
View file @
ea998e61
...
...
@@ -433,11 +433,9 @@ let lookup_incoming symbol =
with
Not_found
->
[]
let
record_incoming
osymbol
target
=
Option
.
iter
(
fun
symbol
->
let
targets
=
lookup_incoming
symbol
in
incoming
:=
SymbolMap
.
add
symbol
(
target
::
targets
)
!
incoming
)
osymbol
let
record_incoming
symbol
target
=
let
targets
=
lookup_incoming
symbol
in
incoming
:=
SymbolMap
.
add
symbol
(
target
::
targets
)
!
incoming
(* ------------------------------------------------------------------------ *)
(* We now perform one depth-first traversal of the automaton,
...
...
@@ -480,11 +478,10 @@ let () =
let
marked
=
Mark
.
fresh
()
in
let
rec
visit
osymbol
node
=
let
rec
visit
node
=
if
not
(
Mark
.
same
node
.
mark
marked
)
then
begin
node
.
mark
<-
marked
;
nodes
:=
node
::
!
nodes
;
record_incoming
osymbol
node
;
(* Number this node. *)
...
...
@@ -662,12 +659,14 @@ let () =
SymbolMap
.
iter
(
fun
symbol
son
->
son
.
predecessors
<-
node
::
son
.
predecessors
;
visit
(
Some
symbol
)
son
if
not
(
Mark
.
same
son
.
mark
marked
)
then
record_incoming
symbol
son
;
visit
son
)
node
.
transitions
end
in
ProductionMap
.
iter
(
fun
_
node
->
visit
None
node
)
entry
ProductionMap
.
iter
(
fun
_
node
->
visit
node
)
entry
let
nodes
=
List
.
rev
!
nodes
(* list is now sorted by increasing node numbers *)
...
...
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