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
aea80b11
Commit
aea80b11
authored
Sep 26, 2019
by
POTTIER Francois
Browse files
New functions [transition_tokens] and [reduction_tokens] in Lr0.
parent
5580435d
Changes
2
Hide whitespace changes
Inline
Sidebyside
src/lr0.ml
View file @
aea80b11
...
...
@@ 371,6 +371,16 @@ let transition
in
(
k
,
Array
.
map
(
interpret
state
)
sr
)
(* [transition_tokens transitions] returns the set of tokens (terminal symbols)
that are labels of outgoing transitions in the table [transitions]. *)
let
transition_tokens
transitions
=
SymbolMap
.
fold
(
fun
symbol
_target
toks
>
match
symbol
with

Symbol
.
T
tok
>
TerminalSet
.
add
tok
toks

Symbol
.
N
_
>
toks
)
transitions
TerminalSet
.
empty
(* Equality of states. *)
let
equal
((
k1
,
toksr1
)
as
state1
)
((
k2
,
toksr2
)
as
state2
)
=
...
...
@@ 636,6 +646,14 @@ let reductions_table state =
add_reductions
prod
toks
reductions
)
TerminalMap
.
empty
(
reductions
state
)
(* [reduction_tokens reductions] returns the domain of the reductions table
[table], in the form of a set of tokens. *)
let
reduction_tokens
reductions
=
TerminalMap
.
fold
(
fun
tok
_prods
toks
>
TerminalSet
.
add
tok
toks
)
reductions
TerminalSet
.
empty
(* This inverts a mapping of tokens to productions into a mapping of
productions to sets of tokens. *)
...
...
src/lr0.mli
View file @
aea80b11
...
...
@@ 85,6 +85,11 @@ val start: node > lr1state
val
transitions
:
lr1state
>
lr1state
SymbolMap
.
t
val
transition
:
Symbol
.
t
>
lr1state
>
lr1state
(* [transition_tokens transitions] returns the set of tokens (terminal symbols)
that are labels of outgoing transitions in the table [transitions]. *)
val
transition_tokens
:
'
target
SymbolMap
.
t
>
TerminalSet
.
t
(* Information about the reductions at a state. *)
(* See also [reductions_table] further on. *)
...
...
@@ 169,6 +174,11 @@ val reductions_table: lr1state > reductions
val
invert
:
reductions
>
TerminalSet
.
t
ProductionMap
.
t
(* [reduction_tokens reductions] returns the domain of the reductions table
[table], in the form of a set of tokens. *)
val
reduction_tokens
:
reductions
>
TerminalSet
.
t
(* [has_eos_conflict transitions reductions] tells whether a state has
an endofstream conflict, that is, a reduction action on [#] and
at least one other (shift or reduce) action. *)
...
...
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