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
alphaLib
Commits
c5f91537
Commit
c5f91537
authored
Feb 16, 2017
by
POTTIER Francois
Browse files
Implement [ba] on top of [iter] instead of [reduce].
parent
2fc8078a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/AlphaLibMacros.cppo.ml
View file @
c5f91537
...
...
@@ -69,6 +69,8 @@
(* -------------------------------------------------------------------------- *)
(* [ba] could be defined in terms of [reduce], as follows. *)
#
define
BA_CLASS
__ba
#
define
BA_FUN
(
term
)
CONCAT
(
ba_
,
term
)
...
...
@@ -82,6 +84,26 @@
let
BA_FUN
(
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
...
...
src/KitBa.ml
View file @
c5f91537
(* This kit serves to compute the set of ``bound atoms'' of a term, that is,
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
)
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