Commit Graph

58 Commits

Author SHA1 Message Date
83c463f6a7 parser: port test "sentinel-terminated slice type"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:10 +00:00
592638502a parser: port test "c pointer type"
Implement [*], [*c], and [*:s] pointer type parsing in parseTypeExpr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:09 +00:00
74d6a66a2d parser: port test "nosuspend block"
Implement nosuspend statement in expectStatement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:09 +00:00
2279ac85a0 parser: port test "errdefer with payload"
Implement in parser.c:
- defer and errdefer statements with expectBlockExprStatement
- parseAssignExpr for assignment expressions (expr op= expr)
- expectBlockExprStatement: block or assign expr + semicolon
- assignOpTag: map all assignment operator tokens to AST tags

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:08 +00:00
cd5ebdb904 parser: port test "top-level bare asterisk+asterisk+identifier"
Implement ** (double pointer) type parsing in parseTypeExpr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:08 +00:00
fcfa3f3b4a parser: port test "top-level bare asterisk+identifier"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:08 +00:00
6743d5dd2f parser: port test "top-level tuple function call type"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:07 +00:00
bfc5846c4d parser: add multiline string, fn call, struct, if-else tests
Port tests from upstream parser_test.zig:
- "multiline string with backslash at end of line"
- "multiline string parameter in fn call with trailing comma"
- "trailing comma on fn call"
- "multi line arguments without last comma"
- "empty block with only comment"
- "trailing commas on struct decl"
- "extra newlines at the end"
- "nested struct literal with one item"
- "if-else with comment before else"

Fix parseSuffixExpr: continue suffix loop after call parsing
instead of returning, enabling method chains like a.b().c().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:07 +00:00
bf632b9d6b parser: add if expression and statement tests
Port tests from upstream parser_test.zig:
- "if statement"
- "respect line breaks in if-else"
- "if nested"
- "remove empty lines at start/end of block"

Implement in parser.c:
- parseIfExpr: if/else expression parsing with payloads
- parsePtrPayload, parsePayload: |value| and |*value| handling
- Handle block-terminated expressions without semicolons in
  expectVarDeclExprStatement

Fix zigData in parser_test.zig:
- if, while, while_cont use node_and_extra (not node_and_node)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:07 +00:00
9f77f5a234 parser: add infix, fn trailing comma, enum, struct literal tests
Port tests from upstream parser_test.zig:
- "respect line breaks after infix operators"
- "fn decl with trailing comma"
- "enum decl with no trailing comma"
- "struct literal no trailing comma"
- "2nd arg multiline string"
- "final arg multiline string"
- "function call with multiline argument"

No new parser.c changes needed — all features already implemented.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:06 +00:00
c67c54c3fb parser: add zig fmt on/off and slice operator tests
Port tests from upstream parser_test.zig:
- "comment to disable/enable zig fmt"
- "line comment following 'zig fmt: off'"
- "doc comment following 'zig fmt: off'"
- "alternating 'zig fmt: off' and 'zig fmt: on'"
- "spaces around slice operator"

Fix parsePrimaryTypeExpr: don't reject identifier followed by colon;
the colon may be part of slice sentinel syntax, not a label.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:06 +00:00
1a8bb5ac10 parser: add fn params, return, call args, enum literal tests
Port tests from upstream parser_test.zig:
- "trailing comma in fn parameter list" (all combinations)
- "enum literal inside array literal"
- "builtin call with trailing comma"

Implement in parser.c:
- parseParamDeclList: full parameter parsing with names, comptime,
  noalias, doc comments, varargs
- parseFnProto: fn_proto_multi, fn_proto_one, fn_proto with
  align/addrspace/section/callconv
