caelix-lang 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- caelix_lang-2.1.0/CHANGELOG.md +68 -0
- caelix_lang-2.1.0/LICENSE +21 -0
- caelix_lang-2.1.0/MANIFEST.in +12 -0
- caelix_lang-2.1.0/Makefile +60 -0
- caelix_lang-2.1.0/PKG-INFO +318 -0
- caelix_lang-2.1.0/README.md +295 -0
- caelix_lang-2.1.0/clxpm +195 -0
- caelix_lang-2.1.0/docs/LANGUAGE.md +126 -0
- caelix_lang-2.1.0/editor/README.md +20 -0
- caelix_lang-2.1.0/editor/nano/caelix.nanorc +28 -0
- caelix_lang-2.1.0/editor/vim/ftdetect/caelix.vim +1 -0
- caelix_lang-2.1.0/editor/vim/syntax/caelix.vim +39 -0
- caelix_lang-2.1.0/editor/vscode-caelix/language-configuration.json +12 -0
- caelix_lang-2.1.0/editor/vscode-caelix/package.json +21 -0
- caelix_lang-2.1.0/editor/vscode-caelix/syntaxes/caelix.tmLanguage.json +48 -0
- caelix_lang-2.1.0/examples/fizzbuzz.clx +11 -0
- caelix_lang-2.1.0/examples/game.clx +12 -0
- caelix_lang-2.1.0/examples/hello.clx +3 -0
- caelix_lang-2.1.0/examples/showcase.clx +303 -0
- caelix_lang-2.1.0/examples/todo.clx +34 -0
- caelix_lang-2.1.0/include/caelix.h +236 -0
- caelix_lang-2.1.0/pyproject.toml +3 -0
- caelix_lang-2.1.0/python/caelix_lang/__init__.py +24 -0
- caelix_lang-2.1.0/python/caelix_lang/__main__.py +17 -0
- caelix_lang-2.1.0/python/caelix_lang.egg-info/PKG-INFO +318 -0
- caelix_lang-2.1.0/python/caelix_lang.egg-info/SOURCES.txt +133 -0
- caelix_lang-2.1.0/python/caelix_lang.egg-info/dependency_links.txt +1 -0
- caelix_lang-2.1.0/python/caelix_lang.egg-info/not-zip-safe +1 -0
- caelix_lang-2.1.0/python/caelix_lang.egg-info/top_level.txt +1 -0
- caelix_lang-2.1.0/setup.cfg +4 -0
- caelix_lang-2.1.0/setup.py +156 -0
- caelix_lang-2.1.0/src/ast.c +25 -0
- caelix_lang-2.1.0/src/core.c +352 -0
- caelix_lang-2.1.0/src/database.c +309 -0
- caelix_lang-2.1.0/src/date.c +234 -0
- caelix_lang-2.1.0/src/edit.c +254 -0
- caelix_lang-2.1.0/src/error.c +102 -0
- caelix_lang-2.1.0/src/gc.c +204 -0
- caelix_lang-2.1.0/src/highlight.c +189 -0
- caelix_lang-2.1.0/src/http.c +368 -0
- caelix_lang-2.1.0/src/interpreter.c +734 -0
- caelix_lang-2.1.0/src/lexer.c +170 -0
- caelix_lang-2.1.0/src/main.c +91 -0
- caelix_lang-2.1.0/src/memory.c +32 -0
- caelix_lang-2.1.0/src/network.c +258 -0
- caelix_lang-2.1.0/src/parser.c +756 -0
- caelix_lang-2.1.0/src/runtime.c +1080 -0
- caelix_lang-2.1.0/stdlib/util.clx +10 -0
- caelix_lang-2.1.0/tests/cases/01_output.clx +14 -0
- caelix_lang-2.1.0/tests/cases/01_output.out +10 -0
- caelix_lang-2.1.0/tests/cases/02_conditions.clx +21 -0
- caelix_lang-2.1.0/tests/cases/02_conditions.out +5 -0
- caelix_lang-2.1.0/tests/cases/03_loops.clx +55 -0
- caelix_lang-2.1.0/tests/cases/03_loops.out +27 -0
- caelix_lang-2.1.0/tests/cases/04_functions.clx +36 -0
- caelix_lang-2.1.0/tests/cases/04_functions.out +5 -0
- caelix_lang-2.1.0/tests/cases/05_collections.clx +23 -0
- caelix_lang-2.1.0/tests/cases/05_collections.out +11 -0
- caelix_lang-2.1.0/tests/cases/06_strings.clx +16 -0
- caelix_lang-2.1.0/tests/cases/06_strings.out +13 -0
- caelix_lang-2.1.0/tests/cases/07_classes.clx +29 -0
- caelix_lang-2.1.0/tests/cases/07_classes.out +7 -0
- caelix_lang-2.1.0/tests/cases/08_errors.clx +37 -0
- caelix_lang-2.1.0/tests/cases/08_errors.out +8 -0
- caelix_lang-2.1.0/tests/cases/09_modules.clx +13 -0
- caelix_lang-2.1.0/tests/cases/09_modules.out +5 -0
- caelix_lang-2.1.0/tests/cases/10_ask.clx +4 -0
- caelix_lang-2.1.0/tests/cases/10_ask.in +2 -0
- caelix_lang-2.1.0/tests/cases/10_ask.out +2 -0
- caelix_lang-2.1.0/tests/cases/11_syntax_else_if.clx +22 -0
- caelix_lang-2.1.0/tests/cases/11_syntax_else_if.out +3 -0
- caelix_lang-2.1.0/tests/cases/12_stop_outside.clx +2 -0
- caelix_lang-2.1.0/tests/cases/12_stop_outside.out +3 -0
- caelix_lang-2.1.0/tests/cases/13_runtime_uncaught.clx +2 -0
- caelix_lang-2.1.0/tests/cases/13_runtime_uncaught.out +3 -0
- caelix_lang-2.1.0/tests/cases/14_missing_end.clx +2 -0
- caelix_lang-2.1.0/tests/cases/14_missing_end.out +3 -0
- caelix_lang-2.1.0/tests/cases/15_recursion_limit.clx +8 -0
- caelix_lang-2.1.0/tests/cases/15_recursion_limit.out +1 -0
- caelix_lang-2.1.0/tests/cases/16_json.clx +22 -0
- caelix_lang-2.1.0/tests/cases/16_json.out +13 -0
- caelix_lang-2.1.0/tests/cases/17_gc.clx +69 -0
- caelix_lang-2.1.0/tests/cases/17_gc.out +7 -0
- caelix_lang-2.1.0/tests/cases/18_showcase.clx +303 -0
- caelix_lang-2.1.0/tests/cases/18_showcase.out +56 -0
- caelix_lang-2.1.0/tests/cases/19_core.clx +52 -0
- caelix_lang-2.1.0/tests/cases/19_core.out +29 -0
- caelix_lang-2.1.0/tests/cases/20_database.clx +62 -0
- caelix_lang-2.1.0/tests/cases/20_database.out +22 -0
- caelix_lang-2.1.0/tests/cases/21_system_args.clx +2 -0
- caelix_lang-2.1.0/tests/cases/21_system_args.out +1 -0
- caelix_lang-2.1.0/tests/cases/22_in_inc_inherit.clx +46 -0
- caelix_lang-2.1.0/tests/cases/22_in_inc_inherit.out +8 -0
- caelix_lang-2.1.0/tests/cases/23_date.clx +37 -0
- caelix_lang-2.1.0/tests/cases/23_date.out +20 -0
- caelix_lang-2.1.0/tests/cases/24_hint_display_comma.clx +2 -0
- caelix_lang-2.1.0/tests/cases/24_hint_display_comma.out +3 -0
- caelix_lang-2.1.0/tests/cases/25_hint_print.clx +1 -0
- caelix_lang-2.1.0/tests/cases/25_hint_print.out +3 -0
- caelix_lang-2.1.0/tests/cases/26_hint_variable.clx +2 -0
- caelix_lang-2.1.0/tests/cases/26_hint_variable.out +2 -0
- caelix_lang-2.1.0/tests/cases/27_hint_mapkey.clx +2 -0
- caelix_lang-2.1.0/tests/cases/27_hint_mapkey.out +2 -0
- caelix_lang-2.1.0/tests/cases/28_hint_list_comma.clx +1 -0
- caelix_lang-2.1.0/tests/cases/28_hint_list_comma.out +3 -0
- caelix_lang-2.1.0/tests/cases/29_super_no_parent.clx +6 -0
- caelix_lang-2.1.0/tests/cases/29_super_no_parent.out +2 -0
- caelix_lang-2.1.0/tests/cases/30_display_strings.clx +60 -0
- caelix_lang-2.1.0/tests/cases/30_display_strings.out +37 -0
- caelix_lang-2.1.0/tests/cases/31_say_renamed.clx +1 -0
- caelix_lang-2.1.0/tests/cases/31_say_renamed.out +3 -0
- caelix_lang-2.1.0/tests/cases/32_say_call_renamed.clx +1 -0
- caelix_lang-2.1.0/tests/cases/32_say_call_renamed.out +2 -0
- caelix_lang-2.1.0/tests/cases/33_ask_types.clx +57 -0
- caelix_lang-2.1.0/tests/cases/33_ask_types.in +28 -0
- caelix_lang-2.1.0/tests/cases/33_ask_types.out +26 -0
- caelix_lang-2.1.0/tests/cases/34_ask_int_error.clx +2 -0
- caelix_lang-2.1.0/tests/cases/34_ask_int_error.in +1 -0
- caelix_lang-2.1.0/tests/cases/34_ask_int_error.out +2 -0
- caelix_lang-2.1.0/tests/cases/35_ask_unknown_type.clx +1 -0
- caelix_lang-2.1.0/tests/cases/35_ask_unknown_type.out +3 -0
- caelix_lang-2.1.0/tests/clxpm_test.sh +60 -0
- caelix_lang-2.1.0/tests/date_tz_test.sh +27 -0
- caelix_lang-2.1.0/tests/highlight_test.sh +35 -0
- caelix_lang-2.1.0/tests/http_server.py +31 -0
- caelix_lang-2.1.0/tests/http_test.sh +40 -0
- caelix_lang-2.1.0/tests/https_server.py +25 -0
- caelix_lang-2.1.0/tests/https_test.sh +83 -0
- caelix_lang-2.1.0/tests/network_test.sh +64 -0
- caelix_lang-2.1.0/tests/pip_test.sh +40 -0
- caelix_lang-2.1.0/tests/pty_driver.py +89 -0
- caelix_lang-2.1.0/tests/pty_test.sh +6 -0
- caelix_lang-2.1.0/tests/repl_test.sh +26 -0
- caelix_lang-2.1.0/tests/run_tests.sh +26 -0
- caelix_lang-2.1.0/tools/tls_probe.c +4 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.1.0
|
|
4
|
+
- Installable with pip: `pip install caelix-lang` builds the C interpreter and installs `caelix` and `clxpm`
|
|
5
|
+
(`setup.py`, `pyproject.toml`, `MANIFEST.in`, helper module `caelix_lang`). Works from a source package or a wheel.
|
|
6
|
+
- The binary now finds its standard library at `<its folder>/../share/caelix/stdlib`, so installs work from any
|
|
7
|
+
prefix or virtual environment without environment variables.
|
|
8
|
+
- Added an MIT `LICENSE` (copyright holder is a placeholder: "The Caelix authors"; edit it to your name).
|
|
9
|
+
- New test `tests/pip_test.sh`.
|
|
10
|
+
|
|
11
|
+
## 2.0.0
|
|
12
|
+
- Renamed from Veyra to Caelix: command `caelix`, package manager `clxpm`, file extension `.clx`, and all related
|
|
13
|
+
folder, file and environment-variable names (table in the README). No language changes; version 2.0.0 marks the
|
|
14
|
+
breaking rename. Entries below describe the same project under its earlier name, Veyra.
|
|
15
|
+
|
|
16
|
+
## 1.4.0
|
|
17
|
+
- `ask (int|float|bool|str) "prompt"`: optional type cast with clear, catchable conversion errors. Plain `ask` unchanged.
|
|
18
|
+
- Highlighting for the type word in the REPL, `--highlight`, nano, vim and VS Code.
|
|
19
|
+
|
|
20
|
+
## 1.3.1
|
|
21
|
+
- `say` renamed to `display` (same behavior; `say` now gives a "renamed" hint). All tests, examples, docs and editor files updated.
|
|
22
|
+
- String operations: `uppercase.{x}`, `lowercase."X"`, `capitalize`, `shred`, `reverse`, `length`, `ridiculous`.
|
|
23
|
+
- `display a, b sep = "-"` custom separator.
|
|
24
|
+
- `/n/` newline escape inside strings (`\/n/` for the literal text); `\n` still works.
|
|
25
|
+
|
|
26
|
+
## 1.3.0
|
|
27
|
+
- HTTPS in the `http` module (OpenSSL, optional at build time; certificate and host-name verification; `http.tls`).
|
|
28
|
+
- `date` module: parts, make, format, parse, add, diff (local and `_utc` variants), calendar-aware.
|
|
29
|
+
- Inheritance: `class D extends C`, `super.method()`, `is_a(obj, Class)`.
|
|
30
|
+
- `in` / `not in` operators and `x++` / `x--` statements.
|
|
31
|
+
- Error hints: missing commas, words from other languages, keyword typos, "did you mean" for names, keys, fields.
|
|
32
|
+
- Fixed: `make test` now actually runs the highlight, pty and time-zone tests.
|
|
33
|
+
|
|
34
|
+
## 1.2.0
|
|
35
|
+
- REPL line editor with live syntax highlighting, history (`~/.caelix_history`), cursor editing and colored results.
|
|
36
|
+
- `exit()` / `quit()` (also bare `exit`) leave the REPL; `exit(code)` also works in scripts.
|
|
37
|
+
- `caelix --highlight file.clx`; `NO_COLOR` is honored.
|
|
38
|
+
- Editor support files for nano, vim and VS Code in `editor/`.
|
|
39
|
+
- New tests: highlight (text is never altered), pty-driven REPL session, REPL exit.
|
|
40
|
+
|
|
41
|
+
## 1.1.0
|
|
42
|
+
- New modules: `core` (text/list utilities), `network` (TCP sockets), `database` (embedded JSON-file tables).
|
|
43
|
+
- `system.args()` returns the script's command-line arguments.
|
|
44
|
+
- `examples/todo.clx`; tests for all new modules (also under GC stress and AddressSanitizer).
|
|
45
|
+
|
|
46
|
+
## 1.0.1
|
|
47
|
+
- `else if` now works as a synonym for `elif`.
|
|
48
|
+
- A `{` in a string is literal unless its contents parse as an expression, so JSON-like text needs no `\{`.
|
|
49
|
+
|
|
50
|
+
## 1.0.0
|
|
51
|
+
- Garbage collector (mark-and-sweep; stress-tested; `system.gc()`, `CAELIX_GC_STRESS`, `CAELIX_GC_STATS`).
|
|
52
|
+
- `http` module (plain HTTP client: get, post, request).
|
|
53
|
+
- CLXPM registry support: `clxpm install name[@version]`, `clxpm pack`, `$CLXPM_REGISTRY` (http/https/file), checksum
|
|
54
|
+
verification and unsafe-path rejection; `clxpm update` follows the registry.
|
|
55
|
+
|
|
56
|
+
## 0.9.0
|
|
57
|
+
- CLXPM: `clxpm create | install | remove | update | list` for local package directories; `use` finds `clx_modules/`.
|
|
58
|
+
- `make install` / `make uninstall` (installs `caelix`, `clxpm`, stdlib; honors `PREFIX` and `DESTDIR`).
|
|
59
|
+
- Documentation: `docs/LANGUAGE.md`.
|
|
60
|
+
|
|
61
|
+
## 0.5.0
|
|
62
|
+
- REPL, source-line error snippets, `json` module.
|
|
63
|
+
|
|
64
|
+
## 0.4.0
|
|
65
|
+
- Classes, `use`, try/catch, modules, typed declarations.
|
|
66
|
+
|
|
67
|
+
## 0.1 to 0.3
|
|
68
|
+
- Lexer, parser, expressions, conditions, all loop forms, functions, lists, maps, interpolation.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The Caelix authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include README.md LICENSE CHANGELOG.md Makefile clxpm
|
|
2
|
+
recursive-include src *.c
|
|
3
|
+
recursive-include include *.h
|
|
4
|
+
recursive-include tools *.c
|
|
5
|
+
recursive-include stdlib *.clx
|
|
6
|
+
recursive-include docs *.md
|
|
7
|
+
recursive-include examples *.clx
|
|
8
|
+
recursive-include editor *
|
|
9
|
+
recursive-include tests *
|
|
10
|
+
recursive-include python *.py
|
|
11
|
+
prune tests/__pycache__
|
|
12
|
+
global-exclude *.o
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
CC ?= cc
|
|
2
|
+
CFLAGS ?= -std=c11 -Wall -Wextra -O2
|
|
3
|
+
PREFIX ?= /usr/local
|
|
4
|
+
CFLAGS += -Iinclude -DCAELIX_STDLIB_DIR=\"$(PREFIX)/share/caelix/stdlib\"
|
|
5
|
+
LDLIBS += -lm
|
|
6
|
+
|
|
7
|
+
# HTTPS: TLS=auto (default) uses OpenSSL when its development files are installed; TLS=0 or TLS=1 force it.
|
|
8
|
+
TLS ?= auto
|
|
9
|
+
TLS_INC ?=
|
|
10
|
+
TLS_LIBS ?= -lssl -lcrypto
|
|
11
|
+
ifeq ($(TLS),auto)
|
|
12
|
+
TLS := $(if $(shell $(CC) tools/tls_probe.c -o .tlsprobe $(TLS_INC) $(TLS_LIBS) 2>/dev/null && rm -f .tlsprobe && echo 1),1,0)
|
|
13
|
+
endif
|
|
14
|
+
ifeq ($(TLS),1)
|
|
15
|
+
CFLAGS += -DCAELIX_TLS $(TLS_INC)
|
|
16
|
+
LDLIBS += $(TLS_LIBS)
|
|
17
|
+
endif
|
|
18
|
+
ifneq ($(MAKECMDGOALS),clean)
|
|
19
|
+
$(info Caelix build: HTTPS $(if $(filter 1,$(TLS)),ENABLED (OpenSSL),disabled - install OpenSSL then 'make clean && make' to enable))
|
|
20
|
+
endif
|
|
21
|
+
SRC := $(wildcard src/*.c)
|
|
22
|
+
OBJ := $(SRC:.c=.o)
|
|
23
|
+
|
|
24
|
+
all: caelix
|
|
25
|
+
|
|
26
|
+
caelix: $(OBJ)
|
|
27
|
+
$(CC) $(OBJ) -o $@ $(LDLIBS)
|
|
28
|
+
|
|
29
|
+
src/%.o: src/%.c include/caelix.h
|
|
30
|
+
$(CC) $(CFLAGS) -c $< -o $@
|
|
31
|
+
|
|
32
|
+
test: caelix
|
|
33
|
+
sh tests/run_tests.sh
|
|
34
|
+
CAELIX_GC_STRESS=1 sh tests/run_tests.sh
|
|
35
|
+
sh tests/repl_test.sh
|
|
36
|
+
sh tests/clxpm_test.sh
|
|
37
|
+
sh tests/http_test.sh
|
|
38
|
+
sh tests/https_test.sh
|
|
39
|
+
sh tests/network_test.sh
|
|
40
|
+
sh tests/date_tz_test.sh
|
|
41
|
+
sh tests/highlight_test.sh
|
|
42
|
+
sh tests/pty_test.sh
|
|
43
|
+
sh tests/pip_test.sh
|
|
44
|
+
|
|
45
|
+
install: caelix
|
|
46
|
+
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/caelix/stdlib
|
|
47
|
+
rm -f $(DESTDIR)$(PREFIX)/bin/caelix $(DESTDIR)$(PREFIX)/bin/clxpm
|
|
48
|
+
cp caelix clxpm $(DESTDIR)$(PREFIX)/bin/
|
|
49
|
+
chmod +x $(DESTDIR)$(PREFIX)/bin/clxpm
|
|
50
|
+
cp stdlib/*.clx $(DESTDIR)$(PREFIX)/share/caelix/stdlib/
|
|
51
|
+
|
|
52
|
+
uninstall:
|
|
53
|
+
rm -f $(DESTDIR)$(PREFIX)/bin/caelix $(DESTDIR)$(PREFIX)/bin/clxpm
|
|
54
|
+
rm -rf $(DESTDIR)$(PREFIX)/share/caelix
|
|
55
|
+
|
|
56
|
+
clean:
|
|
57
|
+
rm -f $(OBJ) caelix
|
|
58
|
+
rm -rf build dist python/*.egg-info
|
|
59
|
+
|
|
60
|
+
.PHONY: all test clean install uninstall
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: caelix-lang
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Caelix: a small interpreted programming language written in C (display, ask, classes, modules, REPL).
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: caelix programming-language interpreter repl
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: POSIX
|
|
9
|
+
Classifier: Programming Language :: C
|
|
10
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
11
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: keywords
|
|
19
|
+
Dynamic: license
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
# Caelix 2.1.0
|
|
25
|
+
|
|
26
|
+
A small interpreted language written in C11: custom lexer, recursive-descent parser, AST, tree-walking
|
|
27
|
+
interpreter, mark-and-sweep garbage collector. No Python, no LLVM, no regex parsing.
|
|
28
|
+
|
|
29
|
+
make # build ./caelix (uses OpenSSL for HTTPS if it is installed)
|
|
30
|
+
make test # all tests (also re-runs the suite with GC stress)
|
|
31
|
+
make PREFIX=/your/prefix install # caelix, clxpm and stdlib (Termux sets PREFIX already)
|
|
32
|
+
./caelix examples/hello.clx
|
|
33
|
+
./caelix # REPL with live syntax highlighting (exit() or Ctrl-D quits)
|
|
34
|
+
./caelix --highlight file.clx # print a file in color
|
|
35
|
+
|
|
36
|
+
Builds with gcc or clang. Termux: `pkg install clang make openssl` (OpenSSL is optional; without it everything
|
|
37
|
+
works except `https://`). The build prints `HTTPS ENABLED` or `HTTPS disabled` so you can see which you got. Docs: `docs/LANGUAGE.md`. History: `CHANGELOG.md`.
|
|
38
|
+
|
|
39
|
+
## Install with pip
|
|
40
|
+
|
|
41
|
+
pip install caelix-lang
|
|
42
|
+
caelix --version # Caelix 2.1.0
|
|
43
|
+
caelix # REPL (caelix file.clx runs a program)
|
|
44
|
+
clxpm help # package manager
|
|
45
|
+
|
|
46
|
+
pip compiles the interpreter on your machine, so you need **Python 3.8+ and a C compiler**
|
|
47
|
+
(Termux: `pkg install python clang`; Debian/Ubuntu: `apt install build-essential`; macOS: `xcode-select --install`).
|
|
48
|
+
Windows is not supported natively (use WSL). If OpenSSL's development files are installed when you run pip
|
|
49
|
+
(Termux: `pkg install openssl`), `https://` is enabled; force it on or off with `CAELIX_TLS=1` / `CAELIX_TLS=0`.
|
|
50
|
+
`http.tls` in a program tells you which you got. The standard library is installed next to the commands
|
|
51
|
+
(`<prefix>/share/caelix/stdlib`) and found automatically. Remove with `pip uninstall caelix-lang`.
|
|
52
|
+
`python -m caelix_lang file.clx` also works.
|
|
53
|
+
|
|
54
|
+
The PyPI name is **caelix-lang**, not `caelix`: the name `caelix` on PyPI already belongs to someone else (a
|
|
55
|
+
0.0.1 placeholder). The commands you type are still `caelix` and `clxpm`. To use another PyPI name, change
|
|
56
|
+
`DIST_NAME` at the top of `setup.py`.
|
|
57
|
+
|
|
58
|
+
**Publishing a release (maintainer notes).** You need a PyPI account and an API token, and the name must still be free.
|
|
59
|
+
|
|
60
|
+
python -m pip install build twine
|
|
61
|
+
python -m build --sdist # dist/caelix_lang-X.Y.Z.tar.gz
|
|
62
|
+
python -m twine check dist/*
|
|
63
|
+
python -m twine upload --repository testpypi dist/* # rehearse on TestPyPI first
|
|
64
|
+
python -m twine upload dist/*
|
|
65
|
+
|
|
66
|
+
Every upload needs a new version number (edit `CAELIX_VERSION` in `include/caelix.h`, the single source of the
|
|
67
|
+
version). Only the source package is published, so every user needs a compiler; prebuilt wheels for Linux and macOS
|
|
68
|
+
would remove that, and need a CI job that builds them. The same wheel/sdist builds are exercised by `tests/pip_test.sh`.
|
|
69
|
+
|
|
70
|
+
## What exists
|
|
71
|
+
|
|
72
|
+
| Area | Status |
|
|
73
|
+
|---|---|
|
|
74
|
+
| Language (spec 0.1 to 0.4) | done: variables, types, conditions, all loops, functions, lists, maps, interpolation, classes, `use`, try/catch |
|
|
75
|
+
| REPL (live highlighting, history, `exit()`), errors with source line + caret | done |
|
|
76
|
+
| Garbage collector | done (see below) |
|
|
77
|
+
| Modules | `math`, `files`, `time`, `date`, `system`, `json`, `http` (HTTP and HTTPS), `core`, `network`, `database` |
|
|
78
|
+
| Classes | fields, methods, `init`, single inheritance (`extends`, `super`, `is_a`) |
|
|
79
|
+
| CLXPM | done: local packages and a static-file registry (see below) |
|
|
80
|
+
| Not implemented | UDP, SQL, multiple inheritance, lambdas, regex |
|
|
81
|
+
|
|
82
|
+
## Grammar decisions (please review)
|
|
83
|
+
|
|
84
|
+
1. **`elif` and `else if` both work** and mean the same thing (`else if` on one line; `else` followed by a newline and `if` is a nested `if` that needs its own `end`).
|
|
85
|
+
2. **Range comma ambiguity.** `for i in a, b[, step]` is a range; `for x in expr` (no top-level comma) iterates a
|
|
86
|
+
list, string (bytes) or map (keys). Commas inside `[]`, `()`, `{}` belong to those. Range bounds are inclusive,
|
|
87
|
+
must be Int, step defaults to 1. `for i in 10, 1` therefore runs zero times; reverse needs an explicit `-1`.
|
|
88
|
+
3. **`display a, b`** prints values separated by one space; add `sep = "-"` to choose another separator. So `display "Age: ", age` prints `Age: 14` (two spaces); use `display "Age:", age` or `sep = ""`.
|
|
89
|
+
4. **`self`** is required inside methods to reach fields (`self.health`). The spec did not define this.
|
|
90
|
+
Optional `function init(...)` is the constructor.
|
|
91
|
+
5. **`/`** always returns Float (`10 / 2` is `5.0`). `%` is floor-modulo. `**` on Ints stays Int.
|
|
92
|
+
6. `"text" + 5` converts the non-string side to text. `+` on two Lists concatenates.
|
|
93
|
+
7. `and` / `or` / `not` return Bool. Truthy: not null/false/0/0.0/""/[]/{}.
|
|
94
|
+
8. Typed declarations (`age: Int = 14`) are checked **at declaration only**. `x: Float = 3` converts to 3.0.
|
|
95
|
+
9. Commands without parentheses: `display`, `ask`, `add`, `remove`, `read`, `fail`.
|
|
96
|
+
10. Interpolation: `"{expr}"` inserts a value **only when the text inside the braces parses as one expression**.
|
|
97
|
+
Anything else stays literal, so `'{"a": 1}'` and `"{x: 1}"` need no escaping. `\{` still forces a literal brace
|
|
98
|
+
(use it for something like `{name}` that you want printed as text). The expression cannot contain the string's
|
|
99
|
+
own quote type (write `"{m['k']}"`).
|
|
100
|
+
11. `catch error` binds the error **message as a String**; raise your own with `fail("message")`.
|
|
101
|
+
12. Extra built-ins beyond the spec list: `keys`, `has`, `read`, `fail`, `exit`, `quit`.
|
|
102
|
+
|
|
103
|
+
## Garbage collector
|
|
104
|
+
|
|
105
|
+
Precise mark-and-sweep over strings, lists, maps, functions, classes and instances. Roots are all live scopes,
|
|
106
|
+
a temp-root stack for values held mid-expression, the return value and the module cache. It runs only at
|
|
107
|
+
statement boundaries (or on `system.gc()`, which returns the live object count), so native functions never see
|
|
108
|
+
an object disappear. The test suite is also run with `CAELIX_GC_STRESS=1` (collect before every statement) and was
|
|
109
|
+
checked under AddressSanitizer. `CAELIX_GC_STATS=1` prints collection counts at exit.
|
|
110
|
+
Measured: a 2,000,000-iteration string-building loop peaks around 11 MB.
|
|
111
|
+
|
|
112
|
+
Limits: scopes captured by a closure, and everything they reference, are never freed (a function that creates an
|
|
113
|
+
inner function leaks that call's scope). Instances are not freed while their class is reachable by name.
|
|
114
|
+
|
|
115
|
+
## http module (HTTP and HTTPS)
|
|
116
|
+
|
|
117
|
+
use http
|
|
118
|
+
r = http.get("http://127.0.0.1:8080/x") // map: status (Int), body (String), headers (Map, lower-case keys)
|
|
119
|
+
http.post(url, body [, content_type])
|
|
120
|
+
http.request("PUT", url [, body [, content_type]])
|
|
121
|
+
|
|
122
|
+
HTTP/1.0 over sockets, 15 s timeout, 64 MB response cap, chunked responses decoded. A response shorter than its
|
|
123
|
+
`Content-Length` is an error. Redirects are not followed. Bodies with NUL bytes are truncated (strings are C strings).
|
|
124
|
+
|
|
125
|
+
**HTTPS** needs OpenSSL 1.1 or newer when you build (Termux: `pkg install openssl`, then `make clean && make`;
|
|
126
|
+
`http.tls` tells a script whether the running build has it). It checks the server certificate against the system's
|
|
127
|
+
trusted authorities and checks that the certificate matches the host name or IP address you asked for (TLS 1.2 or
|
|
128
|
+
newer, SNI sent). A bad certificate raises an error; there is no "ignore certificate errors" switch. To trust a
|
|
129
|
+
private certificate authority or a self-signed test certificate, point `SSL_CERT_FILE` at its PEM file. Without
|
|
130
|
+
OpenSSL, `https://` raises an error saying so. Tested here against local TLS servers (untrusted, trusted,
|
|
131
|
+
wrong-host, IP-address and chunked cases), not against the public internet.
|
|
132
|
+
|
|
133
|
+
## REPL and syntax highlighting
|
|
134
|
+
|
|
135
|
+
On a real terminal the REPL is a small line editor: your input is colored **as you type** (keywords, strings,
|
|
136
|
+
numbers, comments, `{interpolation}`, function calls, class names), blocks keep prompting with `...` until `end`,
|
|
137
|
+
and results are colored too.
|
|
138
|
+
|
|
139
|
+
- **Leave:** `exit()`, `quit()`, bare `exit` / `quit`, or Ctrl-D. `exit(3)` sets the exit code. `exit()` also works in scripts.
|
|
140
|
+
- **Keys:** Left/Right/Home/End, Backspace/Delete, Up/Down history (saved in `~/.caelix_history`), Ctrl-A/E start/end,
|
|
141
|
+
Ctrl-U/K delete to start/end, Ctrl-W delete word, Ctrl-L clear screen, Tab inserts 4 spaces,
|
|
142
|
+
Ctrl-C throws away the current line or block.
|
|
143
|
+
- **Plain mode:** piped input, a non-terminal, `TERM=dumb`, or `NO_COLOR=1` (colors only) fall back automatically.
|
|
144
|
+
- **Files:** `caelix --highlight file.clx` prints colored source (`| less -R` to page it). For editing, see
|
|
145
|
+
`editor/README.md`: ready-made files for **nano** (`editor/nano/caelix.nanorc`), **vim** and **VS Code**.
|
|
146
|
+
The editor files were written to each program's documented format and checked for valid syntax, but I could not
|
|
147
|
+
run them inside nano/vim/VS Code here; the built-in `--highlight` and REPL highlighting are fully tested.
|
|
148
|
+
- The highlighter uses the real parser to decide what is interpolation, so `"{name}"` is marked but `'{"a": 1}'` is not.
|
|
149
|
+
|
|
150
|
+
## Classes and inheritance
|
|
151
|
+
|
|
152
|
+
class Animal
|
|
153
|
+
sound = "..."
|
|
154
|
+
function init(name)
|
|
155
|
+
self.name = name
|
|
156
|
+
end
|
|
157
|
+
function speak()
|
|
158
|
+
display self.name, "says", self.sound
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
class Dog extends Animal
|
|
162
|
+
sound = "woof"
|
|
163
|
+
function init(name, trick)
|
|
164
|
+
super.init(name) // call the parent's version
|
|
165
|
+
self.trick = trick
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
d = Dog("Rex", "sit") d.speak() display is_a(d, Animal) // true
|
|
169
|
+
|
|
170
|
+
A child inherits fields (and may override their defaults) and methods. `super.method(...)` calls the parent's
|
|
171
|
+
method on the same object; it works only inside methods and only for methods (not fields). `init` is inherited if
|
|
172
|
+
the child has none. `is_a(x, Class)` is true for the class and all its ancestors. One parent per class.
|
|
173
|
+
|
|
174
|
+
## Renamed from Veyra (2.0.0)
|
|
175
|
+
|
|
176
|
+
The language was called Veyra up to 1.4.0. Nothing about the language changed, but every name did:
|
|
177
|
+
|
|
178
|
+
| Veyra | Caelix |
|
|
179
|
+
|---|---|
|
|
180
|
+
| `veyra` command | `caelix` |
|
|
181
|
+
| `vpm` package manager | `clxpm` |
|
|
182
|
+
| `.vyr` files | `.clx` |
|
|
183
|
+
| `vpm_modules/`, `vpm.lock`, `veyra.json` | `clx_modules/`, `clxpm.lock`, `caelix.json` |
|
|
184
|
+
| `VPM_REGISTRY`, `VEYRA_STDLIB`, `VEYRA_GC_STRESS`, `VEYRA_GC_STATS`, `VEYRA_BIN` | `CLXPM_REGISTRY`, `CAELIX_STDLIB`, `CAELIX_GC_STRESS`, `CAELIX_GC_STATS`, `CAELIX_BIN` |
|
|
185
|
+
| `~/.veyra_history`, `share/veyra/stdlib` | `~/.caelix_history`, `share/caelix/stdlib` |
|
|
186
|
+
| `editor/vscode-veyra`, `veyra.nanorc` | `editor/vscode-caelix`, `caelix.nanorc` |
|
|
187
|
+
|
|
188
|
+
To move old programs over, rename the files (modules are now found as `name.clx`, not `name.vyr`) and, if you have
|
|
189
|
+
Veyra packages, rename `veyra.json` to `caelix.json` and `vpm_modules` to `clx_modules`:
|
|
190
|
+
|
|
191
|
+
for f in *.vyr; do mv "$f" "${f%.vyr}.clx"; done
|
|
192
|
+
sed -i 's/^\(\s*\)say\b/\1display/' *.clx # only for files written before 1.3.1
|
|
193
|
+
|
|
194
|
+
The old `veyra` and `vpm` commands are not kept as aliases. Inside the C sources the internal helper prefix `vy_`
|
|
195
|
+
is unchanged (it is not visible to programs).
|
|
196
|
+
|
|
197
|
+
## Changes in 1.4.0: `ask` with a type
|
|
198
|
+
|
|
199
|
+
name = ask "Enter name: " // String (default, unchanged)
|
|
200
|
+
age = ask (int) "Enter age: " // Int
|
|
201
|
+
price = ask (float) "Enter price: " // Float
|
|
202
|
+
active = ask (bool) "Active? " // Bool (true/false, yes/no, y/n, 1/0, on/off)
|
|
203
|
+
|
|
204
|
+
Surrounding spaces are ignored for `int`, `float` and `bool`. Bad input raises a catchable error that quotes the text
|
|
205
|
+
(`ask (int): "forty" is not a whole number (for example 42 or -7)`); it does not re-prompt. At end of input a typed `ask`
|
|
206
|
+
is an error while a plain `ask` still returns `null`. `(str)` is accepted as an explicit spelling of the default.
|
|
207
|
+
Existing `ask "..."`, bare `ask` and `ask ("prompt")` are unchanged. Details and the exact rules: `docs/LANGUAGE.md`.
|
|
208
|
+
|
|
209
|
+
## Changes in 1.3.1
|
|
210
|
+
|
|
211
|
+
- **`say` is now `display`.** Same behavior, new name. `say` is no longer a keyword; using it gives a hint
|
|
212
|
+
(`'say' was renamed to 'display'`). To convert old files: `sed -i 's/^\(\s*\)say\b/\1display/' file.clx`.
|
|
213
|
+
- **String operations** `uppercase` `lowercase` `capitalize` `shred` `reverse` `length` `ridiculous`:
|
|
214
|
+
|
|
215
|
+
name = "pamu"
|
|
216
|
+
display uppercase.{name} // PAMU
|
|
217
|
+
display capitalize."hello world" // Hello world
|
|
218
|
+
display shred." hello " // hello
|
|
219
|
+
display ridiculous."simple" // SiMpLe
|
|
220
|
+
|
|
221
|
+
Operand: a string, `{expression}`, or another operation. `capitalize` changes only the first character.
|
|
222
|
+
`ridiculous` alternates over letters only (`"hello world"` -> `HeLlO wOrLd`). `reverse` is UTF-8 safe;
|
|
223
|
+
`length` counts bytes and also takes lists and maps. Full rules in `docs/LANGUAGE.md`.
|
|
224
|
+
- **`sep`:** `display "Hello", "World" sep = "-"` prints `Hello-World`. `sep` is only special right after the values of a
|
|
225
|
+
`display` and must be a String; as a variable name it still works.
|
|
226
|
+
- **`/n/` is a newline inside strings:** `display "hello/n/world"` prints two lines. `\n` still works too. To print the
|
|
227
|
+
literal text `/n/`, write `\/n/`. Any existing string that contained `/n/` now has a newline there.
|
|
228
|
+
|
|
229
|
+
## Operators added in 1.3
|
|
230
|
+
|
|
231
|
+
- **`in` / `not in`:** `"a" in list`, `"ell" in "hello"`, `"key" in map` (keys), `x not in list`.
|
|
232
|
+
- **`x++` / `x--`:** statements only (not inside expressions), on variables, list items and fields: `count++`, `items[0]--`.
|
|
233
|
+
- **Error hints:** the interpreter now suggests fixes: a missing comma (`display "a" b`, `[1 2]`), words from other languages
|
|
234
|
+
(`print`, `return`, `break`, `elseif`, `let`...), typos in keywords, and "did you mean" for misspelled variables,
|
|
235
|
+
map keys, object fields and module functions.
|
|
236
|
+
|
|
237
|
+
## date module
|
|
238
|
+
|
|
239
|
+
Timestamps are whole seconds since 1970-01-01 UTC (`date.now()` returns a Float). Functions without a suffix use the
|
|
240
|
+
device's local time zone; the `_utc` twins use UTC. Month and weekday names are English.
|
|
241
|
+
|
|
242
|
+
use date
|
|
243
|
+
t = date.make(2024, 2, 29, 12, 30) // local time -> timestamp (make_utc for UTC)
|
|
244
|
+
date.parts(t) // {year, month, day, hour, minute, second, weekday (1=Mon..7=Sun), weekday_name, month_name, yday, timestamp}
|
|
245
|
+
date.format(t, "%A, %d %B %Y %H:%M") // strftime codes
|
|
246
|
+
date.parse("2024-03-01 08:15", "%Y-%m-%d %H:%M") // strptime codes -> timestamp
|
|
247
|
+
date.add(t, "months", 1) // units: seconds minutes hours days weeks months years (negative allowed)
|
|
248
|
+
date.diff(a, b, "days") // b - a; Float for seconds..weeks, whole Int for months/years
|
|
249
|
+
date.today() date.now() date.is_leap(2024) date.days_in_month(2024, 2)
|
|
250
|
+
|
|
251
|
+
`add` is calendar-aware: adding days keeps the wall-clock hour across daylight-saving changes, and Jan 31 + 1 month is
|
|
252
|
+
Feb 28/29. A local time that does not exist (the daylight-saving gap) is an error. `parse` rejects text that does not
|
|
253
|
+
match the format and impossible dates such as Feb 31.
|
|
254
|
+
|
|
255
|
+
## core module (text and list utilities)
|
|
256
|
+
|
|
257
|
+
use core
|
|
258
|
+
core.split("a,b", ",") core.join(list, ", ") core.replace(s, old, new) core.trim(s)
|
|
259
|
+
core.upper(s) core.lower(s) core.starts_with(s, p) core.ends_with(s, p) core.index_of(x, item)
|
|
260
|
+
core.slice(x, start[, end]) core.chars(s) core.ord("A") core.chr(65) core.pad_left(s, w[, fill]) core.pad_right
|
|
261
|
+
core.sort(list) core.sort_by(list_of_maps, "key") core.reverse(x) core.pop(list) core.insert(list, i, v)
|
|
262
|
+
core.sum(list) core.range(a, b[, step]) core.unique(list) core.min(list) core.max(list)
|
|
263
|
+
core.copy(x) core.values(map) core.assert(cond[, message]) core.version
|
|
264
|
+
|
|
265
|
+
`sort`, `reverse`, `slice`, `range` return new values; `pop` and `insert` change the list. `slice` ends are
|
|
266
|
+
exclusive and may be negative. `range` is inclusive, like `for i in a, b`. `chr` supports ASCII 1 to 127.
|
|
267
|
+
|
|
268
|
+
## network module (TCP sockets)
|
|
269
|
+
|
|
270
|
+
use network
|
|
271
|
+
c = network.connect("127.0.0.1", 8080 [, timeout_secs]) // handle (Int)
|
|
272
|
+
network.send(c, "text\n") network.recv(c [, max_bytes]) network.recv_line(c) // null when closed
|
|
273
|
+
srv = network.listen(0 [, "127.0.0.1"]) network.port(srv) conn = network.accept(srv)
|
|
274
|
+
network.timeout(h, secs) network.close(h) network.resolve("localhost") network.hostname()
|
|
275
|
+
|
|
276
|
+
Handles are small Ints; at most 255 are open at once. Text only (a NUL byte ends received data). No TLS, no UDP.
|
|
277
|
+
Timeouts raise a catchable error.
|
|
278
|
+
|
|
279
|
+
## database module (embedded tables)
|
|
280
|
+
|
|
281
|
+
use database
|
|
282
|
+
db = database.open("app.db") // or ":memory:"; the file is created on save/close
|
|
283
|
+
database.create_table(db, "users") // true if new, false if it already existed
|
|
284
|
+
id = database.insert(db, "users", {name: "Amy", age: 25}) // rows get an automatic Int "id"
|
|
285
|
+
database.get(db, "users", id) // row, or null
|
|
286
|
+
database.all(db, "users") database.find(db, "users", {age: 25}) database.count(db, "users"[, {where}])
|
|
287
|
+
database.update(db, "users", id, {age: 26}) database.delete(db, "users", id) // true/false
|
|
288
|
+
database.tables(db) database.drop_table(db, "users") database.save(db) database.close(db)
|
|
289
|
+
|
|
290
|
+
Data is kept in memory and written (atomically, via a temp file and rename) by `database.save` and
|
|
291
|
+
`database.close`; **changes are lost if the script ends without saving**. The file is plain JSON. Values must be
|
|
292
|
+
JSON-encodable. `find` matches rows whose fields equal every key you give. Rows you get back are shallow
|
|
293
|
+
copies: editing one does nothing until you call `update`. Lookups scan the table, so it suits thousands of rows,
|
|
294
|
+
not millions. There is no SQL, no indexes and no transactions.
|
|
295
|
+
|
|
296
|
+
## clxpm (package manager)
|
|
297
|
+
|
|
298
|
+
clxpm create name scaffold a package
|
|
299
|
+
clxpm install ./dir local package -> ./clx_modules/<name>, recorded in ./clxpm.lock
|
|
300
|
+
clxpm install name[@version] from the registry in $CLXPM_REGISTRY
|
|
301
|
+
clxpm update [name] clxpm remove name clxpm list
|
|
302
|
+
clxpm pack ./dir [outdir] build registry files from a package
|
|
303
|
+
|
|
304
|
+
A package is a directory with `main.clx` and `caelix.json` (`{"name": "...", "version": "..."}`); `use name` loads it.
|
|
305
|
+
A **registry** is any static file host (`http://`, `https://` or `file://`) with `<name>/latest`,
|
|
306
|
+
`<name>/<version>.tar.gz` and `<name>/<version>.tar.gz.sha256`; `clxpm pack` writes exactly that layout, so
|
|
307
|
+
"publishing" means uploading its output directory yourself. Installs verify the checksum when published, reject
|
|
308
|
+
archives with absolute or `..` paths, and check the archive's declared name. Downloads use `curl` or `wget`
|
|
309
|
+
(that is how https registries work, independent of whether Caelix itself was built with TLS). There is no hosted public registry, no
|
|
310
|
+
dependency resolution between packages, and no signature verification beyond the checksum.
|
|
311
|
+
|
|
312
|
+
## Other limits
|
|
313
|
+
|
|
314
|
+
- Strings are bytes: `length("é")` is 2.
|
|
315
|
+
- Map keys must be Strings. Missing keys on `m.x` / `m["x"]` are errors.
|
|
316
|
+
- Recursion limit 2000 calls (a catchable error).
|
|
317
|
+
- No multiple inheritance, anonymous functions or `finally`.
|
|
318
|
+
- Module exports are a snapshot of the module's variables taken after it runs.
|