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
M
menhir
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
51a6d3db
Commit
51a6d3db
authored
Jan 09, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified the implementation of [Lr1.incoming_symbol] by going through
[Lr0.incoming_symbol].
parent
dbc713c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
26 deletions
+9
-26
TODO
TODO
+0
-2
src/lr1.ml
src/lr1.ml
+9
-24
No files found.
TODO
View file @
51a6d3db
* Clean up Lr1.incoming_symbol by going through Lr0.
* Generate default printers for terminal and nonterminal.
Define printers for productions and items, parameterized
over printers for terminal and nonterminal.
...
...
src/lr1.ml
View file @
51a6d3db
...
...
@@ -40,11 +40,6 @@ type node = {
mutable
predecessors
:
node
list
;
(* If a node has any incoming transitions, then they all carry
the same symbol. This is it. *)
mutable
incoming_symbol
:
Symbol
.
t
option
;
(* Transient marks are used during construction and traversal. *)
mutable
mark
:
Mark
.
t
;
...
...
@@ -253,7 +248,6 @@ let create (state : Lr0.lr1state) : node =
number
=
0
;
(* temporary placeholder *)
mark
=
Mark
.
none
;
predecessors
=
[]
;
incoming_symbol
=
None
;
forbid_default_reduction
=
false
;
}
in
...
...
@@ -661,13 +655,6 @@ let () =
edges that carry distinct symbols. *)
SymbolMap
.
iter
(
fun
symbol
son
->
begin
match
son
.
incoming_symbol
with
|
None
->
son
.
incoming_symbol
<-
Some
symbol
|
Some
symbol'
->
assert
(
Symbol
.
equal
symbol
symbol'
)
end
;
son
.
predecessors
<-
node
::
son
.
predecessors
;
visit
(
Some
symbol
)
son
)
node
.
transitions
...
...
@@ -713,6 +700,13 @@ let bfs =
end
)
in
B
.
search
(* ------------------------------------------------------------------------ *)
(* The incoming symbol of a node can be computed by going through its LR(0)
core. For this reason, we do not need to explicitly record it here. *)
let
incoming_symbol
node
=
Lr0
.
incoming_symbol
(
Lr0
.
core
node
.
state
)
(* ------------------------------------------------------------------------ *)
(* Iteration over all nodes. *)
...
...
@@ -727,13 +721,13 @@ let map f =
let
foldx
f
=
fold
(
fun
accu
node
->
match
node
.
incoming_symbol
with
match
incoming_symbol
node
with
|
None
->
accu
|
Some
_
->
f
accu
node
)
let
iterx
f
=
iter
(
fun
node
->
match
node
.
incoming_symbol
with
match
incoming_symbol
node
with
|
None
->
()
|
Some
_
->
f
node
)
...
...
@@ -844,15 +838,6 @@ let conflicts f =
f
node
.
conflict_tokens
node
)
conflict_nodes
let
incoming_symbol
node
=
(* Instead of reading [node.incoming_symbol], we could return
[Lr0.incoming_symbol (Lr0.core node.state)].
We could then get rid of the field [node.incoming_symbol].
However, this field is also used in the construction of the
table [incoming], so we would have to change the code that
builds this table. TEMPORARY do it! *)
node
.
incoming_symbol
let
predecessors
node
=
node
.
predecessors
...
...
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