- parseSuffixExpr: function call with arguments
- parsePrimaryExpr: return, comptime, nosuspend, resume expressions
- parseAddrSpace, parseLinkSection, parseCallconv: full parsing
- Use OPT() macro for OptionalIndex encoding in extra data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:05 +00:00
cb4be73acb parser: add enum, union, literal, struct doc comment tests
Port tests from upstream parser_test.zig:
- "empty enum decls" (with extern/packed modifiers)
- "empty union decls" (with extern/packed/enum modifiers)
- "enum literal"
- "character literal larger than u8"
- "infix operator and then multiline string literal" (2 tests)
- "correctly space struct fields with doc comments"
- "aligned struct field"
- "comment to disable/enable zig fmt first"

Implement in parser.c:
- extern/packed modifiers before struct/union/enum in
  parsePrimaryTypeExpr

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:05 +00:00
b2b1d8f188 parser: add slicing and tagged union tests
Port tests from upstream parser_test.zig:
- "slices" (open, closed, sentinel-terminated)
- "tagged union with enum values"
- "tagged union enum tag last token"

Implement in parser.c:
- Slice expressions in parseSuffixOp: slice_open, slice,
  slice_sentinel
- Handle OptionalIndex encoding for absent slice end expr

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:05 +00:00
8705fd0197 parser: add struct/array literal tests (2/3 element variants)
Port tests from upstream parser_test.zig:
- "struct literal 2/3 element" (with and without comma)
- "anon list literal 1/2/3 element" (with and without comma)
- "array literal 0/1/2/3 element" (with and without comma)

All 17 new tests pass without parser changes — the init list
implementation from the previous commit handles all cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:04 +00:00
cd93f7cffd parser: add struct/array init literal tests
Port tests from upstream parser_test.zig:
- "anon struct literal 0/1/2/3 element" (with and without comma)
- "struct literal 0/1 element"

Implement in parser.c:
- parseFieldInit: parse .field = expr field initializers
- parseInitList: full struct/array init list parsing
- parseCurlySuffixExpr: use parseInitList for X{...} syntax
- parsePrimaryTypeExpr: handle .{...} anonymous init and .ident
  enum literals
- Empty X{} produces struct_init_one (matching upstream behavior)

Fix zigData in parser_test.zig:
- array_init_one uses node_and_node (not node_and_opt_node)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:04 +00:00
a61bf83a11 parser: add block, break, grouped expression, array type tests
Port tests from upstream parser_test.zig:
- "allow empty line before comment at start of block"
- "comptime struct field"
- "break from block"
- "grouped expressions (parentheses)"
- "array types last token"

Fix bugs in parser.c:
- parseBreakLabel: use null_token instead of null_node
- test decl: use null_token for unnamed tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:04 +00:00
b186471328 parser: add container declaration and test decl tests
Port tests from upstream parser_test.zig:
- "container declaration, one item, multi line trailing comma"
- "container declaration, no trailing comma on separate line"
- "container declaration, line break, no trailing comma"
- "container declaration, transform trailing comma"
- "container declaration, comment, add trailing comma"
- "container declaration, multiline string, add trailing comma"
- "container declaration, doc comment on member, add trailing comma"
- "remove empty lines at start/end of container decl"

Implement in parser.c:
- Test declarations in parseContainerMembers
- Comptime block/var statements in expectStatement
- Variable declaration with initializer in expectVarDeclExprStatement
- Regular assignment expressions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:03 +00:00
8d193346e8 parser: add multiline string, empty file, field, container tests
Port tests from upstream parser_test.zig:
- "multiline string mixed with comments"
- "empty file"
- "file ends in comment"
- "file ends in multi line comment"
- "file ends in comment after var decl"
- "top-level fields"
- "container declaration, single line"

Implement in parser.c:
- parseSuffixOp: array access, field access, deref, unwrap optional
- Slice/array type parsing in parseTypeExpr
- Multiline string literal parsing

Fix zigData mapping in parser_test.zig:
- optional_type uses .node (not .opt_node)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:03 +00:00
298b347cf7 parser: add function, comptime, var declaration tests
Port tests from upstream parser_test.zig:
- "respect line breaks before functions"
- "simple top level comptime block"
- "two spaced line comments before decl"
- "respect line breaks after var declarations"

Implement in parser.c:
- parseSuffixOp: array access (a[i]), field access (a.b),
  deref (a.*), unwrap optional (a.?)
