Add comprehensive Zig syntax test coverage

- Add support for error sets and error union types
- Implement for loops with index and payload syntax
- Add defer, break, continue, and switch statements
- Support unary expressions and array indexing
- Add unreachable expression and test declarations
- Extend AST with new type expressions (array, error union)
- Update formatter to handle all new syntax elements
- Fix formatting for switch prongs, payloads, and blocks
This commit is contained in:
2025-06-05 20:44:49 -05:00
parent 50b38254ab
commit 258b3c8e9b
4 changed files with 529 additions and 7 deletions

View File

@@ -408,6 +408,23 @@ type PrefixTypeExpr struct {
Base TypeExpr
}
// ArrayTypeExpr represents an array type ([N]T).
type ArrayTypeExpr struct {
Size Expr
Elem TypeExpr
}
// SliceTypeExpr represents a slice type ([]T).
type SliceTypeExpr struct {
Elem TypeExpr
}
// ErrorUnionTypeExpr represents an error union type (E!T).
type ErrorUnionTypeExpr struct {
ErrSet TypeExpr
Type TypeExpr
}
// DocComment represents a doc comment (/// or //! lines).
// Newlines in the string automatically add more comments in the output.
type DocComment string