Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
POTTIER Francois
menhir
Commits
7edf2fe5
Commit
7edf2fe5
authored
Nov 13, 2018
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline away the function [find_inline_producer].
parent
4a915a07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
src/nonTerminalDefinitionInlining.ml
src/nonTerminalDefinitionInlining.ml
+8
-11
No files found.
src/nonTerminalDefinitionInlining.ml
View file @
7edf2fe5
...
...
@@ -163,10 +163,11 @@ let inline grammar =
r
in
(* [find_inline_producer b] traverses the producers of the branch [b] and
looks for the first nonterminal symbol that can be inlined. If it finds
one, it inlines its branches into [b], which is why this function can
return several branches. Otherwise, it raises [NoInlining]. *)
(* [chop_inline (prefix, suffix)] traverses the producers of the branch [b],
which already are decomposed under the form [List.rev prefix @ suffix].
It looks for the first nonterminal symbol that can be inlined away. If it
finds one, it inlines its branches into [b], which is why this function
can return several branches. Otherwise, it raises [NoInlining]. *)
let
rec
chop_inline
(
prefix
,
suffix
)
=
match
suffix
with
|
[]
->
...
...
@@ -191,17 +192,13 @@ let inline grammar =
chop_inline
(
x
::
prefix
,
xs
)
in
let
rec
find_inline_producer
b
=
let
prefix
,
nt
,
p
,
c
,
suffix
=
chop_inline
([]
,
b
.
producers
)
in
let
p
=
expand_rule
nt
p
in
prefix
,
p
,
nt
,
c
,
suffix
(* Inline the non terminals that can be inlined in [b]. We use the
ListMonad to combine the results. *)
and
expand_branch
(
b
:
branch
)
:
branch
ListMonad
.
m
=
let
rec
expand_branch
(
b
:
branch
)
:
branch
ListMonad
.
m
=
try
(* [c] is the identifier under which the callee is known. *)
let
prefix
,
p
,
nt
,
c
,
suffix
=
find_inline_producer
b
in
let
prefix
,
nt
,
p
,
c
,
suffix
=
chop_inline
([]
,
b
.
producers
)
in
let
p
=
expand_rule
nt
p
in
(* These are the names of the producers in the host branch,
minus the producer that is being inlined away. *)
let
used
=
StringSet
.
union
(
names
prefix
)
(
names
suffix
)
in
...
...
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