compiler

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildrenCommandNode

type ChildrenCommandNode struct {
	// contains filtered or unexported fields
}

func NewChildrenCommandNode

func NewChildrenCommandNode(t token) *ChildrenCommandNode

func (*ChildrenCommandNode) AddChild

func (n *ChildrenCommandNode) AddChild(c nodeBase)

func (*ChildrenCommandNode) Children

func (n *ChildrenCommandNode) Children() []nodeBase

func (*ChildrenCommandNode) Indent

func (n *ChildrenCommandNode) Indent() int

func (*ChildrenCommandNode) Origin

func (n *ChildrenCommandNode) Origin() token

func (*ChildrenCommandNode) SetNextSibling

func (n *ChildrenCommandNode) SetNextSibling(sibling nodeBase)

func (*ChildrenCommandNode) Source

func (n *ChildrenCommandNode) Source(tw *templateWriter) error

func (*ChildrenCommandNode) Tree

func (n *ChildrenCommandNode) Tree(buf *bytes.Buffer, indent int) string

func (*ChildrenCommandNode) Type

func (n *ChildrenCommandNode) Type() nodeType

type CodeNode

type CodeNode struct {
	// contains filtered or unexported fields
}

func NewCodeNode

func NewCodeNode(t token) *CodeNode

func (*CodeNode) AddChild

func (n *CodeNode) AddChild(c nodeBase)

func (*CodeNode) Children

func (n *CodeNode) Children() []nodeBase

func (*CodeNode) Indent

func (n *CodeNode) Indent() int

func (*CodeNode) Origin

func (n *CodeNode) Origin() token

func (*CodeNode) SetNextSibling

func (n *CodeNode) SetNextSibling(sibling nodeBase)

func (*CodeNode) Source

func (n *CodeNode) Source(tw *templateWriter) error

func (*CodeNode) Tree

func (n *CodeNode) Tree(buf *bytes.Buffer, indent int) string

func (*CodeNode) Type

func (n *CodeNode) Type() nodeType

type CommentNode

type CommentNode struct {
	// contains filtered or unexported fields
}

func NewCommentNode

func NewCommentNode(t token, indent int) *CommentNode

func (*CommentNode) AddChild

func (n *CommentNode) AddChild(c nodeBase)

func (*CommentNode) Children

func (n *CommentNode) Children() []nodeBase

func (*CommentNode) Indent

func (n *CommentNode) Indent() int

func (*CommentNode) Origin

func (n *CommentNode) Origin() token

func (*CommentNode) SetNextSibling

func (n *CommentNode) SetNextSibling(sibling nodeBase)

func (*CommentNode) Source

func (n *CommentNode) Source(tw *templateWriter) error

func (*CommentNode) Tree

func (n *CommentNode) Tree(buf *bytes.Buffer, indent int) string

func (*CommentNode) Type

func (n *CommentNode) Type() nodeType

type CssFilterNode

type CssFilterNode struct {
	// contains filtered or unexported fields
}

func NewCssFilterNode

func NewCssFilterNode(t token, indent int) *CssFilterNode

func (*CssFilterNode) AddChild

func (n *CssFilterNode) AddChild(c nodeBase)

func (*CssFilterNode) Children

func (n *CssFilterNode) Children() []nodeBase

func (*CssFilterNode) Indent

func (n *CssFilterNode) Indent() int

func (*CssFilterNode) Origin

func (n *CssFilterNode) Origin() token

func (*CssFilterNode) SetNextSibling

func (n *CssFilterNode) SetNextSibling(sibling nodeBase)

func (*CssFilterNode) Source

func (n *CssFilterNode) Source(tw *templateWriter) error

func (*CssFilterNode) Tree

func (n *CssFilterNode) Tree(buf *bytes.Buffer, indent int) string

func (*CssFilterNode) Type

func (n *CssFilterNode) Type() nodeType

type DoctypeNode

type DoctypeNode struct {
	// contains filtered or unexported fields
}

func NewDoctypeNode

func NewDoctypeNode(t token) *DoctypeNode

func (*DoctypeNode) AddChild

func (n *DoctypeNode) AddChild(c nodeBase)

func (*DoctypeNode) Children

func (n *DoctypeNode) Children() []nodeBase

func (*DoctypeNode) Indent

func (n *DoctypeNode) Indent() int

func (*DoctypeNode) Origin

func (n *DoctypeNode) Origin() token

func (*DoctypeNode) SetNextSibling