- Multiline string literal parsing
- Slice types ([]T, [:s]T) and array types ([N]T, [N:s]T)
- Fix comptime block main_token in parseContainerMembers

Fix zigData mapping in parser_test.zig:
- field_access, unwrap_optional use node_and_token (not node_and_node)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:03 +00:00
0433771b3e parser: add struct field value declaration test
Port "zig fmt: respect line breaks in struct field value declaration"
test from upstream parser_test.zig.

Implement in parser.c:
- Slice types ([]T, [:s]T) in parseTypeExpr
- Array types ([N]T, [N:s]T) in parseTypeExpr
- Multiline string literals in parsePrimaryTypeExpr
- Add comments explaining why const/volatile/allowzero pointer
  modifiers are consumed (not stored in AST; renderer re-derives
  them from token positions)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:03 +00:00
1bb921b8ca parser: add tuple struct test and container decl support
Port "zig fmt: tuple struct" test from upstream parser_test.zig.

Implement in parser.c:
- parseContainerDeclAuto: struct/enum/union/opaque declarations
- parseGlobalVarDecl: const/var with initializer
- parseByteAlign: align(expr) parsing
- parseTypeExpr: pointer types (*T), optional types (?T)
- parsePrimaryTypeExpr: number_literal, char_literal,
  unreachable_literal, fn proto, grouped expressions,
  container decl, comptime prefix
- expectContainerField: default values (= expr)
- parseContainerMembers: comptime block/field handling
- Fix parseFnProto: use null_token instead of null_node

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-11 14:40:02 +00:00
745b38fde2 zig build does more and in parallel 2026-02-11 14:40:02 +00:00
3750469dca update license 2026-02-11 14:40:02 +00:00
cb8d46b1ab fix tcc 2026-02-10 11:35:41 +00:00
00db079347 zig build -Dcc=tcc 2026-02-10 10:47:27 +00:00
f08f4404ed zig build lint fmt 2026-02-10 10:36:40 +00:00
2948cfd7cf zig 0.15.1
With opus 4.6
2026-02-10 10:03:44 +00:00
8b9a22907e add some notes 2025-07-01 19:48:18 +00:00
a1655ccbd1 fmt 2025-04-24 20:32:51 +00:00
36e8746365 fix listToSpan 2025-04-24 20:31:11 +00:00
c0ec218e42 trying to fix infinite loop 2025-04-24 22:27:56 +03:00
a799d4a3cb fix assertion failure 2025-04-24 22:27:50 +03:00
45449b9c04 add license 2025-04-20 23:32:30 +03:00
d22667f79a bump to zig 0.14 2025-04-13 22:20:02 +03:00
15abfb585f more parser 2025-02-05 16:29:10 +00:00
5c65136bf5 more parser 2025-01-09 07:27:39 +01:00
aa0fab43e4 fmt 2025-01-08 19:04:40 +01:00
a987479617 beginning of parseVarDeclProto 2025-01-08 18:35:04 +01:00
2a56ea9be2 No types, no fucking types. Just bugs 2025-01-07 22:22:05 +01:00
1f134595de start with parser tests 2025-01-04 22:47:51 +01:00
49c910b8b2 fix memleak; initialization boilerplate 2025-01-02 17:17:22 +02:00
85dfbe9d09 more parser 2025-01-01 17:26:58 +02:00
3264d1747e replace TOKENIZER_TAG_ with TOKEN_ 2024-12-30 22:38:26 +02:00
d551ba3d12 a few bugfixes and a new TODO 2024-12-30 22:36:35 +02:00
2ae1ac885b fix filename 2024-12-30 01:33:34 +02:00
b8a52d3f39 More parser — lint+tests pass again 2024-12-30 01:30:48 +02:00
6006a802e1 making tcc happier 2024-12-29 00:13:54 +02:00
6ae7d7320d adding more parser — starts breaking the build 2024-12-26 00:35:13 +02:00
ef3ef64abd more macros 2024-12-23 21:56:56 +02:00