pax_global_header 0000666 0000000 0000000 00000000064 15004313365 0014512 g ustar 00root root 0000000 0000000 52 comment=cdbc9ebc99e720e9bbc79753a06b27e81365940a
snek-1.12/ 0000775 0000000 0000000 00000000000 15004313365 0012375 5 ustar 00root root 0000000 0000000 snek-1.12/.github/ 0000775 0000000 0000000 00000000000 15004313365 0013735 5 ustar 00root root 0000000 0000000 snek-1.12/.github/Dockerfile 0000664 0000000 0000000 00000001404 15004313365 0015726 0 ustar 00root root 0000000 0000000 FROM debian:unstable AS download-tarballs
RUN apt-get update && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
build-essential \
libreadline-dev \
avr-libc \
gcc-avr \
gcc-arm-none-eabi \
gcc-riscv64-unknown-elf \
picolibc-arm-none-eabi \
picolibc-riscv64-unknown-elf \
python3 \
lola \
gawk \
asciidoctor \
ruby-asciidoctor-pdf \
ruby-coderay \
gcc-arm-linux-gnueabi \
libc6-dev-armel-cross \
qemu-system-misc \
qemu-system-arm \
black \
python3-pip \
python3-serial \
nsis \
rsync \
genisoimage \
zip \
gcc-mingw-w64 \
librsvg2-bin \
icoutils \
icnsutils \
black && \
pip3 install --break-system-packages pynsist
snek-1.12/.github/dependabot.yml 0000664 0000000 0000000 00000000224 15004313365 0016563 0 ustar 00root root 0000000 0000000 version: 2
updates:
- package-ecosystem: github-actions
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
snek-1.12/.github/workflows/ 0000775 0000000 0000000 00000000000 15004313365 0015772 5 ustar 00root root 0000000 0000000 snek-1.12/.github/workflows/snek.yml 0000664 0000000 0000000 00000004634 15004313365 0017464 0 ustar 00root root 0000000 0000000 name: snek
on:
push:
branches:
- main
pull_request:
branches:
- main
# When a PR is updated, cancel the jobs from the previous version. Merges
# do not define head_ref, so use run_id to never cancel those jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
IMAGE_FILE: dockerimg.tar.zst
IMAGE: snek
DOCKER_FILE: snek/.github/Dockerfile
jobs:
cache-maker:
runs-on: ubuntu-latest
steps:
- name: 'Clone snek'
uses: actions/checkout@v4
with:
path: snek
- name: Check for Docker Image
id: cache
uses: actions/cache@v4
with:
path: ${{ env.IMAGE_FILE }}
key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKER_FILE ) }}
lookup-only: true
- name: Set up Docker build
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v3
- name: Build snek container
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
file: .github/Dockerfile
tags: ${{ env.IMAGE }}:latest
outputs: type=docker,force-compression=true,compression=zstd,compression-level=22,dest=${{ env.IMAGE_FILE }}
test-snek:
needs: cache-maker
runs-on: ubuntu-latest
steps:
- name: 'Clone snek'
uses: actions/checkout@v4
with:
path: snek
- name: Restore the Docker Image
uses: actions/cache@v4
with:
path: ${{ env.IMAGE_FILE }}
key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKER_FILE ) }}
fail-on-cache-miss: true
- name: Load Docker image
run: |
docker load -i $IMAGE_FILE
docker images -a $IMAGE
- name: 'Create install destination'
run: |
mkdir -p artifacts
- name: 'Build snek'
run: |
docker run \
-v $(readlink -f snek):/snek \
-v $(readlink -f artifacts):/artifacts \
-w /snek \
$IMAGE \
make DESTDIR=/artifacts PREFIX=/opt/snek SNEK_OTHEROS=1 \
SNEK_RISCV_TEST=1 -j$(nproc) \
black check install install-otheros
- name: 'Upload results'
uses: actions/upload-artifact@v4
with:
name: snek
path: artifacts
snek-1.12/.gitignore 0000664 0000000 0000000 00000000107 15004313365 0014363 0 ustar 00root root 0000000 0000000 TAGS
snek-builtin.h
snek-gram.h
snek.pc
**/*.o
**/*.pyc
**/__pycache__
snek-1.12/.gitmodules 0000664 0000000 0000000 00000000132 15004313365 0014546 0 ustar 00root root 0000000 0000000 [submodule "ubaboot"]
path = ubaboot
url = https://github.com/keith-packard/ubaboot.git
snek-1.12/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006452 15004313365 0015203 0 ustar 00root root 0000000 0000000 # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at conduct@keithp.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
snek-1.12/CONTRIBUTING.md 0000664 0000000 0000000 00000005570 15004313365 0014635 0 ustar 00root root 0000000 0000000 # Contributing to Snek
We welcome contributions of all forms, including patches to code and
documentation, issue reports, or just kind words.
## Getting Current Source Code
Snek sources are maintained in git and hosted in two places.
1. [keithp.com](https://keithp.com/cgit/snek.git/). This is the
'canonical' source location.
2. [github](https://github.com/keith-packard/snek). This should
exactly mirror the code at keithp.com. I've placed it here to
make contributing to Snek easier for people familiar with github.
You can create a local copy of the repository with git clone:
$ git clone git://keithp.com/git/snek.git
or
$ git clone https://github.com/keith-packard/snek.git
## Lola
The only non-standard tool used to build Snek is “lola”, which is a
custom LL parser generator designed to construct compact parse tables
for simple languages, like Snek. That's also available on both
keithp.com and github:
1. [keithp.com](https://keithp.com/git/lola.git/).
2. [github](https://github.com/keith-packard/lola).
Just like Snek, you can get it from either place using:
$ git clone git://keithp.com/git/lola.git
or
$ git clone https://github.com/keith-packard/lola.git
Lola is a Python program; installing it is a simple matter of copying
the script someplace in your path. You can use the Makefile for that
if you like:
$ cd lola
$ make install
The default location is /usr/local/bin
## Building Snek from Source
Snek uses simple Makefiles. Because so much of snek targets embedded
systems, using a more sophisticated system like meson is actually
pretty hard.
$ cd snek
$ make
## Patch Submission
You can submit patches in a couple of ways:
1. Mail to the snek list (see below). This can be tricky as it
requires a friendly email system, and you'll have to subscribe to
the mailing list before it will let you post anything
(sigh). Here's a simple example sending the latest patch in your
local repository to the list:
$ git send-email --to snek@keithp.com HEAD^
2. Generate a pull-request in github.
1. Fork the snek project into your own github account
2. Push patches to that repository
3. While viewing your repository, click on the 'New pull request'
button and follow the instructions there.
## Issue Tracking
We're using the issue tracker on Github for now; if you have issues,
please submit them to the
[Snek Issue Tracker](https://github.com/keith-packard/snek/issues)
## Mailing List
Snek has a mailing list, hosted at keithp.com. You can
[subscribe here](https://keithp.com/mailman/listinfo/snek).
This is a public list, with public archives. Participants are expected
to abide by the Snek Code of Conduct.
## Code of Conduct
Snek uses the
[Contributor Covenant](https://www.contributor-covenant.org/), which
you'll find in the source tree. Please help make Snek a kind and
welcoming environment by following those rules.
snek-1.12/COPYING 0000664 0000000 0000000 00000104513 15004313365 0013434 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
snek-1.12/Dockerfile 0000664 0000000 0000000 00000001616 15004313365 0014373 0 ustar 00root root 0000000 0000000 # snek toolchain
#
# VERSION 0.1
FROM debian:unstable
RUN apt-get update && apt-get install -y \
wget \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN wget -O - https://keithp.com/archive/archive-key | \
apt-key add - && echo 'deb http://keithp.com/archive unstable/' > /etc/apt/sources.list.d/keithp.list
RUN apt-get update && apt-get install -y \
libreadline-dev \
gawk \
lola \
gcc-avr \
avr-libc \
python3-serial \
gcc-arm-none-eabi \
gcc-riscv64-unknown-elf \
qemu-system-riscv32 \
qemu-system-arm \
picolibc-riscv64-unknown-elf \
picolibc-arm-none-eabi \
rsync \
librsvg2-bin \
asciidoctor \
ruby-asciidoctor-pdf \
coderay \
gcc-mingw-w64-i686 \
icoutils \
nsis \
icnsutils \
genisoimage \
python3-pip \
&& python3 -m pip install pynsist \
&& rm -rf /var/lib/apt/lists/*
snek-1.12/Makefile 0000664 0000000 0000000 00000004111 15004313365 0014032 0 ustar 00root root 0000000 0000000 #
# Copyright © 2019 Keith Packard
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
SNEK_NO_BUILD_TARGETS = 1
SNEK_ROOT = .
include snek-install.defs
SNEK_OTHEROS_DIR=$(SNEK_HOSTS)/linux $(SNEK_HOSTS)/windows $(SNEK_HOSTS)/macosx $(SNEK_HOSTS)/zip
SUBDIRS = snekde doc examples
SNEKS = $(SNEK_PORTS)/posix/snek $(FIRMWARE)
all: $(SNEKS)
+for dir in $(SUBDIRS); do (cd $$dir && make PREFIX=$(PREFIX) DESTDIR=$(DESTDIR)) || exit 1; done
$(SNEKS): FORCE
+cd `dirname $@` && make PREFIX=$(PREFIX) DESTDIR=$(DESTDIR)
FORCE:
check: all
+cd test && make $@
black:
+black --check --exclude 'fail-syntax-.*\.py|.*/hosts/.*.py|ubaboot.py' .
black-reformat:
+black --exclude 'fail-syntax-.*\.py|.*/hosts/.*.py|ubaboot.py' .
install: all
+for dir in $(SUBDIRS); do (cd $$dir && make PREFIX=$(PREFIX) DESTDIR=$(DESTDIR) $@) || exit 1; done
+for snek in $(SNEKS); do (cd `dirname $$snek` && make PREFIX=$(PREFIX) DESTDIR=$(DESTDIR) $@) || exit 1; done
upload: otheros
+cd doc && make upload
+for otheros in $(SNEK_OTHEROS_DIR); do (cd "$$otheros" && make upload) || exit 1; done
install-otheros: otheros install
+for otheros in $(SNEK_OTHEROS_DIR); do (cd "$$otheros" && make install-otheros) || exit 1; done
otheros: all
+for otheros in $(SNEK_OTHEROS_DIR); do (cd "$$otheros" && make) || exit 1; done
snek-mu.py:
find . -name '*.builtin' -print0 | xargs -0 python3 ./snek-builtin.py --mu -o $@
docker:
docker build -t phsilva/snek .
clean:
+for dir in $(SUBDIRS); do (cd $$dir && make PREFIX=$(PREFIX) DESTDIR=$(DESTDIR) $@); done
+for snek in $(SNEKS); do (cd `dirname $$snek` && make PREFIX=$(PREFIX) DESTDIR=$(DESTDIR) $@); done
snek-1.12/README.md 0000664 0000000 0000000 00000036732 15004313365 0013667 0 ustar 00root root 0000000 0000000 # Snek — a tiny python-inspired language for embedded computing

Snek is a tiny embeddable language targeting processors with only a
few kB of flash and ram. Think of something that would have been
running BASIC years ago and you'll have the idea. These processors are
too small to run [MicroPython](https://micropython.org/).
## Documentation
* The [Snek Home Page](https://sneklang.org) provides more information
about the language and community.
* [Snek Manual in HTML format](https://sneklang.org/snek.html)
* [Snek Manual in PDF format](https://sneklang.org/snek.pdf)
## Downloads
* Snek is packaged for Debian and is available for the unstable release.
* Packages for Linux, including older versions of Debian, Mac OS X
and Windows are available in the
[Snek Dist directory](http://sneklang.org/dist)
## Supported Hardware
Snek supports analog and digital I/O operations on all of these
boards. Snek also has some support for built-in devices on boards as
described below.
* [Adafruit Crickit](https://www.adafruit.com/product/3093). This is
sold as an expansion board for other Adafruit products, but Snek is
able to run on the local processor. Snek supports the motor
controllers and Neopixel.
* [Arduino Duemilanove](https://www.arduino.cc/en/Main/arduinoBoardDuemilanove).
* [Adafruit Feather M0 Express](https://www.adafruit.com/product/3403).
Snek supports digital and analog input and output with this device.
* [Seeed Grove Beginner Kit for Arduino](https://www.seeedstudio.com/Grove-Beginner-Kit-for-Arduino-p-4549.html).
Snek supports the LED, Buzzer, Light, Sound, OLED Display, Button, Rotary
Potentiometer and 3-axis Accelerometer.
* [Adafruit ItsyBitsy 32u4 - 5V](https://www.adafruit.com/product/3677),
[Adafruit ItsyBitsy 32u4 - 3V](https://www.adafruit.com/product/3675).
* [Adafruit ItsyBitsy M0 Express](https://www.adafruit.com/product/3727)
* [Arduino Mega 2560](https://store.arduino.cc/usa/mega-2560-r3)
* [Adafruit METRO M0 Express](https://www.adafruit.com/product/3505)
* [Arduino Nano 33 IoT](https://store.arduino.cc/usa/nano-33-iot)
* [Crowd Supply 1284 Narrow](https://www.crowdsupply.com/pandauino/narrow)
* [Circuit Playground Express](https://www.adafruit.com/product/3333).
Snek supports the NeoPixels, sound, light sensor and temperature
sensor. It does not support the accelerometer yet.
* [Snekboard](https://www.crowdsupply.com/keith-packard/snekboard).
This board was designed to run Snek and control Lego Power Function motors.
* [Crowd Supply µduino](https://www.crowdsupply.com/uduino/uduino).
This board doesn't have any access to the programming pins, so
you'd need to get Snek pre-programmed before it was split off of
the carrier board.
* [Arduino Uno](https://store.arduino.cc/usa/arduino-uno-rev3). This
is pretty much the same as a Duemilanove board, but with a
different USB to serial converter.
* [Seeeduino XIAO](https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html).
* [LEGO® MINDSTORMS® EV3](https://www.lego.com/en-us/product/lego-mindstorms-ev3-31313).
Snek supports EV3 motors and sensors.
* [Seeed Grove Beginner Kit](https://www.seeedstudio.com/Grove-Beginner-Kit-for-Arduino-p-4549.html).
The port includes drivers for everything except the temperature,
humidity and barometric pressure sensors.
* [Narrow 1284](https://www.crowdsupply.com/pandauino/narrow).
* [Arduino Nano Every](https://store.arduino.cc/usa/nano-every). This
uses flash for storage, and includes most of the math library and
the tone driver.
* [LilyPad Arduino 328](https://www.sparkfun.com/products/13342).
This port leaves out dictionaries and slices so that it has space
for the tone driver.
## To Do list
* Convert parser from LL to SLR. The hope here is to reduce the
amount of parse stack space needed due to the large number of
precedence levels in the language.
## Recent Changes
Here's some places that have seen recent work
* Remove the -big variants. The variants supporting boot loaders now
have sufficient space to support all of the options formerly
reserved for the -big ones.
* Rewrite the ATmel chip support to use __flash attributes. Target
newer GCC version. With these changes, there's lots more space
available on ATmel targets.
* Changed the builtin math, time and random functions to no longer
include the math., time. or random. prefixes. This makes them more
convenient to use. To retain compatibility with Python, you can
use 'from math import *' which Snek will ignore.
* [Mu](https://codewith.mu/) version 1.2.0 has Snek support built in
now. Mu is an IDE designed for new Python users that offers a more
polished alternative to the simple Snek IDE provide with snek.
* Fixed a couple of `input` bugs compared with Python—input
returned None instead of the empty string when nothing was
typed before the return and input printed an arbitrary list of
parameters rather than just the first one. Thanks to Justin Miller
and Mikael Bonnier for reporting these issues.
* Store the most recently printed repl value in `_`. Thanks to Justin
Miller for this suggestion.
* For the Windows native port, add the input module and increase the
heap size to 256kB.
* Update the docs to format correctly with asciidoctor-pdf version 2.3
* [LilyPad Arduino 328](https://www.sparkfun.com/products/13342)
port. This is a round ATmega328p-based board designed for wearable
projects. This board runs at 8MHz, which can't run the serial port
at 115.2kbaud, so it runs at 57.6k instead. Thanks to Douglas
Fraser for this.
* Support multiple baud rates in snekde, auto-detect baud rate when
connecting to non-USB based devices.
* Fix NaN comparisons and make dicts containing NaN keys work.
[Jake Edge's article, “Revisiting NaNs in Python”](https://lwn.net/Articles/869231/)
led to the discovery that Snek had several bugs in NaN
comparisons. Snek now computes the right value for comparisons with
Nan, as well as permitting NaN to be used as a key in dictionaries.
* Support explicit serial synchronization using ENQ/ACK so that
applications sending lots of data do not require OS flow control
support. With many devices connecting via USB/serial adapters that
do not provide any flow control, adding explicit flow control to
the Snek implementation provides a way to make downloading code
reliable for them.
* Fixed incorrect precedence between bitwise and (&) and bitwise xor
(^) operators.
## Build and Run!
If you want to build Snek yourself, you'll need to have the build
tools and other dependencies installed.
### Dependencies
To build Snek you need these dependencies:
* [Lola](https://keithp.com/cgit/lola.git/)
* [gawk](https://www.gnu.org/software/gawk/)
* [gcc-avr](https://ccrma.stanford.edu/~juanig/articles/wiriavrlib/AVR_GCC.html)
* [avr-libc](https://www.nongnu.org/avr-libc/)
* [gcc-arm-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
* [gcc-riscv64-unknown-elf](https://github.com/sifive/freedom-tools/)
* [gcc-arm-linux-gnueabi](https://developer.arm.com/downloads/-/gnu-a)
* [picolibc](https://keithp.com/picolibc/)
* [python3](https://www.python.org/)
* [pyserial](https://github.com/pyserial/)
* [python curses](https://docs.python.org/3/library/curses.html)
* [readline](https://www.gnu.org/software/readline/)
* [asciidoctor](https://asciidoctor.org/)
* [asciidoctor-pdf](https://docs.asciidoctor.org/pdf-converter/latest/)
On Debian unstable, you can get everything from the main archive:
# apt install lola gcc-avr avr-libc python3-serial gawk \
gcc-arm-none-eabi gcc-riscv64-unknown-elf libreadline-dev \
picolibc-arm-none-eabi picolibc-riscv64-unknown-elf \
asciidoctor ruby-asciidoctor-pdf gcc-arm-linux-gnueabi
Debian stable has too old a version of lola, so if you're using that,
you'll need to install lola from the git repository above.
The snek build scripts use the GNU awk implementation, `gawk`,
including a GNU extension, `strtonum`, which is not available in other
awk implementations. It's not critical to compiling the code as it's
only used to print out ROM usage for AVR targets so you can tell how
much space is still available, but if you don't have gawk, you will
get build failures.
### Building and install
Here are some useful options to control the build. Each of these is
run from the top level directory.
$ make
If you just type 'make', the system will build all of the embedded
binaries and a native binary to run locally.
$ make install
'make install' will copy all of the built programs to /usr/local
$ make PREFIX=$HOME/.local
This compiles everything to run from your home directory, instead of
/usr/local.
$ make PREFIX=$HOME/.local install
Make sure you use the same PREFIX value every time you run make so that
the snek install scripts (which get PREFIX embedded in them) that are
installed know where to find the snek binaries for each device.
## Running on Embedded Devices
Snek is designed to run on small embedded devices with 32kB or more of
flash and 2kB or more of RAM. Snek has been ported to a variety of
embedded devices, providing access to pins as GPIOs as well as some
built-in peripherals. Documentation about the supported boards can be
found in the [Snek Manual](https://sneklang.org/snek.html).
## Running on Linux, Mac OS X Windows
Snek is also built to run natively on Linux, Mac OS X and
Windows. When installed, you'll find it available in the regular
system menu.
## The Mu Editor
[mu](https://codewith.mu/) is an IDE especially designed for new
Python developers. It has support for boards running snek upstream,
but no release has been made with that code yet.
## The Snek Development Environment
Snekde is provided on all three platforms; you'll find it in the
system menu on Linux and Windows and down in your personal
Applications directory on Mac OS X.
The snekde window is split into two parts. The upper 2/3 is a text
editor for source code. The bottom 1/3 lets you interact with the
Snek device over the USB port. The very top line lists functions that
you can invoke by pressing the associated function key:
* F1 — Device. Connect to a serial port.
* F2 — Get. Get source code saved to the Snek device eeprom into the editor pane.
* F3 — Put. Put code from the editor pane into the Snek device eeprom.
* F4 — Quit. Exit snekde.
* F5 — Load. Read source code from the file system into the editor pane.
* F6 — Save. Write source code from the editor pane to the file system.
There are a couple more keybindings which you'll want to know:
* Page-up/Page-down — Switch between the editor pane and the interaction pane.
* Ctrl-X/Ctrl-C/Ctrl-V — Usual cut/copy/paste commands.
* Ctrl-C — In the interaction pane, this interrupts any snek program running on the device. Note that
this means you don't get a Copy command in the interaction pane.
* Ctrl-Z — Undo.
Tab auto-indents the current line. Backspace backs up over a tab stop
when appropriate.
## Examples
There are examples provided, some of which work with both Python and
Snek, and some of which show how to use SoC-specific APIs that aren't
available in Python.
## Contributions
I'd love to receive more contributions in the form of patches,
suggestions and bug reports. Please feel free to send mail or use the
github process. I've created a mailing list for collaboration;
you'll need to subscribe to be able to post. Subscribe to the [snek
mailing list here](https://keithp.com/mailman/listinfo/snek)
## Releases
Here are more specific notes about Snek releases.
### Version 1.8
* Add 'str' builtin. Just like Python, the str builtin converts any
value to a string.
* Fix 'chained' comparisons (e.g. a < b < c). These generated
incorrect code that left the stack messed up unless all comparisons
were true.
* Allow 3 * 'a' as well as 'a' * 3. The code for evaluating
expressions only permitted the string to be on the left side.
* Add support in snekde for auto-detecting device baud rate between
57600 and 115200 baud.
* Add port to the ATMega 328 based LilyPad, in both the regular size
as well as the big version which replaces the boot loader to gain
more functionality.
### Version 1.7
* Fix NaN comparisons and make dicts containing NaN keys work.
[Jake Edge's article, “Revisiting NaNs in Python”](https://lwn.net/Articles/869231/)
led to the discovery that Snek had several bugs in NaN
comparisons. Snek now computes the right value for comparisons with
Nan, as well as permitting NaN to be used as a key in dictionaries.
* Add math functions to nano-every port; the ATmega4809 has plenty of
flash space for these.
### Version 1.6
* Support explicit serial synchronization using ENQ/ACK so that
applications sending lots of data do not require OS flow control
support. With many devices connecting via USB/serial adapters that
do not provide any flow control, adding explicit flow control to
the Snek implementation provides a way to make downloading code
reliable for them.
* Fixed incorrect precedence between bitwise and (&) and bitwise xor
(^) operators.
* Lots of improvements to the EV3 port making it more like
other Snek devices.
* [Narrow 1284](https://www.crowdsupply.com/pandauino/narrow) port.
This is a small board with the ATmega1284 SoC which is like the
ATmega328 but with much more Flash and RAM which provides way more
room for Snek to run.
* Seeed Grove Beginner Kit port. This is another ATmega328p based board
but with a range of devices provided in the kit. Snek supports the
LED, Buzzer, Light, Sound, OLED Display, Button, Rotary Potentiometer
and 3-axis Accelerometer.
* Seeeduino XIAO port. This is a SAMD21-based device on a tiny board
with a USB-C connector.
* Arduino Nano Every port. This uses the ATmega4809 which has 6kB of
RAM, providing much more space for Snek programs.
### Version 1.5
* Arduino Uno port. This port, is mostly the same as the Duemilanove
port but includes replacement firmware for the Atmega 16u2 on the Uno
board which acts as the USB interface.
* Handle 'chained' comparison operators (a < b < c) correctly.
* Add sound output support for the Adafruit Circuit Playground
Express board.
* Use Optiboot on the Duemilanove board so that Snek can be replaced
without needing a separate programming device.
### Version 1.4
* LEGO EV3 port.
This port, done by Mikhail Gusarov, includes custom functions for
the motors and sensors.
* HiFive1 Rev B port.
This uses a bunch of code from for all of the core and device support.
* Lots of bugs fixed in string interpolation.
* Lessons using LEGO with Snekboard
There are four lessons that show you how to build a simple robot
with step-by-step construction information, and then explore
programming on a Snekboard.
* Improved time.sleep precision. time.sleep is now accurate to the
resolution of the timer. On a Duemilanove, that's
4µs. time.monotonic still returns a float, so the longer
the board has been running, the lower the precision...
* Support for optiboot in Duemilanove code. Once you've installed
optiboot on your Duemilanove, you can install Snek using that over
the USB port, instead of needing an ISP.
### Version 1.3
* Ports to ESP32 and µduino
* Memory-corruption bug in string interpolation fixed
* Bunch of code refactoring saves some space
* Master now tested after every push on github
snek-1.12/RELEASING.md 0000664 0000000 0000000 00000001724 15004313365 0014234 0 ustar 00root root 0000000 0000000 # Releasing snek
Here are the steps to perform when releasing a new version of snek:
1. Make sure the code builds and runs on all target hardware.
2. Check test suite results:
$ make check
3. Check python code format
$ make black
4. Update Supported Hardware and Recent Changes sections in README.md
5. Update SNEK_VERSION and SNEK_DATE in snek.defs
6. Use the 'build-snek' script to compile for all target
machines. This script uses additional software and hardware to
create bits for machines not directly supported in Debian:
$ ./build-snek otheros
7. Commit version change:
$ git commit -m'Snek version ' main
9. Push tag and branch to repositories
$ git push origin main
$ git push github main
10. Publish release bits
$ ./build-snek upload
11. Send mail to snek mailing list including Recent Changes section
from README.
snek-1.12/ao/ 0000775 0000000 0000000 00000000000 15004313365 0012774 5 ustar 00root root 0000000 0000000 snek-1.12/ao/ao-led.c 0000664 0000000 0000000 00000012763 15004313365 0014312 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2018 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "ao.h"
#ifndef LED_0_INVERT
#define LED_0_INVERT 0
#endif
#ifndef LED_1_INVERT
#define LED_1_INVERT 0
#endif
#ifndef LED_2_INVERT
#define LED_2_INVERT 0
#endif
#ifndef LED_3_INVERT
#define LED_3_INVERT 0
#endif
#ifndef LED_4_INVERT
#define LED_4_INVERT 0
#endif
#ifndef LED_5_INVERT
#define LED_5_INVERT 0
#endif
#ifndef LED_6_INVERT
#define LED_6_INVERT 0
#endif
#ifndef LED_7_INVERT
#define LED_7_INVERT 0
#endif
#ifndef LED_8_INVERT
#define LED_8_INVERT 0
#endif
#ifndef LED_9_INVERT
#define LED_9_INVERT 0
#endif
#ifndef LED_10_INVERT
#define LED_10_INVERT 0
#endif
#ifndef LED_11_INVERT
#define LED_11_INVERT 0
#endif
#ifndef LED_12_INVERT
#define LED_12_INVERT 0
#endif
#ifndef LED_13_INVERT
#define LED_13_INVERT 0
#endif
#ifndef LED_14_INVERT
#define LED_14_INVERT 0
#endif
#ifndef LED_15_INVERT
#define LED_15_INVERT 0
#endif
#ifndef LED_16_INVERT
#define LED_16_INVERT 0
#endif
#ifndef LED_17_INVERT
#define LED_17_INVERT 0
#endif
#ifndef LED_18_INVERT
#define LED_18_INVERT 0
#endif
#ifndef LED_19_INVERT
#define LED_19_INVERT 0
#endif
#ifndef LED_20_INVERT
#define LED_20_INVERT 0
#endif
#ifndef LED_21_INVERT
#define LED_21_INVERT 0
#endif
#ifndef LED_22_INVERT
#define LED_22_INVERT 0
#endif
#ifndef LED_23_INVERT
#define LED_23_INVERT 0
#endif
#ifndef LED_24_INVERT
#define LED_24_INVERT 0
#endif
#ifndef LED_25_INVERT
#define LED_25_INVERT 0
#endif
#ifndef LED_26_INVERT
#define LED_26_INVERT 0
#endif
#ifndef LED_27_INVERT
#define LED_27_INVERT 0
#endif
#ifndef LED_28_INVERT
#define LED_28_INVERT 0
#endif
#ifndef LED_29_INVERT
#define LED_29_INVERT 0
#endif
#ifndef LED_30_INVERT
#define LED_30_INVERT 0
#endif
#ifndef LED_31_INVERT
#define LED_31_INVERT 0
#endif
#ifdef LEDS_AVAILABLE
static const struct {
void *port;
uint8_t pin;
uint8_t invert;
} ao_leds[] = {
#ifdef LED_0_PORT
[0] { LED_0_PORT, LED_0_PIN, LED_0_INVERT },
#endif
#ifdef LED_1_PORT
[1] { LED_1_PORT, LED_1_PIN, LED_1_INVERT },
#endif
#ifdef LED_2_PORT
[2] { LED_2_PORT, LED_2_PIN, LED_2_INVERT },
#endif
#ifdef LED_3_PORT
[3] { LED_3_PORT, LED_3_PIN, LED_3_INVERT },
#endif
#ifdef LED_4_PORT
[4] { LED_4_PORT, LED_4_PIN, LED_4_INVERT },
#endif
#ifdef LED_5_PORT
[5] { LED_5_PORT, LED_5_PIN, LED_5_INVERT },
#endif
#ifdef LED_6_PORT
[6] { LED_6_PORT, LED_6_PIN, LED_6_INVERT },
#endif
#ifdef LED_7_PORT
[7] { LED_7_PORT, LED_7_PIN, LED_7_INVERT },
#endif
#ifdef LED_8_PORT
[8] { LED_8_PORT, LED_8_PIN, LED_8_INVERT },
#endif
#ifdef LED_9_PORT
[9] { LED_9_PORT, LED_9_PIN, LED_9_INVERT },
#endif
#ifdef LED_10_PORT
[10] { LED_10_PORT, LED_10_PIN, LED_10_INVERT },
#endif
#ifdef LED_11_PORT
[11] { LED_11_PORT, LED_11_PIN, LED_11_INVERT },
#endif
#ifdef LED_12_PORT
[12] { LED_12_PORT, LED_12_PIN, LED_12_INVERT },
#endif
#ifdef LED_13_PORT
[13] { LED_13_PORT, LED_13_PIN, LED_13_INVERT },
#endif
#ifdef LED_14_PORT
[14] { LED_14_PORT, LED_14_PIN, LED_14_INVERT },
#endif
#ifdef LED_15_PORT
[15] { LED_15_PORT, LED_15_PIN, LED_15_INVERT },
#endif
#ifdef LED_16_PORT
[16] { LED_16_PORT, LED_16_PIN, LED_16_INVERT },
#endif
#ifdef LED_17_PORT
[17] { LED_17_PORT, LED_17_PIN, LED_17_INVERT },
#endif
#ifdef LED_18_PORT
[18] { LED_18_PORT, LED_18_PIN, LED_18_INVERT },
#endif
#ifdef LED_19_PORT
[19] { LED_19_PORT, LED_19_PIN, LED_19_INVERT },
#endif
#ifdef LED_20_PORT
[20] { LED_20_PORT, LED_20_PIN, LED_20_INVERT },
#endif
#ifdef LED_21_PORT
[21] { LED_21_PORT, LED_21_PIN, LED_21_INVERT },
#endif
#ifdef LED_22_PORT
[22] { LED_22_PORT, LED_22_PIN, LED_22_INVERT },
#endif
#ifdef LED_23_PORT
[23] { LED_23_PORT, LED_23_PIN, LED_23_INVERT },
#endif
#ifdef LED_24_PORT
[24] { LED_24_PORT, LED_24_PIN, LED_24_INVERT },
#endif
#ifdef LED_25_PORT
[25] { LED_25_PORT, LED_25_PIN, LED_25_INVERT },
#endif
#ifdef LED_26_PORT
[26] { LED_26_PORT, LED_26_PIN, LED_26_INVERT },
#endif
#ifdef LED_27_PORT
[27] { LED_27_PORT, LED_27_PIN, LED_27_INVERT },
#endif
#ifdef LED_28_PORT
[28] { LED_28_PORT, LED_28_PIN, LED_28_INVERT },
#endif
#ifdef LED_29_PORT
[29] { LED_29_PORT, LED_29_PIN, LED_29_INVERT },
#endif
#ifdef LED_30_PORT
[30] { LED_30_PORT, LED_30_PIN, LED_30_INVERT },
#endif
#ifdef LED_31_PORT
[31] { LED_31_PORT, LED_31_PIN, LED_31_INVERT },
#endif
};
#define N_LED (sizeof (ao_leds)/sizeof(ao_leds[0]))
void
ao_led_on(AO_LED_TYPE colors)
{
AO_LED_TYPE i;
for (i = 0; i < N_LED; i++)
if (colors & (1 << i))
ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, !ao_leds[i].invert);
}
void
ao_led_off(AO_LED_TYPE colors)
{
AO_LED_TYPE i;
for (i = 0; i < N_LED; i++)
if (colors & (1 << i))
ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ao_leds[i].invert);
}
void
ao_led_init(void)
{
AO_LED_TYPE bit;
for (bit = 0; bit < N_LED; bit++)
ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0);
}
#endif
snek-1.12/ao/ao-led.h 0000664 0000000 0000000 00000011276 15004313365 0014315 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2012 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef _AO_LED_H_
#define _AO_LED_H_
/*
* ao_led.c
*/
#define AO_LED_NONE 0
#ifndef AO_LED_TYPE
#define AO_LED_TYPE uint32_t
#endif
/* Turn on the specified LEDs */
void
ao_led_on(AO_LED_TYPE colors);
/* Turn off the specified LEDs */
void
ao_led_off(AO_LED_TYPE colors);
/* Set all of the LEDs to the specified state */
void
ao_led_set(AO_LED_TYPE colors);
/* Set all LEDs in 'mask' to the specified state */
void
ao_led_set_mask(AO_LED_TYPE colors, AO_LED_TYPE mask);
/* Toggle the specified LEDs */
void
ao_led_toggle(AO_LED_TYPE colors);
/* Turn on the specified LEDs for the indicated interval */
void
ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks);
/* Initialize the LEDs */
void
ao_led_init(void);
#ifdef LED_0_PORT
#define AO_LED_0 (1 << 0)
#else
#define AO_LED_0 0
#endif
#ifdef LED_1_PORT
#define AO_LED_1 (1 << 1)
#else
#define AO_LED_1 0
#endif
#ifdef LED_2_PORT
#define AO_LED_2 (1 << 2)
#else
#define AO_LED_2 0
#endif
#ifdef LED_3_PORT
#define AO_LED_3 (1 << 3)
#else
#define AO_LED_3 0
#endif
#ifdef LED_4_PORT
#define AO_LED_4 (1 << 4)
#else
#define AO_LED_4 0
#endif
#ifdef LED_5_PORT
#define AO_LED_5 (1 << 5)
#else
#define AO_LED_5 0
#endif
#ifdef LED_6_PORT
#define AO_LED_6 (1 << 6)
#else
#define AO_LED_6 0
#endif
#ifdef LED_7_PORT
#define AO_LED_7 (1 << 7)
#else
#define AO_LED_7 0
#endif
#ifdef LED_8_PORT
#define AO_LED_8 (1 << 8)
#else
#define AO_LED_8 0
#endif
#ifdef LED_9_PORT
#define AO_LED_9 (1 << 9)
#else
#define AO_LED_9 0
#endif
#ifdef LED_10_PORT
#define AO_LED_10 (1 << 10)
#else
#define AO_LED_10 0
#endif
#ifdef LED_11_PORT
#define AO_LED_11 (1 << 11)
#else
#define AO_LED_11 0
#endif
#ifdef LED_12_PORT
#define AO_LED_12 (1 << 12)
#else
#define AO_LED_12 0
#endif
#ifdef LED_13_PORT
#define AO_LED_13 (1 << 13)
#else
#define AO_LED_13 0
#endif
#ifdef LED_14_PORT
#define AO_LED_14 (1 << 14)
#else
#define AO_LED_14 0
#endif
#ifdef LED_15_PORT
#define AO_LED_15 (1 << 15)
#else
#define AO_LED_15 0
#endif
#ifdef LED_16_PORT
#define AO_LED_16 (1 << 16)
#else
#define AO_LED_16 0
#endif
#ifdef LED_17_PORT
#define AO_LED_17 (1 << 17)
#else
#define AO_LED_17 0
#endif
#ifdef LED_18_PORT
#define AO_LED_18 (1 << 18)
#else
#define AO_LED_18 0
#endif
#ifdef LED_19_PORT
#define AO_LED_19 (1 << 19)
#else
#define AO_LED_19 0
#endif
#ifdef LED_20_PORT
#define AO_LED_20 (1 << 20)
#else
#define AO_LED_20 0
#endif
#ifdef LED_21_PORT
#define AO_LED_21 (1 << 21)
#else
#define AO_LED_21 0
#endif
#ifdef LED_22_PORT
#define AO_LED_22 (1 << 22)
#else
#define AO_LED_22 0
#endif
#ifdef LED_23_PORT
#define AO_LED_23 (1 << 23)
#else
#define AO_LED_23 0
#endif
#ifdef LED_24_PORT
#define AO_LED_24 (1 << 24)
#else
#define AO_LED_24 0
#endif
#ifdef LED_25_PORT
#define AO_LED_25 (1 << 25)
#else
#define AO_LED_25 0
#endif
#ifdef LED_26_PORT
#define AO_LED_26 (1 << 26)
#else
#define AO_LED_26 0
#endif
#ifdef LED_27_PORT
#define AO_LED_27 (1 << 27)
#else
#define AO_LED_27 0
#endif
#ifdef LED_28_PORT
#define AO_LED_28 (1 << 28)
#else
#define AO_LED_28 0
#endif
#ifdef LED_29_PORT
#define AO_LED_29 (1 << 29)
#else
#define AO_LED_29 0
#endif
#ifdef LED_30_PORT
#define AO_LED_30 (1 << 30)
#else
#define AO_LED_30 0
#endif
#ifdef LED_31_PORT
#define AO_LED_31 (1 << 31)
#else
#define AO_LED_31 0
#endif
#define AO_LEDS_AVAILABLE (AO_LED_0 | \
AO_LED_1 | \
AO_LED_2 | \
AO_LED_3 | \
AO_LED_4 | \
AO_LED_5 | \
AO_LED_6 | \
AO_LED_7 | \
AO_LED_8 | \
AO_LED_9 | \
AO_LED_10 | \
AO_LED_11 | \
AO_LED_12 | \
AO_LED_13 | \
AO_LED_14 | \
AO_LED_15 | \
AO_LED_16 | \
AO_LED_17 | \
AO_LED_18 | \
AO_LED_19 | \
AO_LED_20 | \
AO_LED_21 | \
AO_LED_22 | \
AO_LED_23 | \
AO_LED_24 | \
AO_LED_25 | \
AO_LED_26 | \
AO_LED_27 | \
AO_LED_28 | \
AO_LED_29 | \
AO_LED_30 | \
AO_LED_31)
#ifndef LEDS_AVAILABLE
#define LEDS_AVAILABLE AO_LEDS_AVAILABLE
#endif
#endif /* _AO_LED_H_ */
snek-1.12/ao/ao-notask.c 0000664 0000000 0000000 00000001726 15004313365 0015042 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2012 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include
static volatile void *ao_wchan;
uint8_t
ao_sleep(void *wchan)
{
ao_wchan = wchan;
ao_arch_wait_interrupt();
return 0;
}
void
ao_wakeup(void *wchan)
{
(void) wchan;
ao_wchan = 0;
}
snek-1.12/ao/ao-notask.h 0000664 0000000 0000000 00000001620 15004313365 0015040 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2012 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef _AO_NOTASK_H_
#define _AO_NOTASK_H_
uint8_t
ao_sleep(void *wchan);
void
ao_wakeup(void *wchan);
#endif /* _AO_NOTASK_H_ */
snek-1.12/ao/ao-panic.c 0000664 0000000 0000000 00000003624 15004313365 0014634 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2009 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "ao.h"
#if !HAS_BEEP
#define ao_beep(x)
#endif
#if !LEDS_AVAILABLE
#define ao_led_on(x)
#define ao_led_off(x)
#endif
#ifndef AO_LED_PANIC
#define AO_LED_PANIC AO_LED_RED
#endif
static void
ao_panic_delay(uint8_t n)
{
uint8_t i = 0, j = 0;
while (n--) {
#ifdef AO_PANIC_DELAY_SCALE
uint8_t s = AO_PANIC_DELAY_SCALE;
while (s--)
#endif
while (--j)
while (--i)
ao_arch_nop();
}
}
void
ao_panic(uint8_t reason)
{
uint8_t n;
ao_arch_block_interrupts();
for (;;) {
ao_panic_delay(20);
#if HAS_BEEP
for (n = 0; n < 5; n++) {
ao_beep(AO_BEEP_HIGH_PANIC);
ao_panic_delay(1);
ao_beep(AO_BEEP_LOW_PANIC);
ao_panic_delay(1);
}
ao_beep(AO_BEEP_OFF);
ao_panic_delay(2);
#endif
#ifdef SDCC
#pragma disable_warning 126
#endif
if (reason & 0x40) {
ao_led_on(AO_LED_PANIC);
ao_beep(AO_BEEP_HIGH_PANIC);
ao_panic_delay(40);
ao_led_off(AO_LED_PANIC);
ao_beep(AO_BEEP_OFF);
ao_panic_delay(10);
}
for (n = 0; n < (reason & 0x3f); n++) {
ao_led_on(AO_LED_PANIC);
ao_beep(AO_BEEP_MID_PANIC);
ao_panic_delay(10);
ao_led_off(AO_LED_PANIC);
ao_beep(AO_BEEP_OFF);
ao_panic_delay(10);
}
}
}
snek-1.12/ao/ao-product.c 0000664 0000000 0000000 00000012342 15004313365 0015217 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2009 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "ao.h"
#include "ao-product.h"
/* Defines which mark this particular AltOS product */
#define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
#if HAS_USB
/* Maximum power in mA */
#ifndef AO_USB_MAX_POWER
#define AO_USB_MAX_POWER 100
#endif
#ifndef AO_USB_SELF_POWER
#define AO_USB_SELF_POWER 1
#endif
#define AO_USB_DEVICE_CLASS_COMMUNICATION 0x02
#define AO_USB_INTERFACE_CLASS_CONTROL_CDC 0x02
#define AO_USB_INTERFACE_CLASS_DATA_CDC 0x0A
#ifndef AO_USB_DEVICE_CLASS
#define AO_USB_DEVICE_CLASS AO_USB_DEVICE_CLASS_COMMUNICATION
#endif
#ifndef AO_USB_INTERFACE_CLASS_DATA
#define AO_USB_INTERFACE_CLASS_CONTROL AO_USB_INTERFACE_CLASS_CONTROL_CDC
#define AO_USB_INTERFACE_CLASS_DATA AO_USB_INTERFACE_CLASS_DATA_CDC
#endif
#include "ao-usb.h"
#define HEADER_LEN 9
#define CONTROL_CLASS_LEN 35
#define DATA_LEN (9 + 7 * AO_USB_HAS_OUT + 7 * AO_USB_HAS_IN + 7 * AO_USB_HAS_IN2 + 7 * AO_USB_HAS_IN3)
#define TOTAL_LENGTH (HEADER_LEN + AO_USB_HAS_INT * CONTROL_CLASS_LEN + DATA_LEN)
#define NUM_INTERFACES (AO_USB_HAS_INT + 1)
/* USB descriptors in one giant block of bytes */
CONST uint8_t ao_usb_descriptors [] =
{
/* Device descriptor */
0x12,
AO_USB_DESC_DEVICE,
LE_WORD(0x0110), /* bcdUSB */
AO_USB_DEVICE_CLASS, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
AO_USB_CONTROL_SIZE, /* bMaxPacketSize */
LE_WORD(AO_idVendor_NUMBER), /* idVendor */
LE_WORD(AO_idProduct_NUMBER), /* idProduct */
LE_WORD(0x0100), /* bcdDevice */
0x01, /* iManufacturer */
0x02, /* iProduct */
0x03, /* iSerialNumber */
0x01, /* bNumConfigurations */
/* Configuration descriptor */
0x09,
AO_USB_DESC_CONFIGURATION,
LE_WORD(TOTAL_LENGTH), /* wTotalLength */
NUM_INTERFACES, /* bNumInterfaces */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
0x80 | (AO_USB_SELF_POWER << 6), /* bmAttributes */
AO_USB_MAX_POWER >> 1, /* bMaxPower, 2mA units */
#if AO_USB_HAS_INT
/* Control class interface */
0x09,
AO_USB_DESC_INTERFACE,
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x01, /* bNumEndPoints */
AO_USB_INTERFACE_CLASS_CONTROL, /* bInterfaceClass */
0x02, /* bInterfaceSubClass */
0x01, /* bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */
0x00, /* iInterface */
/* Header functional descriptor */
0x05,
AO_USB_CS_INTERFACE,
0x00, /* bDescriptor SubType Header */
LE_WORD(0x0110), /* CDC version 1.1 */
/* Call management functional descriptor */
0x05,
AO_USB_CS_INTERFACE,
0x01, /* bDescriptor SubType Call Management */
0x01, /* bmCapabilities = device handles call management */
0x01, /* bDataInterface call management interface number */
/* ACM functional descriptor */
0x04,
AO_USB_CS_INTERFACE,
0x02, /* bDescriptor SubType Abstract Control Management */
0x02, /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */
/* Union functional descriptor */
0x05,
AO_USB_CS_INTERFACE,
0x06, /* bDescriptor SubType Union Functional descriptor */
0x00, /* bLeaderInterface */
0x01, /* bFollowerInterface0 */
/* Notification EP */
0x07,
AO_USB_DESC_ENDPOINT,
AO_USB_INT_EP|0x80, /* bEndpointAddress */
0x03, /* bmAttributes = intr */
LE_WORD(8), /* wMaxPacketSize */
0xff, /* bInterval */
#endif
/* Data class interface descriptor */
0x09,
AO_USB_DESC_INTERFACE,
AO_USB_HAS_INT, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
AO_USB_HAS_OUT + AO_USB_HAS_IN + AO_USB_HAS_IN2 + AO_USB_HAS_IN3, /* bNumEndPoints */
AO_USB_INTERFACE_CLASS_DATA, /* bInterfaceClass = data */
0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
#if AO_USB_HAS_OUT
/* Data EP OUT */
0x07,
AO_USB_DESC_ENDPOINT,
AO_USB_OUT_EP, /* bEndpointAddress */
0x02, /* bmAttributes = bulk */
LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */
0x00, /* bInterval */
#endif
#if AO_USB_HAS_IN
/* Data EP in */
0x07,
AO_USB_DESC_ENDPOINT,
AO_USB_IN_EP|0x80, /* bEndpointAddress */
0x02, /* bmAttributes = bulk */
LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
0x00, /* bInterval */
#endif
/* String descriptors */
0x04,
AO_USB_DESC_STRING,
LE_WORD(0x0409),
/* iManufacturer */
AO_iManufacturer_LEN,
AO_USB_DESC_STRING,
AO_iManufacturer_UCS2,
/* iProduct */
AO_iProduct_LEN,
AO_USB_DESC_STRING,
AO_iProduct_UCS2,
/* iSerial */
AO_iSerial_LEN,
AO_USB_DESC_STRING,
AO_iSerial_UCS2,
/* Terminating zero */
0
};
#endif
snek-1.12/ao/ao-usb.h 0000664 0000000 0000000 00000007554 15004313365 0014346 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2012 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef _AO_USB_H_
#define _AO_USB_H_
/*
* ao_usb.c
*/
/* Put one character to the USB output queue */
int
ao_usb_putc(char c, FILE *file);
/* Try to read one char from USB */
int
ao_usb_pollchar(void);
/* Get one character from the USB input queue */
int
ao_usb_getc(void);
/* Flush the USB output queue */
int
ao_usb_flush(FILE *file);
/* Enable the USB controller */
void
ao_usb_enable(void);
/* Disable the USB controller */
void
ao_usb_disable(void);
/* Initialize the USB system */
void
ao_usb_init(void);
extern CONST uint8_t ao_usb_descriptors [];
#define AO_USB_SETUP_DIR_MASK (0x01 << 7)
#define AO_USB_SETUP_TYPE_MASK (0x03 << 5)
#define AO_USB_SETUP_RECIP_MASK (0x1f)
#define AO_USB_DIR_OUT 0
#define AO_USB_DIR_IN (1 << 7)
#define AO_USB_TYPE_STANDARD 0
#define AO_USB_TYPE_CLASS (1 << 5)
#define AO_USB_TYPE_VENDOR (2 << 5)
#define AO_USB_TYPE_RESERVED (3 << 5)
#define AO_USB_RECIP_DEVICE 0
#define AO_USB_RECIP_INTERFACE 1
#define AO_USB_RECIP_ENDPOINT 2
#define AO_USB_RECIP_OTHER 3
/* standard requests */
#define AO_USB_REQ_GET_STATUS 0x00
#define AO_USB_REQ_CLEAR_FEATURE 0x01
#define AO_USB_REQ_SET_FEATURE 0x03
#define AO_USB_REQ_SET_ADDRESS 0x05
#define AO_USB_REQ_GET_DESCRIPTOR 0x06
#define AO_USB_REQ_SET_DESCRIPTOR 0x07
#define AO_USB_REQ_GET_CONFIGURATION 0x08
#define AO_USB_REQ_SET_CONFIGURATION 0x09
#define AO_USB_REQ_GET_INTERFACE 0x0A
#define AO_USB_REQ_SET_INTERFACE 0x0B
#define AO_USB_REQ_SYNCH_FRAME 0x0C
#define AO_USB_DESC_DEVICE 1
#define AO_USB_DESC_CONFIGURATION 2
#define AO_USB_DESC_STRING 3
#define AO_USB_DESC_INTERFACE 4
#define AO_USB_DESC_ENDPOINT 5
#define AO_USB_DESC_DEVICE_QUALIFIER 6
#define AO_USB_DESC_OTHER_SPEED 7
#define AO_USB_DESC_INTERFACE_POWER 8
#define AO_USB_GET_DESC_TYPE(x) (((x)>>8)&0xFF)
#define AO_USB_GET_DESC_INDEX(x) ((x)&0xFF)
#define AO_USB_CONTROL_EP 0
#define AO_USB_CONTROL_SIZE 32
#define AO_USB_INT_EP 1
#define AO_USB_INT_SIZE 8
#ifndef AO_USB_OUT_EP
#define AO_USB_OUT_EP 4
#define AO_USB_IN_EP 5
#define AO_USB_IN2_EP 6
#define AO_USB_IN3_EP 7
#endif
#ifndef AO_USB_HAS_OUT
#define AO_USB_HAS_OUT 1
#endif
#ifndef AO_USB_HAS_IN
#define AO_USB_HAS_IN 1
#endif
#ifndef AO_USB_HAS_INT
#define AO_USB_HAS_INT 1
#endif
#ifndef AO_USB_HAS_IN2
#define AO_USB_HAS_IN2 0
#endif
#ifndef AO_USB_HAS_IN3
#define AO_USB_HAS_IN3 0
#endif
/*
* USB bulk packets can only come in 8, 16, 32 and 64
* byte sizes, so we'll use 64 for everything
*/
#define AO_USB_IN_SIZE 64
#define AO_USB_OUT_SIZE 64
#define AO_USB_EP0_IDLE 0
#define AO_USB_EP0_DATA_IN 1
#define AO_USB_EP0_DATA_OUT 2
#define AO_USB_EP0_STALL 3
#define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
/* CDC definitions */
#define AO_USB_CS_INTERFACE 0x24
#define AO_USB_CS_ENDPOINT 0x25
#define AO_USB_SET_LINE_CODING 0x20
#define AO_USB_GET_LINE_CODING 0x21
#define AO_USB_SET_CONTROL_LINE_STATE 0x22
/* Data structure for GET_LINE_CODING / SET_LINE_CODING class requests */
struct ao_usb_line_coding {
uint32_t rate;
uint8_t char_format;
uint8_t parity;
uint8_t data_bits;
} ;
extern uint8_t ao_usb_running;
#endif /* _AO_USB_H_ */
snek-1.12/ao/ao.h 0000664 0000000 0000000 00000006575 15004313365 0013561 0 ustar 00root root 0000000 0000000 /*
* Copyright © 2009 Keith Packard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef _AO_H_
#define _AO_H_
#include
#include
#include
#include
#include
#include
#include
#include
#define AO_MAX_VERSION 8
/*
* ao_panic.c
*/
#define AO_PANIC_CRASH 1 /* Processor crashed */
#define AO_PANIC_USB 2 /* USB communication error */
/* Stop the operating system, beeping and blinking the reason */
void
ao_panic(uint8_t reason);
/*
* ao_timer.c
*/
#ifndef AO_TICK_TYPE
#define AO_TICK_TYPE uint32_t
#define AO_TICK_SIGNED int32_t
#endif
extern volatile AO_TICK_TYPE ao_tick_count;
/* Our timer runs at 1kHz */
#ifndef AO_HERTZ
#define AO_HERTZ 1000
#endif
#define AO_MS_TO_TICKS(ms) ((ms) / (1000 / AO_HERTZ))
#define AO_SEC_TO_TICKS(s) ((s) * AO_HERTZ)
/* Returns the current time in ticks */
AO_TICK_TYPE
ao_time(void);
/* Returns the current time in ns */
uint64_t
ao_time_ns(void);
/* Suspend the current task until ticks time has passed */
void
ao_delay(uint16_t ticks);
/* Initialize the timer */
void
ao_timer_init(void);
/* Initialize the hardware clock. Must be called first */
void
ao_clock_init(void);
#if AO_POWER_MANAGEMENT
/* Go to low power clock */
void
ao_clock_suspend(void);
/* Restart full-speed clock */
void
ao_clock_resume(void);
#endif
/*
* Various drivers
*/
#if LEDS_AVAILABLE || HAS_LED
#include
#endif
#if HAS_USB
#include
#endif
/*
* ao_stdio.c
*/
#define AO_READ_AGAIN (-1)
extern uint8_t ao_stdin_ready;
/*
* Fifos
*/
#ifndef AO_FIFO_SIZE
#define AO_FIFO_SIZE 256
#endif
#if AO_FIFO_SIZE > 255
typedef uint16_t fifo_t;
#else
typedef uint8_t fifo_t;
#endif
struct ao_fifo {
fifo_t remove;
fifo_t count;
char fifo[AO_FIFO_SIZE];
};
static inline void
ao_fifo_insert(struct ao_fifo *f, char c)
{
fifo_t insert = (f->remove + f->count) & (AO_FIFO_SIZE - 1);
f->fifo[insert] = c;
f->count++;
}
static inline char
ao_fifo_remove(struct ao_fifo *f)
{
char c = f->fifo[f->remove];
f->remove = (f->remove + 1) & (AO_FIFO_SIZE - 1);
f->count--;
return c;
}
static inline bool
ao_fifo_full(struct ao_fifo *f)
{
return f->count == AO_FIFO_SIZE;
}
static inline bool
ao_fifo_empty(struct ao_fifo *f)
{
return f->count == 0;
}
static inline fifo_t
ao_fifo_space(struct ao_fifo *f)
{
return f->count;
}
static inline bool
ao_fifo_has_space(struct ao_fifo *f, fifo_t amount)
{
return amount <= AO_FIFO_SIZE - f->count;
}
static inline bool
ao_fifo_mostly(struct ao_fifo *f)
{
return f->count >= AO_FIFO_SIZE * 3 / 4;
}
static inline bool
ao_fifo_barely(struct ao_fifo *f)
{
return f->count <= AO_FIFO_SIZE * 1 / 4;
}
#include
#endif /* _AO_H_ */
snek-1.12/ao/make-product.py 0000775 0000000 0000000 00000004742 15004313365 0015753 0 ustar 00root root 0000000 0000000 #!/usr/bin/python3
import argparse
def write_ucs2(a, description):
l = len(a)
print("/* %s */" % description)
print("#define AO_%s_LEN 0x%02x" % (description, l * 2 + 2))
print('#define AO_%s_STRING "%s"' % (description, a))
print("#define AO_%s_UCS2" % description, end="")
for i in range(l):
c = a[i]
if i > 0:
print(",", end="")
if 0x20 <= ord(c) and ord(c) < 128:
print(" '%c', 0" % c, end="")
else:
print(" LE_WORD(0x%04x)" % ord(c), end="")
print("\n")
def write_string(a, description):
print("/* %s */" % description)
print('#define AO_%s_STRING "%s"' % (description, a))
def write_int(a, description):
print("/* %s */" % description)
print("#define AO_%s_NUMBER %d\n" % (description, a))
def write_hex(a, description):
print("/* %s */" % description)
print("#define AO_%s_NUMBER 0x%04x\n" % (description, a))
def auto_int(x):
return int(x, 0)
def make_product():
manufacturer = "keithp.com"
product = "MetroSnek"
version = "0.0"
output = ""
serial = 1
user_argind = 0
id_vendor = 0xFFFE
id_product = 0x000A
parse = argparse.ArgumentParser()
parse.add_argument(
"-m", "--manufacturer", help="manufacturer name", default=manufacturer
)
parse.add_argument("-p", "--product", help="product name", default=product)
parse.add_argument(
"-V", "--id_vendor", type=auto_int, help="vendor id number", default=id_vendor
)
parse.add_argument(
"-i",
"--id_product",
type=auto_int,
help="product id number",
default=id_product,
)
parse.add_argument("-v", "--version", help="version string", default=version)
parse.add_argument(
"-s", "--serial", type=auto_int, help="serial number", default=serial
)
args = parse.parse_args()
if args.manufacturer:
manufacturer = args.manufacturer
if args.product:
product = args.product
if args.id_vendor:
id_vendor = args.id_vendor
if args.id_product:
id_product = args.id_product
if args.version:
version = args.version
if args.serial:
serial = args.serial
write_ucs2(manufacturer, "iManufacturer")
write_ucs2(product, "iProduct")
write_ucs2("%06d" % serial, "iSerial")
write_int(serial, "iSerial")
write_hex(id_product, "idProduct")
write_hex(id_vendor, "idVendor")
write_string(version, "iVersion")
make_product()
snek-1.12/build-snek 0000775 0000000 0000000 00000000372 15004313365 0014362 0 ustar 00root root 0000000 0000000 #!/bin/sh
export SNEKMAC=imac.keithp.com:build/snek
export SNEK_RISCV_TEST=1
export SNEK_ESP32=1
export SNEK_NANO_EVERY=1
export SNEK_OTHEROS=1
export AVR_LIBC=/opt/avr-libc
export ESP_IDF=$HOME/src/esp/esp-idf
wakeonlan 58:40:4e:ee:39:1a
make "$@"
snek-1.12/chips/ 0000775 0000000 0000000 00000000000 15004313365 0013503 5 ustar 00root root 0000000 0000000 snek-1.12/chips/atmega/ 0000775 0000000 0000000 00000000000 15004313365 0014741 5 ustar 00root root 0000000 0000000 snek-1.12/chips/atmega/ef_acosh.c 0000664 0000000 0000000 00000002677 15004313365 0016670 0 ustar 00root root 0000000 0000000 /* ef_acosh.c -- float version of e_acosh.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
#include "fdlibm.h"
#ifdef __STDC__
static const float
#else
static float
#endif
one = 1.0,
ln2 = 6.9314718246e-01; /* 0x3f317218 */
#if defined(_IEEE_LIBM) && defined(HAVE_ALIAS_ATTRIBUTE)
__strong_reference(__ieee754_acoshf, acoshf);
#endif
#ifdef __STDC__
float __ieee754_acoshf(float x)
#else
float __ieee754_acoshf(x)
float x;
#endif
{
float t;
__int32_t hx;
GET_FLOAT_WORD(hx,x);
if(hx<0x3f800000) { /* x < 1 */
return (x-x)/(x-x);
} else if(hx >=0x4d800000) { /* x > 2**28 */
if(!FLT_UWORD_IS_FINITE(hx)) { /* x is inf of NaN */
return x+x;
} else
return __ieee754_logf(x)+ln2; /* acosh(huge)=log(2x) */
} else if (hx==0x3f800000) {
return 0.0; /* acosh(1) = 0 */
} else if (hx > 0x40000000) { /* 2**28 > x > 2 */
t=x*x;
return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one)));
} else { /* 1