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
64e01756
Commit
64e01756
authored
Jul 02, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temporary state where the two definitions of [nullable_first_prod]
are checked to produce the same results.
parent
6d4c8892
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
21 deletions
+28
-21
src/grammar.ml
src/grammar.ml
+28
-21
No files found.
src/grammar.ml
View file @
64e01756
...
...
@@ -993,29 +993,33 @@ let () =
TerminalSet
.
compare
original
updated
<>
0
)
module
FIRST
=
GenericAnalysis
(
TerminalSet
)
(
struct
(* A terminal symbol has a singleton FIRST set. *)
let
terminal
=
TerminalSet
.
singleton
(* The FIRST set of an alternative is the union of the FIRST sets. *)
let
disjunction
p
q
=
TerminalSet
.
union
p
(
Lazy
.
force
q
)
(* The FIRST set of a sequence is the union of:
the FIRST set of the first member, and
the FIRST set of the second member, if the first member is nullable. *)
let
conjunction
symbol
p
q
=
if
NULLABLE
.
symbol
symbol
then
TerminalSet
.
union
p
(
Lazy
.
force
q
)
else
p
(* The FIRST set of the empty sequence is empty. *)
let
epsilon
=
TerminalSet
.
empty
end
)
let
first'
,
_first_prod'
,
_first_symbol'
=
let
module
FIRST
=
GenericAnalysis
(
TerminalSet
)
(
struct
(* A terminal symbol has a singleton FIRST set. *)
let
terminal
=
TerminalSet
.
singleton
(* The FIRST set of an alternative is the union of the FIRST sets. *)
let
disjunction
p
q
=
TerminalSet
.
union
p
(
Lazy
.
force
q
)
(* The FIRST set of a sequence is the union of:
the FIRST set of the first member, and
the FIRST set of the second member, if the first member is nullable. *)
let
conjunction
symbol
p
q
=
if
NULLABLE
.
symbol
symbol
then
TerminalSet
.
union
p
(
Lazy
.
force
q
)
else
p
(* The FIRST set of the empty sequence is empty. *)
let
epsilon
=
TerminalSet
.
empty
end
)
in
FIRST
.
nonterminal
,
FIRST
.
production
,
FIRST
.
symbol
let
nullable_first_prod'
prod
i
=
NULLABLE
.
production
prod
i
,
FIRST
.
production
prod
i
(* TEMPORARY sanity check *)
let
()
=
for
nt
=
Nonterminal
.
start
to
Nonterminal
.
n
-
1
do
...
...
@@ -1272,7 +1276,10 @@ module Analysis = struct
let
nullable_first_prod
prod
i
=
let
rhs
=
Production
.
rhs
prod
in
nullable_first_rhs
rhs
i
let
n
,
f
=
nullable_first_rhs
rhs
i
in
let
n'
,
f'
=
nullable_first_prod'
prod
i
in
assert
(
n
=
n'
&&
TerminalSet
.
equal
f
f'
);
n
,
f
let
explain_first_rhs
(
tok
:
Terminal
.
t
)
(
rhs
:
Symbol
.
t
array
)
(
i
:
int
)
=
convert
(
explain
tok
rhs
i
)
...
...
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