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
35e59e49
Commit
35e59e49
authored
Dec 06, 2017
by
POTTIER Francois
Browse files
Front: implement selective expansion + safety test + full expansion.
parent
82b7a883
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/front.ml
View file @
35e59e49
...
...
@@ -76,9 +76,21 @@ let sorts =
to obtain a grammar without parameterized nonterminal symbols. *)
let
grammar
:
UnparameterizedSyntax
.
grammar
=
(* TEMPORARY do selective expansion first *)
CheckSafeParameterizedGrammar
.
check
grammar
;
Drop
.
drop
(
SelectiveExpansion
.
expand
SelectiveExpansion
.
ExpandAll
sorts
grammar
)
let
module
S
=
SelectiveExpansion
in
(* First, perform a selective expansion: expand away all parameters of
higher sort, keeping the parameters of sort [*]. This process always
terminates. *)
let
grammar1
=
S
.
expand
S
.
ExpandHigherSort
sorts
grammar
in
(* This "first-order parameterized grammar" can then be submitted to
the termination check. *)
CheckSafeParameterizedGrammar
.
check
grammar1
;
(* If it passes the check, then full expansion is safe. We drop [grammar1]
and start over from [grammar]. This is required in order to get correct
names. (Expanding [grammar1] would yield an equivalent grammar, with
more complicated names, reflecting the two steps of expansion.) *)
let
grammar
=
S
.
expand
S
.
ExpandAll
sorts
grammar
in
(* This yields an unparameterized grammar. *)
Drop
.
drop
grammar
let
()
=
Time
.
tick
"Joining and expanding"
...
...
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