ast

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayLiteral added in v0.0.2

type ArrayLiteral struct {
	Token    token.Token
	Elements []Expression
}

func (*ArrayLiteral) Line added in v0.0.2

func (al *ArrayLiteral) Line() uint

func (*ArrayLiteral) String added in v0.0.2

func (al *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral added in v0.0.2

func (al *ArrayLiteral) TokenLiteral() string

type AssignStatement added in v0.0.2

type AssignStatement struct {
	Token token.Token // The 'var' or identifier token
	Name  *Identifier
	Value Expression
}

func (*AssignStatement) Line added in v0.0.2

func (as *AssignStatement) Line() uint

func (*AssignStatement) String added in v0.0.2

func (as *AssignStatement) String() string

func (*AssignStatement) TokenLiteral added in v0.0.2

func (as *AssignStatement) TokenLiteral() string

type BlockStatement added in v0.0.2

type BlockStatement struct {
	Token      token.Token
	Statements []Statement
}

func (*BlockStatement) Line added in v0.0.2

func (bs *BlockStatement) Line() uint

func (*BlockStatement) String added in v0.0.2

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral added in v0.0.2

func (bs *BlockStatement) TokenLiteral() string

type BooleanLiteral

type BooleanLiteral struct {
	Token token.Token // The 'true' or 'false' token
	Value bool
}

func (*BooleanLiteral) Line added in v0.0.2

func (bl *BooleanLiteral) Line() uint

func (*BooleanLiteral) String

func (bl *BooleanLiteral) String() string

func (*BooleanLiteral) TokenLiteral

func (bl *BooleanLiteral) TokenLiteral() string

type CallExpression added in v0.0.2

type CallExpression struct {
	Token     token.Token // Function identifier token
	Receiver  Expression  // Receiver of the call
	Function  *Identifier // Function being called
	Arguments []Expression
}

func (*CallExpression) Line added in v0.0.2

func (ce *CallExpression) Line() uint

func (*CallExpression) String added in v0.0.2

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral added in v0.0.2

func (ce *CallExpression) TokenLiteral() string

type EachStatement added in v0.0.2

type EachStatement struct {
	Token token.Token // The '@for' token
	Var   *Identifier // The variable name
	Array Expression  // The array to loop over
	Block *BlockStatement
}

func (*EachStatement) Line added in v0.0.2

func (es *EachStatement) Line() uint

func (*EachStatement) String added in v0.0.2

func (es *EachStatement) String() string

func (*EachStatement) TokenLiteral added in v0.0.2

func (es *EachStatement) TokenLiteral() string

type ElseIfStatement added in v0.0.2

type ElseIfStatement struct {
	Token       token.Token
	Condition   Expression
	Consequence *BlockStatement
}

func (*ElseIfStatement) Line added in v0.0.2

func (eis *ElseIfStatement) Line() uint

func (*ElseIfStatement) String added in v0.0.2

func (eis *ElseIfStatement) String() string

func (*ElseIfStatement) TokenLiteral added in v0.0.2

func (eis *ElseIfStatement) TokenLiteral() string

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token
	Expression Expression
}

func (*ExpressionStatement) Line added in v0.0.2

func (es *ExpressionStatement) Line() uint

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type FloatLiteral added in v0.0.2

type FloatLiteral struct {
	Token token.Token
	Value float64
}

func (*FloatLiteral) Line added in v0.0.2

func (fl *FloatLiteral) Line() uint

func (*FloatLiteral) String added in v0.0.2

func (fl *FloatLiteral) String() string

func (*FloatLiteral) TokenLiteral added in v0.0.2

func (fl *FloatLiteral) TokenLiteral() string

type ForStatement added in v0.0.2

type ForStatement struct {
	Token     token.Token // The '@for' token
	Init      Statement   // The initialization statement; or nil
	Condition Expression  // The condition expression; or nil
	Post      Statement   // The post iteration statement; or nil
	Block     *BlockStatement
}

func (*ForStatement) Line added in v0.0.2

func (fs *ForStatement) Line() uint

func (*ForStatement) String added in v0.0.2

func (fs *ForStatement) String() string

func (*ForStatement) TokenLiteral added in v0.0.2

func (fs *ForStatement) TokenLiteral() string

type HTMLStatement

type HTMLStatement struct {
	Token token.Token
}

func (*HTMLStatement) Line added in v0.0.2

func (hs *HTMLStatement) Line() uint

func (*HTMLStatement) String

func (hs *HTMLStatement) String() string

func (*HTMLStatement) TokenLiteral

func (hs *HTMLStatement) TokenLiteral() string

type Identifier

type Identifier struct {
	Token token.Token
	Value string
}

func (*Identifier) Line added in v0.0.2

func (i *Identifier) Line() uint

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IfStatement added in v0.0.2

type IfStatement struct {
	Token        token.Token        // The '@if' token
	Condition    Expression         // The truthy condition
	Consequence  *BlockStatement    // The 'then' block
	Alternative  *BlockStatement    // The 'else' block
	Alternatives []*ElseIfStatement // The 'elseif' blocks
}

func (*IfStatement) Line added in v0.0.2

func (is *IfStatement) Line() uint

func (*IfStatement) String added in v0.0.2

func (is *IfStatement) String() string

func (*IfStatement) TokenLiteral added in v0.0.2

func (is *IfStatement) TokenLiteral() string

type IndexExpression added in v0.0.2

type IndexExpression struct {
	Token token.Token // The '[' token
	Left  Expression
	Index Expression
}

