51 lines
875 B
Go

package zig
// https://github.com/ziglang/zig-spec/blob/master/grammar/grammar.peg
type Root struct {
ContainerDocComment string // //! Doc Comment
ContainerMembers []*ContainerMember
}
type ContainerMember struct {
// FIXME
Decls []Decl
}
type Decl interface{}
type FnDecl struct {
Name string
Params []*ParamDecl
CallConv string
ReturnType TypeExpr
Body *Block // nil means semicolon
}
type ParamDecl struct {
DocComment string // ??? It's what it says
Name string // Can be empty
Type TypeExpr // anytype when empty
}
type Block struct {
Label string
Stmts []Stmt
}
type Stmt interface{}
type ReturnStmt struct{}
type Expr interface{}
// This will need to become a real type expr someday
type TypeExpr string
func (t TypeExpr) String() string {
if string(t) == "" {
return "anytype"
}
return string(t)
}