func (n *DoctypeNode) SetNextSibling(sibling nodeBase)

func (*DoctypeNode) Source

func (n *DoctypeNode) Source(tw *templateWriter) error

func (*DoctypeNode) Tree

func (n *DoctypeNode) Tree(buf *bytes.Buffer, indent int) string

func (*DoctypeNode) Type

func (n *DoctypeNode) Type() nodeType

type ElementNode

type ElementNode struct {
	// contains filtered or unexported fields
}

func NewElementNode

func NewElementNode(t token, indent int) *ElementNode

func (*ElementNode) AddChild

func (n *ElementNode) AddChild(c nodeBase)

func (*ElementNode) Children

func (n *ElementNode) Children() []nodeBase

func (*ElementNode) Indent

func (n *ElementNode) Indent() int

func (*ElementNode) Origin

func (n *ElementNode) Origin() token

func (*ElementNode) SetNextSibling

func (n *ElementNode) SetNextSibling(sibling nodeBase)

func (*ElementNode) Source

func (n *ElementNode) Source(tw *templateWriter) error

func (*ElementNode) Tree

func (n *ElementNode) Tree(buf *bytes.Buffer, indent int) string

func (*ElementNode) Type

func (n *ElementNode) Type() nodeType

type GohtNode

type GohtNode struct {
	// contains filtered or unexported fields
}

func NewGohtNode

func NewGohtNode(t token) *GohtNode

func (*GohtNode) AddChild

func (n *GohtNode) AddChild(c nodeBase)

func (*GohtNode) Children

func (n *GohtNode) Children() []nodeBase

func (*GohtNode) Indent

func (n *GohtNode) Indent() int

func (*GohtNode) Origin

func (n *GohtNode) Origin() token

func (*GohtNode) SetNextSibling

func (n *GohtNode) SetNextSibling(sibling nodeBase)

func (*GohtNode) Source

func (n *GohtNode) Source(tw *templateWriter) error

func (*GohtNode) Tree

func (n *GohtNode) Tree(buf *bytes.Buffer, indent int) string

func (*GohtNode) Type

func (n *GohtNode) Type() nodeType

type JavaScriptFilterNode

type JavaScriptFilterNode struct {
	// contains filtered or unexported fields
}

func NewJavaScriptFilterNode

func NewJavaScriptFilterNode(t token, indent int) *JavaScriptFilterNode

func (*JavaScriptFilterNode) AddChild

func (n *JavaScriptFilterNode) AddChild(c nodeBase)

func (*JavaScriptFilterNode) Children

func (n *JavaScriptFilterNode) Children() []nodeBase

func (*JavaScriptFilterNode) Indent

func (n *JavaScriptFilterNode) Indent() int

func (*JavaScriptFilterNode) Origin

func (n *JavaScriptFilterNode) Origin() token

func (*JavaScriptFilterNode) SetNextSibling

func (n *JavaScriptFilterNode) SetNextSibling(sibling nodeBase)

func (*JavaScriptFilterNode) Source

func (n *JavaScriptFilterNode) Source(tw *templateWriter) error

func (*JavaScriptFilterNode) Tree

func (n *JavaScriptFilterNode) Tree(buf *bytes.Buffer, indent int) string

func (*JavaScriptFilterNode) Type

func (n *JavaScriptFilterNode) Type() nodeType

type NewLineNode

type NewLineNode struct {
	// contains filtered or unexported fields
}

func NewNewLineNode

func NewNewLineNode(t token) *NewLineNode

func (*NewLineNode) AddChild

func (n *NewLineNode) AddChild(c nodeBase)

func (*NewLineNode) Children

func (n *NewLineNode) Children() []nodeBase

func (*NewLineNode) Indent

func (n *NewLineNode) Indent() int

func (*NewLineNode) Origin

func (n *NewLineNode) Origin() token

func (*NewLineNode) SetNextSibling

func (n *NewLineNode) SetNextSibling(sibling nodeBase)

func (*NewLineNode) Source

func (n *NewLineNode) Source(tw *templateWriter) error

func (*NewLineNode) Tree

func (n *NewLineNode) Tree(buf *bytes.Buffer, indent int) string

func (*NewLineNode) Type

func (n *NewLineNode) Type() nodeType

type OrderedMap

type OrderedMap[T any] struct {
	// contains filtered or unexported fields
}

func NewOrderedMap

func NewOrderedMap[T any]() *OrderedMap[T]

