d2parser

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MPL-2.0 Imports: 9 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf added in v0.2.0

func Errorf(n d2ast.Node, f string, v ...interface{}) error

func Parse

func Parse(path string, r io.RuneReader, opts *ParseOptions) (*d2ast.Map, error)

Parse parses a .d2 Map in r.

The returned Map always represents a valid .d2 file. All encountered errors will be in []error.

The map may be compiled via Compile even if there are errors to keep language tooling operational. Though autoformat should not run.

If UTF16Mode is true, positions will be recorded in UTF-16 codeunits as required by LSP and browser clients. See https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocuments TODO: update godocs

func ParseKey

func ParseKey(key string) (*d2ast.KeyPath, error)

func ParseMapKey

func ParseMapKey(mapKey string) (*d2ast.Key, error)

func ParseValue

func ParseValue(value string) (d2ast.Value, error)

Types

type ParseError

type ParseError struct {
	IOError *d2ast.Error  `json:"ioerr"`
	Errors  []d2ast.Error `json:"errs"`
}

TODO: remove ioerr, just sort (with Append) should be fine but filter non ast errors in API TODO: rename to Error and make existing Error a private type errorWithRange

func (ParseError) Empty added in v0.2.0

func (pe ParseError) Empty() bool

func (ParseError) Error

func (pe ParseError) Error() string

type ParseOptions

type ParseOptions struct {
	UTF16 bool
}

Jump to

Keyboard shortcuts

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