Repository navigation
Cob v0.0.7
Cob Language v0.0.7
Overview
The headline feature is conditionals. Cob now has if, elif and
else:
set score = 85
if score >= 90:
pop("grade: A")
elif score >= 80:
pop("grade: B")
else:
pop("keep practicing")
Both tools support it, and they print identical output for the same
program:
cob_interpparses, caches and runs it.popcorn_compcompiles it to a plain Cif (...) { ... } else { ... }.
Added
-
if <condition>:runs its indented block when the condition is
true. The condition grammar is exactlywhile's:==,!=,<,
>,<=,>=on two numbers or two strings, or a bare expression
as a truthiness test (non-zero for a number, non-empty for a string).
Comparing a string to a number still warns and evaluates to false. -
elif <condition>:andelse:may follow anifat the
SAME indentation. Any number ofelifs, at most oneelse. -
Blocks nest freely:
ifinsideif, insidewhile, andwhile
insideif. -
if,elifandelseare now reserved words, so anexterncan no
longer be declared with one of those names (same rule aswhile,
set,pop, ...). -
Clear syntax errors, each with a line number:
'else' without a matching 'if' at the same indentation'elif' without a matching 'if' at the same indentationmalformed condition in if statement(orelif)expected ':' to open if block(orelif)
-
A signed Debian package and apt repository. One package,
csf-cob(apt package names must be lowercase, soapt install CSF-COBcannot work; it iscsf-cob), carries all four Linux builds
(amd64, i386, arm64, armhf). On install, the post-install script keeps
the one that matches the machine (dpkg --print-architecture) and
deletes the other three;/usr/bin/cob,farmerandpopcorn_comp
run that build, andpopcorn_compstill finds its bundled Zig. It
replaces the oldcobpackage name. To install and keep it updated:sudo mkdir -p /etc/apt/keyrings curl -fsSL https://github.com/Cob-Software-Foundation/Cob/releases/download/apt-repo/cob-gpg-public-key.asc | sudo tee /etc/apt/keyrings/csf-cob.asc > /dev/null echo "deb [signed-by=/etc/apt/keyrings/csf-cob.asc] https://github.com/Cob-Software-Foundation/Cob/releases/download/apt-repo ./" | sudo tee /etc/apt/sources.list.d/csf-cob.list sudo apt update && sudo apt install csf-cobThe repository index (
InRelease,Release.gpg) is signed with the
project's GPG key, and the.debitself also has a detached signature
(csf-cob_<version>_all.deb.asc) plus a SHA-256 file, so it can be
checked by hand withgpg --verify. The repository lives on a
release namedapt-repoand keeps the newest three versions.
The workflow refuses to publish if the signing key is not configured. -
An "if / else" example on the in-browser playground, and
ifon the
website's release notes and download page.
Changed
.strawberrycache format bumped fromCOBSTRW7toCOBSTRW8.
A new statement kind (STMT_IF) was appended, with the condition
followed by the then-block and the else-block. Existing caches are
detected as stale and rebuilt automatically the next time a script
runs (you will see onecache ... unreadable, reparsing sourcenote
per script). Nothing needs to be deleted by hand.elifis not a separate kind in the cache or the compiler: the
parser turns it into anifnested inside the previouselse, so
the cache reader/writer and the code generator only ever deal with
if/else.
Verified this session
- A test script (
tools/tests/if_statements.cob, with its expected
output intools/tests/if_statements.expected) covering if, if/else,
an if/elif/elif/else chain, anifnested inside anelifbranch
inside awhileloop, string equality and inequality, and the
truthiness of0and"", produces byte-identical output cold,
against its own.strawberrycache, and as a native binary built by
popcorn_comp. cob_interpcompiles clean under-Wall -Wextra -Wpedanticand runs
clean under AddressSanitizer + UndefinedBehaviorSanitizer +
LeakSanitizer on the valid program (cold and cached) and on seven
malformed programs, including errors in the middle of an
if/elif/elsechain (a badelifcondition, a bad statement
inside anelsebody, a secondelse, a missing colon, anelse
with noif), which free a half-built chain.- The package and the signed apt repository were exercised with the
workflow's own scripts, serving the repository over HTTP to real apt
with throwaway keys:apt updateaccepts the signature,apt install csf-cobresolves its dependencies and installs,cobruns an
if/elsescript, an upgrade from one version to the next works and
leaves only the matching build, a package list changed after signing
is refused, an index signed by a different key is refused, and the
oldest of four published versions is pruned.apt install CSF-COB
fails withUnable to locate package, as expected. - The
.debpackaging steps frombuild.ymlwere run end to end on an
amd64 machine against a package tree laid out like the real Linux
build artifacts. The package installed, kept only theamd64build,
linkedcurrentto it, ran anif/elif/elsescript withcob,
compiled and ran it withpopcorn_compthrough the launcher (which
found the Zig next to the real binary, not next to/usr/bin), and
then removed cleanly. - Signing was exercised with throwaway keys, both unprotected and
passphrase-protected: the signature verifies from an empty keyring
holding only the published public key, a one-byte change to the
.debmakes verification fail, no private key material appears in
any published file, and the key and passphrase file are removed from
the runner afterwards. A push with no key fails the job, a fork pull
request builds unsigned and skips signing, and a protected key with no
passphrase fails without producing a signature. - A
COBSTRW7cache and a truncatedCOBSTRW8cache are both ignored
with a note and the script is re-parsed correctly, rather than
misread. - The existing arithmetic stress script still runs, and the widget
smoke script still runs in a plainmake cob_interpbuild. - The
-DCOB_WASMconfiguration (the same definesmake wasmuses)
compiles natively and gives the same output on the test script.
Not verified
make wasmhas not been run here: Emscripten is not installed in
this environment. The code is plain C99 with no new dependencies and
the-DCOB_WASMflavor was compiled natively as described above, but
the first realemccbuild will be whatever CI run triggers it.
Pounce (the block-coding front end) builds from this source, so it
inherits that gap.- The
debandapt-repojobs have not run on GitHub Actions, signing
has not been run with the realGPG_PRIVATE_KEY, and the repository has
not yet been fetched through GitHub's release-asset URLs (which redirect
to a CDN; apt follows redirects, but this was not tried against GitHub
itself). In the local run the amd64 build
was real but the Zig was a stand-in that forwards to gcc, and the
i386, arm64 and armhf builds were placeholders, so those three were
packaged but never installed or run on matching hardware. - The
.debis oneArchitecture: allpackage holding binaries for
several architectures, which is not how Debian packaging is normally
done and whichlintianwill complain about.dpkg --verifyreports
the deleted other-architecture files as missing, by design.apt
does not check detached.ascsignatures on a loose.deb; the
signature is for manual verification, not for anaptrepository. popcorn_comp's-Wpedanticbuild still emits one warning about an
over-long string literal in the C runtime preamble. It was already
there before this release and this release did not touch it.- Everything Windows/macOS/cross-compile-related that previous
releases flagged as not verified on real hardware remains not
verified; this release touched none of that code. - The website changes (
docs/index.html,docs/download.html,
docs/play/index.html) were edited but not opened in a browser, and
the new playground example has not been run in the WebAssembly
playground. - The full CI suite (
ci.yml,build.yml, the Docker stress image)
has not been run on this change.