Yet Another Language Experimental Compiler — a small frontend that parses .yl sources, lowers them to C, and drives TinyCC as the backend for transpile, in-process JIT, and executable builds.
Author: Philipp Andrew Roa Redondo.
- Original compiler sources (
main/,main.c,Makefile,build.bat,tests/*.yl, docs): MIT License — seeLICENSE. - TinyCC (
thirdparty/tinycc/): LGPL-2.1 — full textthirdparty/tinycc/COPYING. - libunicode / cutils (
thirdparty/libunicode/): MIT — see copyright notices in each file.
Because yellec may statically link libtcc.c, redistributing binaries triggers LGPL 2.1 obligations for the TinyCC-linked portions (shared-library linking vs. relinking rules). Read LGPL_COMPLIANCE.md and NOTICE.
| Area | Role |
|---|---|
main.c |
CLI, orchestration, TinyCC wiring (dump / run / compile / produce), diagnostics |
main/ |
Lexer (tokenizer), parser, AST (ast), type tags (typetag), codegen (compiler), shared definitions (global), runtime state (state, context) |
tests/ |
Example .yl programs (strings, lists, arrays, inline C, probes) — run manually with yellec |
thirdparty/tinycc |
TinyCC submodule (headers, libtcc, Win32 runtime) |
thirdparty/libunicode |
Unicode helpers used by the tokenizer (expects QuickJS cutils.c / cutils.h alongside, per build.bat) |
build/ |
Build output directory when using build.bat (yellec.exe, synced TinyCC win32 tree) |
The language surface is still evolving; main/keyword.h lists reserved words (mod, fn, var, let, control flow, numeric types, string, etc.). What is fully wired end-to-end depends on the current parser and compiler passes — use tests/ as living examples.
Prerequisites:
- GCC on
PATH(gcc) - TinyCC sources under
thirdparty\tinycc(submodule) thirdparty\libunicodewithlibunicode.cand bundledcutils.c/cutils.h(the batch file checks for these)
From the repo root:
build.batThis script:
- Verifies dependencies and generates
thirdparty\tinycc\config.hif missing - Copies the TinyCC Win32 runtime into
build\win32and runs TinyCC’sbuild-tcc.batto populate runtime pieces - Compiles
main.c,main\*.c, libunicode, andlibtcc.cintobuild\yellec.exe
From the repo root (requires gcc, populated thirdparty/tinycc, and thirdparty/libunicode with cutils.c / cutils.h):
make debug # default; AddressSanitizer on non-Windows
make releaseOn non-Windows, --run uses libtcc in-memory JIT and adds common system include/library paths in main.c. You can also mirror the gcc line from build.bat if you prefer not to use Make.
All modes require -f / --file pointing at a .yl source unless you only dump C (you can combine dump with run).
| Option | Meaning |
|---|---|
-f, --file <path> |
Input .yl file |
-d, --dump <out.c> |
Write generated C to disk |
-r, --run |
Execute generated code (Win32: spawns build\win32\tcc.exe; else: libtcc JIT) |
-c, --compile <exe> |
Emit an executable |
-p, --produce <exe> |
Emit an executable with TinyCC options -O2 -DNDEBUG |
Examples:
build\yellec.exe -f tests\test.yl -d out.c
build\yellec.exe -f tests\mini_test.yl -r
build\yellec.exe -f tests\string_concat.yl -c build\app.exe
build\yellec.exe -f tests\test.yl -p build\app-fast.exeDump-only (no run/compile): -f file.yl -d out.c satisfies the CLI without -r/-c/-p.
- Tokenizer (
main/tokenizer.c) produces tokens from UTF-8 source. - Parser (
main/parser.c) builds an AST (main/ast.c,main/global.h). - Compiler (
main/compiler.c) walks the AST and emits C into per-context buffers, thenfile_linker(main/global.h) concatenates module/function chunks for TinyCC. - TinyCC compiles that C either to memory (JIT), or to an
.exe/ELF-style executable depending on platform and flags.
Embedded C snippets use the /***BEGIN … END***/ regions (see tests/test.yl, tests/string_concat.yl).
There is no root-level automated test runner; scripts under tests/ are sample programs to exercise the toolchain:
mini_test.yl— minimalmod+main+println-style usagestring_concat.yl— string literals and+concatenation (runtime helpers emitYL_stringglue in generated C)list_test.yl,list_min*.yl,expr_*,list_probe_*— list-oriented samples (push,peek, indexing, etc., as supported by the compiler)lit_array_inline.yl— fixed-size array literal style{i32,n}{…}lit_list_inline.yl,expr_inline_list_*— inline list forms
Use -r or -c/-p on individual files to validate behavior as the language grows.
main/global.h— central enums (AstType,TokenType),Astlayout,State/Context, error reporting helpersmain/typetag.c— maps semantic types to C spellings and default values- After changing AST shapes or codegen, update
main/compiler.cand add or adjust a sample undertests/
See NOTICE. TinyCC is LGPL-2.1; binary redistribution with static libtcc is covered in LGPL_COMPLIANCE.md.