func (*IndexExpression) Line added in v0.0.2

func (ie *IndexExpression) Line() uint

func (*IndexExpression) String added in v0.0.2

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral added in v0.0.2

func (ie *IndexExpression) TokenLiteral() string

type InfixExpression added in v0.0.2

type InfixExpression struct {
	Token    token.Token // The operator token, e.g. +
	Operator string      // The operator, e.g. +
	Left     Expression
	Right    Expression
}

func (*InfixExpression) Line added in v0.0.2

func (ie *InfixExpression) Line() uint

func (*InfixExpression) String added in v0.0.2

func (ie *InfixExpression) String() string

func (*InfixExpression) TokenLiteral added in v0.0.2

func (ie *InfixExpression) TokenLiteral() string

type InsertStatement added in v0.0.2

type InsertStatement struct {
	Token    token.Token     // The '@insert' token
	Name     *StringLiteral  // The name of the insert statement
	Argument Expression      // The argument to the insert statement; nil if has block
	Block    *BlockStatement // The block of the insert statement; nil if has argument
}

func (*InsertStatement) Line added in v0.0.2

func (is *InsertStatement) Line() uint

func (*InsertStatement) String added in v0.0.2

func (is *InsertStatement) String() string

func (*InsertStatement) TokenLiteral added in v0.0.2

func (is *InsertStatement) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token
	Value int64
}

func (*IntegerLiteral) Line added in v0.0.2

func (il *IntegerLiteral) Line() uint

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

type NilLiteral

type NilLiteral struct {
	Token token.Token // The 'nil' token
}

func (*NilLiteral) Line added in v0.0.2

func (nl *NilLiteral) Line() uint

func (*NilLiteral) String

func (nl *NilLiteral) String() string

func (*NilLiteral) TokenLiteral

func (nl *NilLiteral) TokenLiteral() string

type Node

type Node interface {
	TokenLiteral() string
	String() string
	Line() uint
}

type PostfixExpression added in v0.0.2

type PostfixExpression struct {
	Token    token.Token // The '++' or '--' token
	Operator string
	Left     Expression
}

func (*PostfixExpression) Line added in v0.0.2

func (pe *PostfixExpression) Line() uint

func (*PostfixExpression) String added in v0.0.2

func (pe *PostfixExpression) String() string

func (*PostfixExpression) TokenLiteral added in v0.0.2

func (pe *PostfixExpression) TokenLiteral() string

type PrefixExpression added in v0.0.2

type PrefixExpression struct {
	Token    token.Token // The '!' or '-' token
	Operator string
	Right    Expression
}

func (*PrefixExpression) Line added in v0.0.2

func (pe *PrefixExpression) Line() uint

func (*PrefixExpression) String added in v0.0.2

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral added in v0.0.2

func (pe *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Token      token.Token // The 'program' token
	Statements []Statement
	IsLayout   bool
}

func (*Program) ApplyInserts added in v0.0.2

func (p *Program) ApplyInserts(inserts map[string]*InsertStatement, absPath string) *fail.Error

func (*Program) ApplyLayout added in v0.0.2

func (p *Program) ApplyLayout(layoutProg *Program) error

Remove all the statements except the first one, which is the layout statement When we use layout, we do not print the file itself

func (*Program) HasReserveStmt added in v0.0.2

func (p *Program) HasReserveStmt() bool

func (*Program) HasUseStmt added in v0.0.2

func (p *Program) HasUseStmt() (bool, *UseStatement)

func (*Program) Inserts added in v0.0.2

func (p *Program) Inserts() map[string]*InsertStatement

func (*Program) Line added in v0.0.2

func (p *Program) Line() uint

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type ReserveStatement added in v0.0.2

type ReserveStatement struct {
	Token  token.Token      // The '@reserve' token
	Insert *InsertStatement // The insert statement; nil if not yet parsed
	Name   *StringLiteral
}

func (*ReserveStatement) Line added in v0.0.2

func (rs *ReserveStatement) Line() uint

func (*ReserveStatement) String added in v0.0.2

func (rs *ReserveStatement) String() string

func (*ReserveStatement) TokenLiteral added in v0.0.2

func (rs *ReserveStatement) TokenLiteral() string

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

type StringLiteral

type StringLiteral struct {
	Token token.Token // The content of the string
	Value string
}

func (*StringLiteral) Line added in v0.0.2

func (sl *StringLiteral) Line() uint

func (*StringLiteral) String

func (sl *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

type TernaryExpression added in v0.0.2

type TernaryExpression struct {
	Token       token.Token // The '?' token
	Condition   Expression
	Consequence Expression
	Alternative Expression
}

func (*TernaryExpression) Line added in v0.0.2

func (te *TernaryExpression) Line() uint

func (*TernaryExpression) String added in v0.0.2

func (te *TernaryExpression) String() string

func (*TernaryExpression) TokenLiteral added in v0.0.2

func (te *TernaryExpression) TokenLiteral() string

type UseStatement added in v0.0.2

type UseStatement struct {
	Token   token.Token    // The '@use' token
	Name    *StringLiteral // The relative path to the layout like 'layouts/main'
	Program *Program
}

func (*UseStatement) Line added in v0.0.2

func (us *UseStatement) Line() uint

func (*UseStatement) String added in v0.0.2

func (us *UseStatement) String() string

func (*UseStatement) TokenLiteral added in v0.0.2

func (us *UseStatement) TokenLiteral() string

Jump to

Keyboard shortcuts

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