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
A
alphaLib
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
POTTIER Francois
alphaLib
Commits
c5f91537
Commit
c5f91537
authored
Feb 16, 2017
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement [ba] on top of [iter] instead of [reduce].
parent
2fc8078a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
src/AlphaLibMacros.cppo.ml
src/AlphaLibMacros.cppo.ml
+22
-0
src/KitBa.ml
src/KitBa.ml
+18
-0
No files found.
src/AlphaLibMacros.cppo.ml
View file @
c5f91537
...
@@ -69,6 +69,8 @@
...
@@ -69,6 +69,8 @@
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* [ba] could be defined in terms of [reduce], as follows. *)
#
define
BA_CLASS
__ba
#
define
BA_CLASS
__ba
#
define
BA_FUN
(
term
)
CONCAT
(
ba_
,
term
)
#
define
BA_FUN
(
term
)
CONCAT
(
ba_
,
term
)
...
@@ -82,6 +84,26 @@
...
@@ -82,6 +84,26 @@
let
BA_FUN
(
term
)
t
=
\
let
BA_FUN
(
term
)
t
=
\
new
BA_CLASS
#
VISIT
(
term
)
()
t
\
new
BA_CLASS
#
VISIT
(
term
)
()
t
\
#
undef
__BA
#
undef
BA
(* -------------------------------------------------------------------------- *)
(* We prefer to define [ba] in terms of [iter] because we wish to eliminate
our dependency on [reduce] visitors. *)
#
define
__BA
\
class
[
'
self
]
BA_CLASS
=
object
(
_
:
'
self
)
\
inherit
[
_
]
iter
\
inherit
[
_
]
KitBa
.
iter
\
end
\
#
define
BA
(
term
)
\
let
BA_FUN
(
term
)
t
=
\
let
o
=
new
BA_CLASS
in
\
o
#
VISIT
(
term
)
()
t
;
\
o
#
accu
\
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
#
define
AVOIDS_CLASS
__avoids
#
define
AVOIDS_CLASS
__avoids
...
...
src/KitBa.ml
View file @
c5f91537
(* This kit serves to compute the set of ``bound atoms'' of a term, that is,
(* This kit serves to compute the set of ``bound atoms'' of a term, that is,
the set of all binding name occurrences. *)
the set of all binding name occurrences. *)
(* This computation can be performed either on top of an [iter] visitor, or
on top of a [reduce] visitor. *)
class
[
'
self
]
iter
=
object
(
_
:
'
self
)
val
mutable
accu
=
Atom
.
Set
.
empty
method
accu
=
accu
(* must be public *)
(* A bound atom is added to the accumulator when its scope is entered. *)
method
private
extend
x
()
=
accu
<-
Atom
.
Set
.
add
x
accu
method
private
visit_'fn
()
_x
=
()
end
class
[
'
self
]
reduce
=
object
(
_
:
'
self
)
class
[
'
self
]
reduce
=
object
(
_
:
'
self
)
method
private
extend
_x
()
=
method
private
extend
_x
()
=
...
...
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