func (*OrderedMap[T]) Delete

func (m *OrderedMap[T]) Delete(key string)

func (*OrderedMap[T]) Get

func (m *OrderedMap[T]) Get(key string) (value T, ok bool)

func (*OrderedMap[T]) Len

func (m *OrderedMap[T]) Len() int

func (*OrderedMap[T]) Range

func (m *OrderedMap[T]) Range(f func(key string, value T) (bool, error)) error

func (*OrderedMap[T]) Set

func (m *OrderedMap[T]) Set(key string, value T)

type Position

type Position struct {
	Line int
	Col  int
}

type PositionalError

type PositionalError struct {
	Line   int
	Column int
	Err    error
}

func (PositionalError) Error

func (e PositionalError) Error() string

func (PositionalError) Position

func (e PositionalError) Position() string

func (PositionalError) Unwrap

func (e PositionalError) Unwrap() error

type Range

type Range struct {
	From Position
	To   Position
}

type RenderCommandNode

type RenderCommandNode struct {
	// contains filtered or unexported fields
}

func NewRenderCommandNode

func NewRenderCommandNode(t token, indent int) *RenderCommandNode

func (*RenderCommandNode) AddChild

func (n *RenderCommandNode) AddChild(c nodeBase)

func (*RenderCommandNode) Children

func (n *RenderCommandNode) Children() []nodeBase

func (*RenderCommandNode) Indent

func (n *RenderCommandNode) Indent() int

func (*RenderCommandNode) Origin

func (n *RenderCommandNode) Origin() token

func (*RenderCommandNode) SetNextSibling

func (n *RenderCommandNode) SetNextSibling(sibling nodeBase)

func (*RenderCommandNode) Source

func (n *RenderCommandNode) Source(tw *templateWriter) error

func (*RenderCommandNode) Tree

func (n *RenderCommandNode) Tree(buf *bytes.Buffer, indent int) string

func (*RenderCommandNode) Type

func (n *RenderCommandNode) Type() nodeType

type RootNode

type RootNode struct {
	// contains filtered or unexported fields
}

func NewRootNode

func NewRootNode() *RootNode

func (*RootNode) AddChild

func (n *RootNode) AddChild(c nodeBase)

func (*RootNode) Children

func (n *RootNode) Children() []nodeBase

func (*RootNode) Indent

func (n *RootNode) Indent() int

func (*RootNode) Origin

func (n *RootNode) Origin() token

func (*RootNode) SetNextSibling

func (n *RootNode) SetNextSibling(sibling nodeBase)

func (*RootNode) Source

func (n *RootNode) Source(tw *templateWriter) error

func (*RootNode) Tree

func (n *RootNode) Tree(buf *bytes.Buffer, indent int) string

func (*RootNode) Type

func (n *RootNode) Type() nodeType

type ScriptNode

type ScriptNode struct {
	// contains filtered or unexported fields
}

func NewScriptNode

func NewScriptNode(t token) *ScriptNode

func (*ScriptNode) AddChild

func (n *ScriptNode) AddChild(c nodeBase)

func (*ScriptNode) Children

func (n *ScriptNode) Children() []nodeBase

func (*ScriptNode) Indent

func (n *ScriptNode) Indent() int

func (*ScriptNode) Origin

func (n *ScriptNode) Origin() token

func (*ScriptNode) SetNextSibling

func (n *ScriptNode) SetNextSibling(sibling nodeBase)

func (*ScriptNode) Source

func (n *ScriptNode) Source(tw *templateWriter) error

func (*ScriptNode) Tree

func (n *ScriptNode) Tree(buf *bytes.Buffer, indent int) string

func (*ScriptNode) Type

func (n *ScriptNode) Type() nodeType

type SilentScriptNode

type SilentScriptNode struct {
	// contains filtered or unexported fields
}

func NewSilentScriptNode

func NewSilentScriptNode(t token, indent int) *SilentScriptNode

func (*SilentScriptNode) AddChild

func (n *SilentScriptNode) AddChild(c nodeBase)

func (*SilentScriptNode) Children

func (n *SilentScriptNode) Children() []nodeBase

func (*SilentScriptNode) Indent

func (n *SilentScriptNode) Indent() int

func (*SilentScriptNode) Origin

func (n *SilentScriptNode) Origin() token

func (*SilentScriptNode) SetNextSibling

func (n *SilentScriptNode) SetNextSibling(sibling nodeBase)

func (*SilentScriptNode) Source

