ast

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assignment

type Assignment struct {
	Left   string `@Ident`
	Equals string `@"="`
	Expr   *Expr  `@@`
	Semi   string `@";"`
}

Assignment is an assignment statement.

type BlockStmt

type BlockStmt struct {
	Stmts []*Stmt `"{" @@* "}"`
}

BlockStmt is a block of statements enclosed in braces.

type Declaration

type Declaration struct {
	UniformDecl  *UniformDecl  `@@`
	FunctionDecl *FunctionDecl `| @@`
}

Declaration is a top-level declaration.

type Expr

type Expr struct {
	FuncCall *FuncCall `@@`
}

Expr is an expression.

type File

type File struct {
	Pos          lexer.Position
	Declarations []*Declaration `@@*`
}

File is the root of a parsed .gdshader file.

func Parse

func Parse(filename string, reader io.Reader) (*File, error)

Parse parses a .gdshader file into a tree of AST nodes.

type FuncCall

type FuncCall struct {
	FuncName string   `@Ident`
	LParen   string   `@"("`
	Args     []string `@Ident ("," @Ident)*`
	RParen   string   `@")"`
}

FuncCall is a function call exporession.

type FunctionDecl

type FunctionDecl struct {
	ReturnType string     `@Ident`
	Name       string     `@Ident "(" ")"`
	Body       *BlockStmt `@@`
}

FunctionDecl is a function declaration.

type Stmt

type Stmt struct {
	Assignment *Assignment `@@`
}

Stmt is a code statement.

type UniformDecl

type UniformDecl struct {
	Type string `"uniform" @Ident`
	Name string `@Ident ";"`
}

UniformDecl is a uniform variable declaration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL