Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Franck Pommereau
/
snakes
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Franck Pommereau
2014-02-18 15:38:19 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
13f9f94d79f4c48579ef8e712a1df0e0d3d1658f
13f9f94d
1 parent
f706e190
improved let wrt .globals
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
snakes/nets.py
snakes/plugins/let.py
snakes/nets.py
View file @
13f9f94
...
...
@@ -907,10 +907,12 @@ class Expression (ArcAnnotation) :
else
:
env
=
binding
.
_dict
env
[
"__binding__"
]
=
binding
.
_dict
env
[
"__globals__"
]
=
self
.
globals
try
:
return
Token
(
self
.
globals
(
self
.
_expr
,
env
))
finally
:
del
env
[
"__binding__"
]
del
env
[
"__globals__"
]
def
__call__
(
self
,
binding
)
:
"""Returns the value from `bind` (but not encapsulated in a
`Token`).
...
...
snakes/plugins/let.py
View file @
13f9f94
...
...
@@ -67,11 +67,9 @@ def unlet (expr, *names) :
return
unparse
(
new
),
drop
.
calls
class
MakeLet
(
object
)
:
def
__init__
(
self
,
globals
)
:
self
.
globals
=
globals
def
match
(
self
,
match
,
binding
)
:
env
=
dict
(
binding
)
env
.
update
(
iter
(
self
.
globals
)
)
env
.
update
(
env
[
"__globals__"
]
)
exec
(
""
,
env
)
old
=
set
(
env
)
exec
(
match
,
env
)
...
...
@@ -95,5 +93,5 @@ def extend (module) :
class
PetriNet
(
module
.
PetriNet
)
:
def
__init__
(
self
,
name
,
**
args
)
:
module
.
PetriNet
.
__init__
(
self
,
name
,
**
args
)
self
.
globals
[
"let"
]
=
MakeLet
(
self
.
globals
)
self
.
globals
[
"let"
]
=
MakeLet
()
return
PetriNet
,
unlet
...
...
Please
register
or
login
to post a comment