func (n *SilentScriptNode) Source(tw *templateWriter) error

func (*SilentScriptNode) Tree

func (n *SilentScriptNode) Tree(buf *bytes.Buffer, indent int) string

func (*SilentScriptNode) Type

func (n *SilentScriptNode) Type() nodeType

type SourceMap

type SourceMap struct {
	SourceLinesToTarget map[int]map[int]Position
	TargetLinesToSource map[int]map[int]Position
}

func (*SourceMap) Add

func (sm *SourceMap) Add(t token, destRange Range)

Add will create a new source map entry from the Goht template to the generated Go code.

The IDEs will be using zero-based line and column numbers, so we need to convert them from the one-based line and column numbers that we've generated during the parsing of the Goht template.

When we parse the length of a line we will create mappings for the entire len() because the IDEs and LSPs will use the character AFTER the last character in the range as the end position. For example, "foo" will have a start column of 0 and an end column value of 3, not 2.

func (*SourceMap) SourcePositionFromTarget

func (sm *SourceMap) SourcePositionFromTarget(line, col int) (Position, bool)

func (*SourceMap) TargetPositionFromSource

func (sm *SourceMap) TargetPositionFromSource(line, col int) (Position, bool)

type Template

type Template struct {
	Filename string
	Root     nodeBase
}

func ParseFile

func ParseFile(fileName string) (*Template, error)

func ParseString

func ParseString(contents string) (*Template, error)

func (*Template) Compose

func (t *Template) Compose(w io.Writer) (*SourceMap, error)

func (*Template) Generate

func (t *Template) Generate(w io.Writer) error

type TextFilterNode

type TextFilterNode struct {
	// contains filtered or unexported fields
}

func NewTextFilterNode

func NewTextFilterNode(t token, indent int) *TextFilterNode

func (*TextFilterNode) AddChild

func (n *TextFilterNode) AddChild(c nodeBase)

func (*TextFilterNode) Children

func (n *TextFilterNode) Children() []nodeBase

func (*TextFilterNode) Indent

func (n *TextFilterNode) Indent() int

func (*TextFilterNode) Origin

func (n *TextFilterNode) Origin() token

func (*TextFilterNode) SetNextSibling

func (n *TextFilterNode) SetNextSibling(sibling nodeBase)

func (*TextFilterNode) Source

func (n *TextFilterNode) Source(tw *templateWriter) error

func (*TextFilterNode) Tree

func (n *TextFilterNode) Tree(buf *bytes.Buffer, indent int) string

func (*TextFilterNode) Type

func (n *TextFilterNode) Type() nodeType

type TextNode

type TextNode struct {
	// contains filtered or unexported fields
}

func NewTextNode

func NewTextNode(t token) *TextNode

func (*TextNode) AddChild

func (n *TextNode) AddChild(c nodeBase)

func (*TextNode) Children

func (n *TextNode) Children() []nodeBase

func (*TextNode) Indent

func (n *TextNode) Indent() int

func (*TextNode) Origin

func (n *TextNode) Origin() token

func (*TextNode) SetNextSibling

func (n *TextNode) SetNextSibling(sibling nodeBase)

func (*TextNode) Source

func (n *TextNode) Source(tw *templateWriter) error

func (*TextNode) Tree

func (n *TextNode) Tree(buf *bytes.Buffer, indent int) string

func (*TextNode) Type

func (n *TextNode) Type() nodeType

type UnescapeNode

type UnescapeNode struct {
	// contains filtered or unexported fields
}

func NewUnescapeNode

func NewUnescapeNode(t token, indent int) *UnescapeNode

func (*UnescapeNode) AddChild

func (n *UnescapeNode) AddChild(c nodeBase)

func (*UnescapeNode) Children

func (n *UnescapeNode) Children() []nodeBase

func (*UnescapeNode) Indent

func (n *UnescapeNode) Indent() int

func (*UnescapeNode) Origin

func (n *UnescapeNode) Origin() token

func (*UnescapeNode) SetNextSibling

func (n *UnescapeNode) SetNextSibling(sibling nodeBase)

func (*UnescapeNode) Source

func (n *UnescapeNode) Source(tw *templateWriter) error

func (*UnescapeNode) Tree

func (n *UnescapeNode) Tree(buf *bytes.Buffer, indent int) string

func (*UnescapeNode) Type

func (n *UnescapeNode) Type() nodeType

Jump to

Keyboard shortcuts

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