Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Franck Pommereau
/
zinc
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
2018-04-03 14:09:53 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6561048c16e020df8a4f48b3132d0c7456b14762
6561048c
1 parent
602e2054
added Erathostene's sieve model
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
1 deletions
test/sieve-cs.zn
test/sieve-go.zn
test/sieve-py.zn
zinc/compil/go/codegen.py
test/sieve-cs.zn
0 → 100644
View file @
6561048
# Erathostenes' sieve (https://mcc.lip6.fr/pdf/Eratosthenes-form.pdf)
lang coffee
net "Erathostene sieve" :
place p number = 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
trans t n % d == 0 :
< p var = n
< p var = d
> p var = d
test/sieve-go.zn
0 → 100644
View file @
6561048
# Erathostenes' sieve (https://mcc.lip6.fr/pdf/Eratosthenes-form.pdf)
lang go
net "Erathostene sieve" :
place p int = 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
trans t n % d == 0 :
< p var = n
< p var = d
> p var = d
test/sieve-py.zn
0 → 100644
View file @
6561048
# Erathostenes' sieve (https://mcc.lip6.fr/pdf/Eratosthenes-form.pdf)
lang python
net "Erathostene sieve" :
place p int = 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
trans t n % d == 0 :
< p var = n
< p var = d
> p var = d
zinc/compil/go/codegen.py
View file @
6561048
...
...
@@ -30,7 +30,8 @@ class CodeGenerator (ast.CodeGenerator) :
self
.
write
(
preamble
%
{
"timestamp"
:
self
.
timestamp
(),
"package"
:
node
.
name
})
self
.
children_visit
(
node
.
body
)
self
.
fill
(
closing
)
if
node
.
name
==
"main"
:
self
.
fill
(
closing
)
def
_tupledef
(
self
,
typ
)
:
return
"_"
.
join
([
""
]
+
[
_letter
.
sub
(
""
,
self
.
typedef
[
t
])
for
t
in
typ
]
+
[
""
])
def
_typedef
(
self
,
typ
,
place
)
:
...
...
Please
register
or
login
to post a comment