Coding
PromptBeginner5 minmarkdown
Markdown Converter
Agent skill for markdown-converter
23
This file is for agentic coding assistants working in this repo.
Sign in to like and favorite skills
This file is for agentic coding assistants working in this repo. Keep it practical, follow existing patterns, and update docs when behavior changes.
dep/; use cmach dep ... in a consuming project.doc/* as the source of truth for language/tooling behavior.doc/* pages and keep examples compiling.boot/, run clang-format when available.boot/ -> builds out/bin/cmach (~27k lines, C23, full feature set).src/ -> builds out/bin/imach (~68 .mach files, ~60-70% feature parity).https://github.com/octalide/mach-std) and cannot be edited here.mach.toml (targets, source paths, output paths).make cmach (clean + build)make cmach-build (build only)out/bin/cmachmake imach or make imach-build (uses cmach)make mach or make mach-build (uses imach)make test (builds cmach, then runs ./out/bin/cmach test)cmach test . (run all tests in repo)cmach test --filter "lexer" . (filters by module path or test name)cmach test --filter "edge case" .cmach test --target linux . (target selection from mach.toml)-m or --modules shows module-level progress-v or --verbose shows all test results (not just failures)cmach init my-app - create new project with scaffoldingcmach build . or cmach build . --target <name>cmach build . -o out/bin/myapp - specify outputcmach build myfile.mach -I std=/path/to/mach-std/src - module prefix mapping (C only)cmach run . - build and execute with argument forwardingcmach dep add <url> --version branch/main - add remote dependencycmach dep add --local /path/to/lib <name> - add local dependencycmach dep pull - update dependenciescmach dep list - show current depscmach dep del <name> - remove dependencycmach dep tidy - clean orphaned submodulescmach, imach, and mach are intended to be interchangeable for MVP.cmach for bootstrap reliability, but keep commands compatible.-I flag not supported (blocks single-file with imports)--verbose and --modules flags missingThe compiler uses a two-layer backend called MASM:
boot/src/compiler/masm/ir.c (C), src/compiler/masm/ir.mach (Mach)boot/src/compiler/masm/isa/x86_64/isel.c, src/compiler/masm/isel.machboot/src/compiler/masm/isa/x86_64/encode.cboot/src/compiler/masm/lower.c, src/compiler/masm/lower.machfin)boot/)clang.lowercase_with_underscoresPascalCaseUPPER_SNAKE_CASE when needed.dnit or explicit teardown paths.parser_error).clang-format when editing boot/ (if available).src/)use statements by domain (std, project, compiler subsystems).use print: std.print;.lowercase_with_underscores.PascalCase.src/.val for immutable bindings, var for mutable.Result/Option before use; handle is_err()/is_some().std.print helpers.ret consistently; avoid falling through when clarity matters.cnt/brk for loop control.# summary and description # --- # param: description # ret: description of return value
.mach files using test "name" { ... }.cmach test scans dir_src from mach.toml, builds each test as a separate executable, and runs them in isolated processes.--filter matches both module path and test name substrings.-m or --modules shows module-level progress during execution.out/<target>/tests/... and cleaned per run.$main.symbol = "main"; and a C-like fun main(argc: i64, argv: &&u8) i64 signature.use imports modules; use aligned aliases for readability (e.g. use print: std.print;).val is immutable, var is mutable; prefer explicit types in public APIs.ret, cnt, and brk instead of fallthrough.?expr (address-of) and @expr (dereference).value::Type); avoid implicit conversions.nil (not null or NULL).ret 1 if omitted).# commentuse [alias:] project.module; - import with optional aliaspub - export symbolext "C:name" - external/FFI bindingdef Name: Type; - type aliasrec Name { field: Type; } - record (struct)uni Name[T] { variant: Type; } - tagged union (optionally generic)val name: Type = value; - immutable bindingvar name: Type = value; - mutable bindingfun name(params) RetType { body } - functionfun (self: *Type) method() { } - method with receiverif (cond) { } or { } - conditional with elsefor (cond) { } or for { } - loop (no C-style for)fin stmt; - deferred execution (defer)asm { ... } - inline assemblyType[T], fun[T](arg: T) T*T (mutable), &T (immutable/ref)[N]Tdep/ directly.cmach dep ... to add/update dependencies in consuming projects.branch/<name>, commit/<hash>, ^1.2.3, ~1.2.3, 1.2.3cmach dep add --local /ABS/PATH/TO/mach-std mach-std # test changes... cmach dep del mach-std # revert before commit
mach-std/ repository directly rather than the vendored copy under dep/mach-std/.doc/* is the source of truth for language/tooling behavior.doc/* when behavior changes (syntax, flags, outputs, semantics).CHANGELOG.md for user-visible changes (new features, fixes, breaking changes) between releases.CHANGELOG.md should match mach.toml version.doc/README.md (language reference index)doc/testing.md (test runner, filtering, output semantics)doc/cheatsheet.md (syntax and toolchain commands)doc/getting-started.md (build setup and prerequisites)cmach (C bootstrap) → imach (Mach compiled by C) → mach (Mach compiled by Mach) ↓ works ↓ works ↓ CRASHES (SIGILL)
The final
mach binary crashes with "Illegal instruction" - malformed machine code.
00 00 00 00) where instructions should beParser stores data in these fields - mismatches cause silent bugs:
| Node Type | | | |
|---|---|---|---|
| VAR/VAL decl | name (str) | type node | initializer |
| CALL expr | arguments (*List) | type args | callee |
| FIELD access | field name (str) | - | base expr |
src/compiler/masm/isa/x86_64/encode.mach - instruction encodingsrc/compiler/masm/isel.mach - instruction selectionsrc/compiler/masm/of/elf.mach - ELF outputsrc/compiler/masm/lower.mach - IR lowering# Compare working (imach) vs broken (mach) objdump -d ./out/bin/imach > /tmp/imach.asm objdump -d ./out/linux/bin/mach > /tmp/mach.asm diff /tmp/imach.asm /tmp/mach.asm | head -200