kdlgo

package module
v0.0.0-...-099938a Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 8 Imported by: 1

README

kdlgo

Go parser for the KDL Document Language.

Go Reference

To reach 1.0 parity

  • Parse from file

  • Parse from string

  • String

  • Raw String

  • Boolean

  • Null

  • Array Value

  • Nested child object

  • Inline ; node

  • "slashdash" comment /-

  • Multi-line node \

  • Line comment //

  • Block comment /**/

  • Quoted node

  • Inline = node

  • Type Annotations (Currently this will probably either get parsed as part of the node or cause an error.)

    • Ignored
    • signed int
    • unsigned int
    • float
    • decimal
  • Pass the tests (I'm going through them in alphabetical order. If its not listed and its before the listed ones, its passing. If its after the listed ones, I've not looked into it.)

    • empty_child_whitespace
    • empty_quoted_node_id

Documentation

Index

Constants

View Source
const (
	KDLEmptyArray      = "Array is empty"
	KDLDifferentKey    = "All keys of KDLObject to convert to document should be the same"
	KDLInvalidKeyChar  = "Invalid character for key"
	KDLInvalidNumValue = "Invalid numeric value"
	KDLInvalidSyntax   = "Invalid syntax"
	KDLInvalidType     = "Invalid KDLType"
	KDLUnexpectedEOF   = "Unexpected end of file"
)
View Source
const (
	KDLBoolType      = "kdl_bool"
	KDLNumberType    = "kdl_number"
	KDLStringType    = "kdl_string"
	KDLRawStringType = "kdl_raw_string"
	KDLDocumentType  = "kdl_document"
	KDLNullType      = "kdl_null"
	KDLDefaultType   = "kdl_default"
	KDLObjectsType   = "kdl_objects"
)

Variables

This section is empty.

Functions

func RecreateKDLObj

func RecreateKDLObj(kdlObj KDLObject) (string, error)

func RecreateString

func RecreateString(s string) string

Types

type KDLBool

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

func NewKDLBool

func NewKDLBool(key string, value bool) KDLBool

func (KDLBool) GetKey

func (kdlNode KDLBool) GetKey() string

func (KDLBool) GetValue

func (kdlNode KDLBool) GetValue() KDLValue

type KDLDefault

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

func NewKDLDefault

func NewKDLDefault(key string) KDLDefault

func (KDLDefault) GetKey

func (kdlNode KDLDefault) GetKey() string

func (KDLDefault) GetValue

func (kdlNode KDLDefault) GetValue() KDLValue

type KDLDocument

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

func ConvertToDocument

func ConvertToDocument(objs []KDLObject) (KDLDocument, error)

func NewKDLDocument

func NewKDLDocument(key string, value []KDLValue) KDLDocument

func (KDLDocument) GetKey

func (kdlNode KDLDocument) GetKey() string

func (KDLDocument) GetValue

func (kdlNode KDLDocument) GetValue() KDLValue

type KDLErrorType

type KDLErrorType string

type KDLNode

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

type KDLNull

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

func NewKDLNull

func NewKDLNull(key string) KDLNull

func (KDLNull) GetKey

func (kdlNode KDLNull) GetKey() string

func (KDLNull) GetValue

func (kdlNode KDLNull) GetValue() KDLValue

type KDLNumber

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

func NewKDLNumber

func NewKDLNumber(key string, value float64) KDLNumber

func (KDLNumber) GetKey

func (kdlNode KDLNumber) GetKey() string

func (KDLNumber) GetValue

func (kdlNode KDLNumber) GetValue() KDLValue

type KDLObject

type KDLObject interface {
	GetKey() string
	GetValue() KDLValue
}

type KDLObjects

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

func NewKDLObjects

func NewKDLObjects(key string, objects []KDLObject) KDLObjects

func ParseFile

func ParseFile(fullfilepath string) (KDLObjects, error)

func ParseReader

func ParseReader(reader *bufio.Reader) (KDLObjects, error)

func ParseString

func ParseString(toParse string) (KDLObjects, error)

func (KDLObjects) GetKey

func (kdlNode KDLObjects) GetKey() string

func (KDLObjects) GetValue

func (kdlNode KDLObjects) GetValue() KDLValue

func (KDLObjects) ToObjMap

func (kdlObjs KDLObjects) ToObjMap() KDLObjectsMap

func (KDLObjects) ToValueMap

func (kdlObjs KDLObjects) ToValueMap() KDLValuesMap

type KDLObjectsMap

type KDLObjectsMap map[string]KDLObject

type KDLRawString

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

func NewKDLRawString

func NewKDLRawString(key string, value string) KDLRawString

func (KDLRawString) GetKey

func (kdlNode KDLRawString) GetKey() string

func (KDLRawString) GetValue

func (kdlNode KDLRawString) GetValue() KDLValue

type KDLString

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

func NewKDLString

func NewKDLString(key string, value string) KDLString

func (KDLString) GetKey

func (kdlNode KDLString) GetKey() string

func (KDLString) GetValue

func (kdlNode KDLString) GetValue() KDLValue

type KDLType

type KDLType string

type KDLValue

type KDLValue struct {
	Bool      bool
	Number    big.Float
	String    string
	RawString string
	Document  []KDLValue
	Objects   []KDLObject

	Type KDLType
	// contains filtered or unexported fields
}

func (KDLValue) RecreateKDL

func (kdlValue KDLValue) RecreateKDL() (string, error)

func (KDLValue) ToString

func (kdlValue KDLValue) ToString() (string, error)

type KDLValuesMap

type KDLValuesMap map[string]KDLValue

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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