You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parser (AST): Recursive-descent parser builds a complete AST supporting all Phase 1, Phase 2, and Phase 3 syntax constructs. See CLAUDE.md for full list.
Codegen (LLVM 18+, conditional): When built with llvm-18-dev, CodeGen class generates LLVM IR for: functions, extern declarations, variables, control flow (if/else, while, for-in, break/continue), expressions (arithmetic, comparison, logical, bitwise with type coercion), strings (safe BlangString type with interpolation and methods), arrays (safe BlangArray with bounds checking), structs (literal construction, field access, method calls), enums (tagged union layout with match/destructure), generics (monomorphization), Result/Option ? operator (tag check, payload extraction, early error return), pipeline operator, ownership (move semantics, use-after-move detection), ARC for shared/sync, spawn (closure extraction, thread pool dispatch), async/await, channels, contracts (requires/ensures), test blocks, assert, @json annotation codegen, database query/insert/update/delete codegen, and multi-module type sharing.
Tests: 143 tests in run_tests.sh — 99 pass, 40 fail (negative), 4 cgfail. 36 end-to-end codegen tests via test_codegen.sh. GitHub Actions CI configured.
The foundation: transition from C-style syntax to BLang syntax, complete the type system, and get the core language compiling end-to-end.
1.1 Syntax Transition: fn keyword and -> return types
#
Task
Type
Done
Description
1
Add fn keyword to lexer
impl
YES
Add fn as a recognized keyword token in FileLexer.cpp
2
Parse fn function declarations
impl
YES
Update FunctionDefinition::Parse to accept fn name(type arg, ...) -> type { } syntax
3
Support omitted return type as void
impl
YES
fn greet(string name) { } — no -> means void return
4
Update all pass test files to fn syntax
test
YES
All pass tests use fn-style syntax; C-style is now rejected
5
Update all fail test files
test
YES
All fail tests updated to .b extension and fn syntax
6
Add fail test: old C-style syntax rejected
test
YES
c_style_func.b — C-style function declarations correctly rejected
7
Update codegen for new function syntax
impl
YES
CodeGen::genFunction works with both AST shapes
8
Document fn syntax in CLAUDE.md
docs
YES
Documented in CLAUDE.md supported features
1.2 Fix Remaining Parser Issues
#
Task
Type
Done
Description
9
Move xfail tests that now pass to pass/
test
YES
Moved arithmetic_stmt.c, assignment_stmt.c, binary_expr_return.c, comparison_expr.c to pass/
10
Support extern without named params
impl
YES
extern int printf(string, ...); works with synthetic _arg0 names
11
Move extern_func_call.b to pass/ once fixed
test
YES
Added extern fn printf declaration; moved from xfail/ to pass/
12
Add const keyword to lexer
impl
YES
const recognized as keyword token
13
Implement const variable declarations
impl
YES
const float PI = 3.14; parsed, must have initializer
14
Add pass tests for const
test
YES
const_decl.c, const_no_init.c (fail test)
15
Add var keyword for type inference
impl
YES
var x = 42; parsed with type inferred from initializer
16
Add pass/fail tests for var
test
YES
var_infer.c, var_no_init.c (fail test)
1.3 Struct Types and impl Blocks
#
Task
Type
Done
Description
17
Add struct keyword to lexer
impl
YES
struct is a recognized keyword token
18
Create StructDefinition AST node
impl
YES
StructDefinition in Type.h with fields, methods, generic params
19
Parse struct definitions
impl
YES
QStructDefinition.cpp — struct Point { int x; int y; }
20
Add struct type to type system
impl
YES
Structs registered as types in scope via addType()
21
Parse struct literal construction
impl
YES
Point { x: 1, y: 2 } syntax in QExpression.cpp
22
Parse field access expressions
impl
YES
point.x — FieldAccessExpression AST node
23
Add impl keyword to lexer
impl
YES
impl is a recognized keyword token
24
Parse impl blocks
impl
YES
QImplBlock.cpp — impl Protocol for Struct { ... }
25
Add self keyword
impl
YES
Lexer + parser support for self in method params
26
Codegen for struct types
impl
YES
LLVM struct type mapping (getOrCreateStructType), field access (genFieldAccess), struct literal (genStructLiteral), generic struct instantiation
27
Codegen for method calls
impl
YES
Method dispatch (genMethodCall), impl block methods emitted as StructName_methodName, self passed as first arg; builtin string/array methods also supported
ParseImplBlock verifies all required protocol methods are implemented
35
Compile error for missing protocol methods
impl
YES
Compile error: "Struct 'X' does not implement method 'Y' required by protocol 'Z'"
36
Add pass tests for protocols
test
YES
protocol_basic.c, impl_protocol.c
37
Add fail tests for protocols
test
YES
protocol_no_fn.c
38
Document protocol system
docs
YES
Documented in CLAUDE.md
1.5 Generics
#
Task
Type
Done
Description
39
Parse <T> type parameters on functions
impl
YES
fn first<T>(List<T> list) -> Option<T>
40
Parse <T> type parameters on structs
impl
YES
struct List<T> { ... } with GenericParam
41
Parse protocol constraints <T: Comparable>
impl
YES
Constraint syntax on functions, structs, protocols, enums
42
Implement generic type instantiation
impl
YES
Monomorphization via instantiateGenericStruct() — stamps out concrete types like Box_int; cached in mGenericInstanceMap
43
Codegen for generic functions
impl
YES
Monomorphization via instantiateGenericFunction() — stamps out concrete functions; explicit type args required (no inference); generic methods/protocols not yet supported
Registered in gScope (EnumDefinition::CreateBuiltinResult) and mEnumDefMap; type-erased 8-byte payload, concrete T/E recovered at match/? from the subject's type args; user-defined Result still shadows it. Tested in codegen_builtin_result.b, codegen_builtin_try.b
48
Implement Option<T> as built-in generic type
impl
YES
Registered in gScope (EnumDefinition::CreateBuiltinOption) and mEnumDefMap; channel recv() now returns this same built-in Option<T>. Tested in codegen_builtin_option.b, cgfail/builtin_option_non_exhaustive.b
QUESTION_MARK token in lexer; TryExpression AST node; postfix parsing in ParsePrimary
52
Codegen for Result/Option
impl
YES
Enum tagged union layout {i32 tag, [N x i8] payload} via genEnumConstruct; tested in codegen_result_type.b and codegen_enum_payload.b
53
Codegen for match
impl
YES
genMatchExpression — tag extraction, switch dispatch, variant pattern matching with payload extraction and binding, wildcard arms, and enum exhaustiveness checking (missing variant without _ is a compile error; tested in cgfail/match_non_exhaustive.b, codegen_match_exhaustive.b, codegen_match_wildcard_enum.b)
54
Codegen for ? operator
impl
YES
genTryExpression — resolves operand's enum type, extracts tag, branches on success (ok/some) vs error (err/none), unwraps payload on success, propagates error via early return on failure; tested in codegen_try_operator.b
registerExternalTypes() shares struct/enum type definitions across CodeGen instances; type-level cross-module support works, function-level symbol linking pending
chan<T> variable declarations parsed and codegen'd via __blang_chan_create
92
Parse channel operations
impl
YES
chan<T> type parsed (QType.cpp); .send()/.recv()/.close() parse as method calls; tested in pass/chan_send_recv.b
93
Implement BLang runtime: green thread scheduler
impl
YES
Thread pool with __blang_spawn, __blang_spawn_wait, __blang_wait_all in blang_runtime.c
94
Implement BLang runtime: channel implementation
impl
YES
__blang_chan_create/__blang_chan_send/__blang_chan_recv/__blang_chan_close/__blang_chan_destroy in blang_runtime.c
95
Codegen for spawn
impl
YES
Closure extraction: captured variables packed into context struct, dispatched to thread pool; tested in codegen_spawn.b, codegen_spawn_threaded.b, codegen_shared_spawn.b
96
Codegen for channel operations
impl
YES
genChanMethodCall emits __blang_chan_send/__blang_chan_recv/__blang_chan_close; recv() returns Option<T> (synthesized Option_<T> enum; some on success, none on closed+empty) so the closed signal is surfaced and exhaustive match enforces handling; tested in codegen_channel.b, codegen_channel_spawn.b, codegen_channel_closed.b, cgfail/chan_recv_non_exhaustive.b
97
Enforce thread safety rules
impl
YES
Own variables cannot be captured across spawn boundaries (compile error); shared/sync enforced via ARC and locking
async fn declarations set mIsAsync flag on FunctionDefinition
104
Parse await expressions
impl
YES
await expr parsed into AwaitExpression AST node
105
Implement BLang runtime: event loop
impl
YES
__blang_async_call/__blang_await/__blang_task_destroy in blang_runtime.c
106
Codegen for async functions
impl
YES
Async body extracted to void*(void*) wrapper, called via __blang_async_call; tested in codegen_async.b, codegen_async_multi.b
107
Codegen for await
impl
YES
__blang_await + __blang_task_destroy; tested in codegen_wait.b, codegen_wait_all.b
108
Add on keyword for event handlers
impl
YES
on timer.every(1000) { ... }
109
Parse event handler syntax
impl
YES
on expr { body } parsed into EventHandler AST node
110
Codegen for event handlers
impl
YES
on EXPR { body } extracts the body to a callback and registers it on the global event loop via __blang_event_on keyed by the fd that EXPR yields (timerfd or socket fd); refcounted captures are retained for deferred invocation. A non-fd event expr falls back to inline invocation (legacy). Runtime: poll-based loop with timerfds (timer.every/after, timer.run/stop); tested in codegen_timer_event.b
table struct User { int id; string name; } with setIsTable(true)
141
Implement schema metadata storage
impl
YES
SchemaMigration engine stores and diffs schema snapshots
142
Add query keyword to lexer
impl
YES
query keyword token
143
Add insert keyword to lexer
impl
YES
insert keyword token
144
Add update keyword to lexer
impl
YES
update keyword token
145
Add delete keyword to lexer
impl
YES
delete keyword token
146
Parse `query T
> where { }
> order_by { }
> limit()`
147
Parse insert T { field: value }
impl
YES
InsertExpression AST node
148
Parse `update T
> where { }
> set { }`
impl
149
Parse `delete T
> where { }`
impl
YES
150
Compile-time field validation
impl
YES
Query/update/delete field refs and insert field names validated against the table struct (validateQueryFields/validateInsertFields); unknown field is a compile error. Test: cgfail/query_bad_field.b. (JOIN field refs validated against primary table only.)
151
SQL generation backend
impl
YES
SQLGen translates query AST to parameterized SQL (SELECT/INSERT/UPDATE/DELETE, CREATE TABLE)
152
Implement database runtime library
impl
YES
blang_db library with connection, query, result APIs; optional SQLite backend
153
Support @db("name") annotation for named connections
impl
YES
[database.<name>] parsed and registered via __blang_db_register; query codegen routes through __blang_db_get("name") when the table struct carries @db("name"), else the default connection
test_files/codegen_db_query.b — insert/update/delete/select with bound WHERE/SET params against in-memory SQLite (run via test_codegen.sh, gated on SQLite)
157
Document query system
docs
YES
Documented in CLAUDE.md
3.3 Automatic Migrations
#
Task
Type
Done
Description
158
Implement schema snapshot storage
impl
YES
SchemaMigration persists schema state in .blang/ directory
159
Implement schema diff engine
impl
YES
Compares current table structs against stored snapshot
HttpServer.get/post/put/route(method, path, handler) build an Array<Route> route table; dispatch_request matches method+path → handler, else 404. (delete is a keyword — use route("DELETE", ...).) Tested in codegen_http_routing.b
188
Implement automatic JSON serialization for responses
impl
YES
Builtin to_json(value) dispatches at compile time to StructName_to_json for a @json struct (compile error otherwise); net.http_json(to_json(user)) returns an application/json response with the serialized struct. Tested in codegen_to_json_builtin.b, codegen_http_json_response.b, cgfail/to_json_not_annotated.b
189
Implement http.Client for outgoing requests
impl
YES
http_get(host, port, path) and http_post(host, port, path, content_type, body) — BLang-native Buffer I/O, return the response body
190
Add pass tests for HTTP server
test
YES
codegen_http_routing.b (route dispatch + get/post registration); codegen_http_blang.b (parsing/response building). Live socket serving verified manually (deterministic socket+thread E2E omitted from the suite)
191
Document HTTP library
docs
YES
Documented in CLAUDE.md; demo demos/13_http_server.b uses the routing API
3.7 GraphQL Standard Library
#
Task
Type
Done
Description
192
Implement @graphql annotation
impl
—
Generate GraphQL schema from struct
193
Implement graphql.Server in standard library
impl
—
GraphQL endpoint with query execution
194
Implement auto-resolver generation from table structs
impl
—
CRUD resolvers derived from query expressions
195
Implement custom resolver override
impl
—
User-defined resolvers replace generated ones
196
Add pass tests for GraphQL
test
—
Schema generation, query execution, mutations
197
Document GraphQL library
docs
—
Update CLAUDE.md
3.8 Database Configuration and Tooling
#
Task
Type
Done
Description
198
Implement blang.toml project configuration
impl
YES
ProjectConfig class parses blang.toml for project metadata, type (bin/lib), and dependencies
199
Implement Postgres driver in stdlib
impl
PARTIAL
libpq backend implemented (pg_open/pg_query/pg_exec with ?→$n rewrite), compile-guarded behind BLANG_HAS_POSTGRES; not yet exercised in CI (requires libpq-dev)
200
Implement SQLite driver in stdlib
impl
YES
SQLite backend with runtime parameter binding behind a driver-dispatch layer; tested via codegen_db_query.b + test_migrate.sh
201
Implement connection pooling
impl
—
Deferred; process uses a single shared default/named connection (sufficient for SQLite/single-threaded). Pooling for file/Postgres connections is future
202
Add database integration tests
test
YES
test_migrate.sh (migrate → apply against SQLite) + codegen_db_query.b (insert/update/delete/query roundtrip with bound params)
203
Document database configuration
docs
YES
CLAUDE.md: [database]/[database.<name>] blang.toml format, BLANG_DATABASE_URL fallback, migrate workflow, driver status
Cross-Cutting Concerns
These tasks span multiple phases and should be addressed incrementally.
Documentation
#
Task
Type
Done
Description
204
Keep CLAUDE.md in sync with implementation
docs
YES
CLAUDE.md is comprehensive and current
205
Keep language_design.md implementation status current
docs
PARTIAL
CLAUDE.md is more current; language_design.md needs update
206
Add examples/ directory
docs
YES
demos/ directory with example programs
207
Write tutorial: "Your first BLang program"
docs
—
208
Write tutorial: "BLang for Rust developers"
docs
—
Testing Infrastructure
#
Task
Type
Done
Description
209
Add --verbose output to run_tests.sh showing compiler stderr
test
YES
--verbose flag shows stderr on failure
210
Add codegen-specific tests (require LLVM)
test
YES
test_codegen.sh with 36 E2E tests; cgfail/ category in run_tests.sh
211
Add end-to-end execution tests
test
YES
test_codegen.sh runs full pipeline (parse → IR → compile → link → run) and checks exit codes
212
Add regression test for each bug fix
test
—
No systematic regression test policy
213
Implement test timeout handling
test
YES
timeout 10 in run_tests.sh
Build and CI
#
Task
Type
Done
Description
214
Add GitHub Actions CI workflow
infra
YES
.github/workflows/ci.yml — builds with and without LLVM, runs tests on push/PR
215
Add install_deps.sh to CI
infra
YES
install_deps.sh — cross-platform dependency installer with --with-llvm option
216
Add build matrix: Linux + macOS
infra
PARTIAL
CI matrix includes parse-only and with-llvm; macOS support in install_deps.sh
217
Add blang wrapper script or rename qcc
impl
PARTIAL
User-facing binary is bcc (BLang Compiler CLI); no blang alias yet
Phase 4 — Build System and Dependencies
4.1 AST Prerequisites for .bmod Emission
#
Task
Type
Done
Description
218
Add isPublic to EnumDefinition
impl
YES
mIsPublic flag and isPublic() getter, isPublic param on Parse()
219
Add isPublic to ProtocolDefinition
impl
YES
mIsPublic flag and isPublic() getter, isPublic param on Parse()
220
Pass isPublic from Module::Parse
impl
YES
pub enum and pub protocol now correctly set visibility
221
Add mProtocolList to Module
impl
YES
Protocols stored on Module; getProtocolList() getter added
Safety and concurrency: ownership, spawn/chan, async/await, contracts, testing
50
1
0
6
Phase 3
134–203
Data and services: pipeline, queries, migrations, serialization, gRPC, HTTP, GraphQL
51
2
0
17
Phase 4
218–250
Build system: .bmod, blang.toml, deps, cache
33
0
0
0
Cross-cutting
204–217
Documentation, test infrastructure, CI
9
3
0
2
Total
250
218
6
1
25
Phase 1 Complete
All Phase 1 tasks are done or explicitly deferred:
Task 47/48 (built-in Result/Option): Done — Option<T> and Result<T,E> are registered as built-in generic enums (no user definition required). They use a type-erased pointer-sized payload; the concrete type argument is recovered at the match/? site from the subject's static type. A user-defined Option/Result shadows the built-in (user defs land in a child scope).
Task 63 (visibility checking): Deferred — requires cross-module name resolution which depends on multi-module function linking (not just type sharing).
Phase 4 Complete
All Phase 4 tasks are done:
blang.toml project manifest with [project] (name, version, type) and [deps] (local path dependencies)
.bmod interface files emitted via qcc --emit-bmod and consumed via two-phase parsing with flat symbol merge
bcc build recursively builds dependency graph, produces .a+.bmod for libraries and executables for binaries
bcc clean removes the build cache
Content-addressable cache at ~/.cache/blang/objects/<hash>/ skips rebuilding unchanged dependencies
Integration test in test_build/ verifies the full lib→bin build flow