Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
6429a199
Commit
6429a199
authored
Nov 14, 2018
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refactoring.
parent
1913b6ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
src/nonTerminalDefinitionInlining.ml
src/nonTerminalDefinitionInlining.ml
+18
-5
No files found.
src/nonTerminalDefinitionInlining.ml
View file @
6429a199
...
...
@@ -326,25 +326,38 @@ let inline_branch caller (prefix, producer, suffix) (callee : branch) : branch =
let
inline_branches
caller
site
(
callees
:
branches
)
:
branches
=
List
.
map
(
inline_branch
caller
site
)
callees
(* A getter and transformer for branches. *)
let
branches
rule
=
rule
.
branches
let
transform_branches
f
rule
=
{
rule
with
branches
=
f
rule
.
branches
}
(* Inline a grammar. The resulting grammar does not contain any definitions
that can be inlined. *)
let
inline
grammar
=
(* Inline the non terminals that can be inlined in [caller]. We use the
ListMonad to combine the results. *)
let
rec
expand_branch
expand_symbol
(
caller
:
branch
)
:
branch
ListMonad
.
m
=
let
rec
expand_branch
expand_symbol
(
caller
:
branch
)
:
branch
es
=
match
find_inlining_site
grammar
([]
,
caller
.
producers
)
with
|
None
->
return
caller
|
Some
((
_prefix
,
producer
,
_suffix
)
as
site
)
->
let
symbol
=
producer_symbol
producer
in
let
rule
=
expand_symbol
symbol
in
inline_branches
caller
site
rule
.
branches
>>=
expand_branch
expand_symbol
expand_symbol
symbol
|>
branches
|>
inline_branches
caller
site
|>
expand_branches
expand_symbol
and
expand_branches
expand_symbol
branches
:
branches
=
branches
>>=
expand_branch
expand_symbol
in
let
expand_symbol
expand_symbol
symbol
:
rule
=
let
rule
=
find
grammar
symbol
in
{
rule
with
branches
=
rule
.
branches
>>=
expand_branch
expand_symbol
}
find
grammar
symbol
|>
transform_branches
(
expand_branches
expand_symbol
)
in
let
expand_symbol
:
Syntax
.
symbol
->
rule
=
...
...
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