encoding

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayNode

type ArrayNode struct {
	Nodebase
	Elements []Node
}

func (ArrayNode) Type

func (n ArrayNode) Type() NodeType

type Comment

type Comment struct {
	Slash scanner.Position
	Text  string
}

func (*Comment) Pos

func (c *Comment) Pos() scanner.Position

type CommentGroup

type CommentGroup struct {
	List []*Comment
}

func (*CommentGroup) Pos

func (g *CommentGroup) Pos() scanner.Position

func (*CommentGroup) Text

func (g *CommentGroup) Text() string

type IdentNode

type IdentNode struct {
	Nodebase
	Name string
}

func NewIdentNode

func NewIdentNode(pos scanner.Position, name string) *IdentNode

func (IdentNode) Type

func (n IdentNode) Type() NodeType

type KVPairNode

type KVPairNode struct {
	K, V Node
}

func NewKVPairNode

func NewKVPairNode(k, v Node) *KVPairNode

func (KVPairNode) Pos

func (n KVPairNode) Pos() scanner.Position

func (KVPairNode) Type

func (n KVPairNode) Type() NodeType

type LiteralNode

type LiteralNode struct {
	Nodebase

	Value string
	// contains filtered or unexported fields
}

func NewLiteralNode

func NewLiteralNode(pos scanner.Position, nodeType NodeType) *LiteralNode

func (LiteralNode) Type

func (n LiteralNode) Type() NodeType

type Node

type Node interface {
	// Pos returns position of node
	Pos() scanner.Position
	// Type returns type of node
	Type() NodeType
}

type NodeType

type NodeType int

NodeType represents type of node

const (
	Invalid NodeType = iota
	Ident            // abc,true,false
	Int              // 1
	Float            // 1.2
	Char             // 'c'
	String           // "xyz"
	Object           // {}
	Array            // []
	KVPair           // e.g. x=y, x: y
)

func (NodeType) String

func (t NodeType) String() string

type Nodebase

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

func CreateNodebase

func CreateNodebase(pos scanner.Position) Nodebase

func (Nodebase) Pos

func (n Nodebase) Pos() scanner.Position

type ObjectNode

type ObjectNode struct {
	Nodebase
	Elements []KVPairNode
}

func (ObjectNode) Type

func (n ObjectNode) Type() NodeType

type Parser

type Parser struct {
	Pos scanner.Position
	Tok rune
	Lit string

	Comments    []*CommentGroup
	LeadComment *CommentGroup
	LineComment *CommentGroup
	// contains filtered or unexported fields
}

func (*Parser) BeginPos

func (p *Parser) BeginPos() scanner.Position

func (*Parser) Err

func (p *Parser) Err() error

func (*Parser) Expect

func (p *Parser) Expect(tokens ...rune) error

func (*Parser) ExpectError

func (p *Parser) ExpectError(tokens ...rune) error

func (*Parser) ExpectValue

func (p *Parser) ExpectValue(s string) error

func (*Parser) Init

func (p *Parser) Init(s *scanner.Scanner)

func (*Parser) Next

func (p *Parser) Next() error

func (*Parser) StringLit

func (p *Parser) StringLit() (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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