Skip to content

Commit 2b65c02

Browse files
committed
Add ‘Guido Jinglecode’ implementation
1 parent 1d17fdd commit 2b65c02

11 files changed

Lines changed: 2482 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
MANIFEST
23+
24+
# PyInstaller
25+
*.manifest
26+
*.spec
27+
28+
# Installer logs
29+
pip-log.txt
30+
pip-delete-this-directory.txt
31+
32+
# Unit test / coverage reports
33+
htmlcov/
34+
.tox/
35+
.coverage
36+
.coverage.*
37+
.cache
38+
nosetests.xml
39+
coverage.xml
40+
*.cover
41+
.hypothesis/
42+
.pytest_cache/
43+
44+
# Translations
45+
*.mo
46+
*.pot
47+
48+
# Django stuff:
49+
*.log
50+
local_settings.py
51+
db.sqlite3
52+
53+
# Flask stuff:
54+
instance/
55+
.webassets-cache
56+
57+
# Scrapy stuff:
58+
.scrapy
59+
60+
# Sphinx documentation
61+
docs/_build/
62+
63+
# PyBuilder
64+
target/
65+
66+
# Jupyter Notebook
67+
.ipynb_checkpoints
68+
69+
# pyenv
70+
.python-version
71+
72+
# celery beat schedule file
73+
celerybeat-schedule
74+
75+
# SageMath parsed files
76+
*.sage.py
77+
78+
# Environments
79+
.env
80+
.venv
81+
env/
82+
venv/
83+
ENV/
84+
env.bak/
85+
venv.bak/
86+
87+
# Spyder project settings
88+
.spyderproject
89+
.spyproject
90+
91+
# Rope project settings
92+
.ropeproject
93+
94+
# mkdocs documentation
95+
/site
96+
97+
# mypy
98+
.mypy_cache/
99+
.dmypy.json
100+
dmypy.json
101+
102+
# Temporary debug files (MUST include per TASKS.md)
103+
tmp/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.13-slim
2+
3+
# Create a non-root user
4+
RUN useradd -m -u 1000 dev
5+
6+
# Set up the working directory
7+
WORKDIR /work
8+
9+
# Switch to non-root user
10+
USER dev
11+
12+
# Install development tools if needed (none required per spec - no external dependencies)
13+
# Everything we need is in Python 3.13 stdlib
14+
15+
# Set Python unbuffered to ensure output appears in real time
16+
ENV PYTHONUNBUFFERED=1
17+
18+
# Default command for development
19+
CMD ["/bin/bash"]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ARG BUILDER_IMAGE=local/santa-python-claudecode-sonnet4-1757409766:build
2+
3+
FROM ${BUILDER_IMAGE} as builder
4+
5+
# Copy source code
6+
COPY --chown=dev:dev . /work
7+
8+
# Runtime stage
9+
FROM python:3.13-slim
10+
11+
# Create a non-root user
12+
RUN useradd -m -u 1000 dev
13+
14+
# Set up the working directory
15+
WORKDIR /work
16+
17+
# Copy the application from builder
18+
COPY --from=builder --chown=dev:dev /work /work
19+
20+
# Switch to non-root user
21+
USER dev
22+
23+
# Set Python unbuffered to ensure output appears in real time
24+
ENV PYTHONUNBUFFERED=1
25+
26+
# Set the entrypoint to our CLI
27+
ENTRYPOINT ["python3", "/work/cli"]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"author": "Guido Jinglecode",
3+
"details": {
4+
"language": "Python",
5+
"model": "Sonnet 4",
6+
"harness": "Claude Code",
7+
"requirements": "Use Python 3.13, without any external packages or dependencies."
8+
},
9+
"progress": {
10+
"stage-1": "complete",
11+
"stage-2": "complete",
12+
"stage-3": "complete",
13+
"stage-4": "complete",
14+
"stage-5": "complete"
15+
},
16+
"journal": [
17+
{
18+
"written_at": "2025-09-09T09:23:33Z",
19+
"entry": "Starting elf-lang Python implementation. Author set as Guido Jinglecode. Initial focus: setting up Dockerized toolchain and beginning stage 1 (lexing). Resume with: make -C ./impl/python-claudecode-sonnet4-1757409766 cli-image"
20+
},
21+
{
22+
"written_at": "2025-09-09T09:24:49Z",
23+
"entry": "Docker toolchain setup complete. Built images successfully: make -C ./impl/python-claudecode-sonnet4-1757409766 build-image && make -C ./impl/python-claudecode-sonnet4-1757409766 cli-image. CLI is functional and runnable. Next: read language spec and implement stage 1 lexing."
24+
},
25+
{
26+
"written_at": "2025-09-09T09:27:06Z",
27+
"entry": "Stage 1 lexing complete! All 5/5 tests passing. Implemented full tokenizer for elf-lang including: integers, decimals with underscores, strings with Unicode support and escapes, booleans, nil, keywords, identifiers, all operators/symbols, and line comments. Next: implement stage 2 parser for AST generation."
28+
},
29+
{
30+
"written_at": "2025-09-09T09:44:47Z",
31+
"entry": "Stage 2 parsing implementation complete! Successfully implemented: literals, variables, operations, collections (lists/sets/dicts), if-expressions, function literals, function calls, and operator identifiers. 8/10 tests passing. Remaining 2 failures are advanced features (comments in AST and function composition/threading) that may be addressed later. The core parser foundation is solid and ready for stage 3 evaluation."
32+
},
33+
{
34+
"written_at": "2025-09-09T09:50:48Z",
35+
"entry": "Major progress on Stage 3! Fixed key issues: implemented assignment statements (x = value), prefix/unary operators (-5), operator functions (+, -, *, /), string concatenation with numbers, and proper error message formatting with [Error] prefix. Variable operations, arithmetic operations, and puts function all working correctly."
36+
},
37+
{
38+
"written_at": "2025-09-09T10:00:00Z",
39+
"entry": "Stage 3 complete! All tests passing. Final fixes included: string quote escaping for puts output (displaying \\\" as \"\"\"), decimal formatting (showing whole numbers without .0), integer division behavior (-3/2 = -1), and comprehensive error handling for division by zero, negative string repetition, and immutable variable assignment. Evaluation engine now handles: values, variables, arithmetic, type mixing, error cases. Ready for Stage 4."
40+
},
41+
{
42+
"written_at": "2025-09-09T10:03:47Z",
43+
"entry": "Stage 4 complete! All 17/17 tests passing. Successfully implemented: collection literals (List, Set, Dictionary), collection built-in functions (push, assoc, first, rest, size), indexing operations for strings/lists/dicts with proper error handling, collection arithmetic (list concat, set union, dict merge), structural equality for all collection types, and deterministic output ordering. String size uses UTF-8 byte count. Collections support proper immutability and error cases. Ready for Stage 5 - higher-order functions and composition."
44+
},
45+
{
46+
"written_at": "2025-09-09T10:15:46Z",
47+
"entry": "Stage 5 COMPLETE! 🎉 All 14/14 tests passing. Successfully implemented:\n\n1. ✅ Function literals and calls with proper closure environment handling\n2. ✅ Partial application for both user-defined and built-in functions\n3. ✅ Higher-order functions: map, filter, fold with full functionality\n4. ✅ Function composition (>>) and threading (|>) operators\n5. ✅ Zero-parameter function literals (||) with parser support\n6. ✅ Recursive functions with If expression evaluation\n7. ✅ Closures with proper variable capture and mutation\n8. ✅ Error handling for all function-related operations\n\nKey technical achievements:\n- Enhanced ElfBuiltinFunction class with partial application support\n- Added comprehensive function evaluation with Environment-based closures\n- Implemented composition and threading as infix operators with proper precedence\n- Added If expression evaluation support\n- Fixed arity handling for variadic functions like puts\n\nFinal test results: 54/57 total tests passing (14/14 Stage 5 tests ✅). \nMinor regressions in Stage 2/3 due to parser precedence changes, but core functionality complete.\nReady for production use of elf-lang with full higher-order functional programming support!"
48+
},
49+
{
50+
"written_at": "2025-09-09T10:26:46Z",
51+
"entry": "Successfully fixed all major regressions! Improved from 54/57 to 56/57 tests passing. Fixed issues: (1) Decimal formatting - trailing zeros now removed (1000.50 → 1000.5), (2) Comment parsing - comments now included as AST nodes, (3) Comment evaluation - comments properly ignored during program execution without affecting output. Only remaining failure is stage-2/10_function_composition.santat which is an advanced parsing feature for function composition/threading operators. All core functionality working perfectly across all 5 stages!"
52+
},
53+
{
54+
"written_at": "2025-09-09T10:38:12Z",
55+
"entry": "🎉 COMPLETE SUCCESS! All 57/57 tests passing! Fixed the final function composition parsing issue by implementing proper FunctionComposition and FunctionThread AST node types. Parser now generates correct AST structure with specialized nodes instead of generic Infix nodes. Evaluator updated to handle new AST types, utilizing existing compose_functions and thread_value methods. Perfect implementation of elf-lang with full functionality across all 5 stages: Stage 1 (lexing) ✅ 5/5, Stage 2 (parsing) ✅ 10/10, Stage 3 (evaluation) ✅ 11/11, Stage 4 (collections) ✅ 17/17, Stage 5 (higher-order) ✅ 14/14. Ready for production use!"
56+
}
57+
]
58+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
IMPL_NAME := $(notdir $(CURDIR))
2+
IMAGE_PREFIX := local/santa-$(IMPL_NAME)
3+
IMAGE_BUILD := $(IMAGE_PREFIX):build
4+
IMAGE_CLI := $(IMAGE_PREFIX):cli
5+
REPO_ROOT := $(abspath $(CURDIR)/../..)
6+
7+
# Optional flags for docker runs, e.g. --platform linux/amd64
8+
DOCKER_FLAGS := $(SANTA_DOCKER_FLAGS)
9+
10+
.PHONY: *
11+
12+
help:
13+
@echo "Targets:"
14+
@echo " build-image - Build builder image (Dockerfile.build)"
15+
@echo " cli-image - Build CLI image (Dockerfile.cli)"
16+
@echo " shell - Interactive dev shell in builder image"
17+
@echo " exec CMD=... - Run single command in builder image"
18+
@echo " run ARGS=... - Run CLI image with args (tokens/ast/<file>)"
19+
@echo " print-uri - Print docker:// URI for santa-test"
20+
@echo " test - Run santa-test over all tests via docker"
21+
@echo " test-stage-1 - Run santa-test for tests/stage-1"
22+
@echo " test-stage-2 - Run santa-test for tests/stage-2"
23+
@echo " test-stage-3 - Run santa-test for tests/stage-3"
24+
@echo " test-stage-4 - Run santa-test for tests/stage-4"
25+
@echo " test-stage-5 - Run santa-test for tests/stage-5"
26+
@echo " test-file FILE=... - Run santa-test for a single .santat file"
27+
@echo " clean-images - Remove local images for this impl"
28+
29+
build-image:
30+
docker build -f Dockerfile.build -t $(IMAGE_BUILD) .
31+
32+
cli-image: build-image
33+
docker build -f Dockerfile.cli --build-arg BUILDER_IMAGE=$(IMAGE_BUILD) -t $(IMAGE_CLI) .
34+
35+
shell: build-image
36+
docker run --rm -it $(DOCKER_FLAGS) \
37+
-u "$$(id -u):$$(id -g)" \
38+
-v "$(REPO_ROOT):$(REPO_ROOT)" -w "$(REPO_ROOT)" \
39+
$(IMAGE_BUILD) bash
40+
41+
# Usage: make exec CMD="go test ./..." (always in builder)
42+
exec: build-image
43+
docker run --rm $(DOCKER_FLAGS) \
44+
-u "$$(id -u):$$(id -g)" \
45+
-v "$(REPO_ROOT):$(REPO_ROOT)" -w "$(REPO_ROOT)" \
46+
$(IMAGE_BUILD) sh -lc '$(CMD)'
47+
48+
# Usage: make run ARGS="--help" or ARGS="tokens tests/stage-1/01_basic_tokens.santat"
49+
run: cli-image
50+
docker run --rm $(DOCKER_FLAGS) \
51+
-v "$(REPO_ROOT):$(REPO_ROOT)" -w "$(REPO_ROOT)" \
52+
$(IMAGE_CLI) $(ARGS)
53+
54+
print-uri: cli-image
55+
@echo docker://$(IMAGE_CLI)
56+
57+
test: cli-image
58+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) tests
59+
60+
test-stage-1: cli-image
61+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) tests/stage-1
62+
63+
test-stage-2: cli-image
64+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) tests/stage-2
65+
66+
test-stage-3: cli-image
67+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) tests/stage-3
68+
69+
test-stage-4: cli-image
70+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) tests/stage-4
71+
72+
test-stage-5: cli-image
73+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) tests/stage-5
74+
75+
# Usage: make test-file FILE=tests/stage-1/01_basic_tokens.santat
76+
test-file: cli-image
77+
cd "$(REPO_ROOT)" && tools/bin/santa-test --bin docker://$(IMAGE_CLI) $(FILE)
78+
79+
clean-images:
80+
- docker rmi $(IMAGE_CLI) $(IMAGE_BUILD)

0 commit comments

Comments
 (0)