yamlh

package
v0.0.0-...-831a7e0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: Apache-2.0, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The size of the input raw buffer.
	Input_raw_buffer_size = 512

	// The size of the input buffer.
	// It should be possible to decode the whole raw buffer.
	Input_buffer_size = Input_raw_buffer_size * 3

	// The size of other stacks and queues.
	Initial_stack_size = 16
	Initial_queue_size = 16
)
View Source
const (
	NULL_TAG      = "tag:yaml.org,2002:null"      // The tag !!null with the only possible value: null.
	BOOL_TAG      = "tag:yaml.org,2002:bool"      // The tag !!bool with the values: true and false.
	STR_TAG       = "tag:yaml.org,2002:str"       // The tag !!str for string values.
	INT_TAG       = "tag:yaml.org,2002:int"       // The tag !!int for integer values.
	FLOAT_TAG     = "tag:yaml.org,2002:float"     // The tag !!float for float values.
	TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values.

	SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences.
	MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping.

	// Not in original libyaml.
	BINARY_TAG = "tag:yaml.org,2002:binary"
	MERGE_TAG  = "tag:yaml.org,2002:merge"

	DEFAULT_SCALAR_TAG   = STR_TAG // The default scalar tag is !!str.
	DEFAULT_SEQUENCE_TAG = SEQ_TAG // The default sequence tag is !!seq.
	DEFAULT_MAPPING_TAG  = MAP_TAG // The default mapping tag is !!map.
)

Variables

This section is empty.

Functions

func As_digit

func As_digit(b []byte, i int) int

Get the value of a digit.

func As_hex

func As_hex(b []byte, i int) int

Get the value of a hex-digit.

func IsBlank

func IsBlank(b byte) bool

func IsBlankz

func IsBlankz(b []byte) bool

func IsBreak

func IsBreak(b []byte) bool

func IsPrintable

func IsPrintable(b []byte) bool

Check if the character at the start of the buffer can be printed unescaped.

func Is_alpha

func Is_alpha(b []byte, i int) bool

Check if the character at the specified position is an alphabetical character, a digit, '_', or '-'.

func Is_blank

func Is_blank(b []byte, i int) bool

Check if the character at the specified position is blank (space or tab).

func Is_blankz

func Is_blankz(b []byte, i int) bool

Check if the character is a line break, space, tab, or NUL.

func Is_bom

func Is_bom(b []byte) bool

Check if the beginning of the buffer is a BOM.

func Is_break

func Is_break(b []byte, i int) bool

Is_break - Check if the character at the specified position is a line break.

func Is_breakz

func Is_breakz(b []byte, i int) bool

Check if the character is a line break or NUL.

func Is_crlf

func Is_crlf(b []byte, i int) bool

func Is_digit

func Is_digit(b []byte, i int) bool

Check if the character at the specified position is a digit.

func Is_hex

func Is_hex(b []byte, i int) bool

Check if the character at the specified position is a hex-digit.

func Is_space

func Is_space(b []byte, i int) bool

Check if the character at the specified position is space.

func Is_spacez

func Is_spacez(b []byte, i int) bool

Check if the character is a line break, space, or NUL.

func Is_tab

func Is_tab(b []byte, i int) bool

Check if the character at the specified position is tab.

func Is_z

func Is_z(b []byte, i int) bool

Check if the character at the specified position is NUL.

func Width

func Width(b byte) int

Determine the width of the character.

Types

type Break

type Break int
const (
	// Let the parser choose the break type.
	ANY_BREAK Break = iota

	CR_BREAK   // Use CR for line breaks (Mac style).
	LN_BREAK   // Use LN for line breaks (Unix style).
	CRLN_BREAK // Use CR LN for line breaks (DOS style).
)

Line break types.

type Encoding

type Encoding int
const (
	// Let the parser choose the encoding.
	ANY_ENCODING Encoding = iota

	UTF8_ENCODING    // The default UTF-8 encoding.
	UTF16LE_ENCODING // The UTF-16-LE encoding with BOM.
	UTF16BE_ENCODING // The UTF-16-BE encoding with BOM.
)

The stream encoding.

type ErrorType

type ErrorType int
const (
	// No error is produced.
	NO_ERROR ErrorType = iota

	READER_ERROR  // Cannot read or decode the input stream.
	SCANNER_ERROR // Cannot scan the input stream.
	PARSER_ERROR  // Cannot parsePanic the input stream.
	WRITER_ERROR  // Cannot write to the output stream.
	EMITTER_ERROR // Cannot emit a YAML stream.
)

Many bad things could happen with the parser and emitter.

type Event

type Event struct {
	// The event type.
	Type EventType

	// The start and end of the event.
	Start_mark, End_mark Position

	// The document Encoding (for STREAM_START_EVENT).
	Encoding Encoding

	// The version directive (for DOCUMENT_START_EVENT).
	Version_directive *VersionDirective

	// The list of tag directives (for DOCUMENT_START_EVENT).
	Tag_directives []TagDirective

	// The comments
	Head_comment []byte
	Line_comment []byte
	Foot_comment []byte
	Tail_comment []byte

	// The Anchor (for SCALAR_EVENT, SEQUENCE_START_EVENT, MAPPING_START_EVENT, ALIAS_EVENT).
	Anchor []byte

	// The Tag (for SCALAR_EVENT, SEQUENCE_START_EVENT, MAPPING_START_EVENT).
	Tag []byte

	// The scalar Value (for SCALAR_EVENT).
	Value []byte

	// Is the document start/end indicator Implicit, or the Tag optional?
	// (for DOCUMENT_START_EVENT, DOCUMENT_END_EVENT, SEQUENCE_START_EVENT, MAPPING_START_EVENT, SCALAR_EVENT).
	Implicit bool

	// Is the Tag optional for any non-plain style? (for SCALAR_EVENT).
	Quoted_implicit bool

	// The Style (for SCALAR_EVENT, SEQUENCE_START_EVENT, MAPPING_START_EVENT).
	Style YamlStyle
}

The Event structure.

func (*Event) Mapping_style

func (e *Event) Mapping_style() YamlMappingStyle

func (*Event) Scalar_style

func (e *Event) Scalar_style() YamlScalarStyle

func (*Event) Sequence_style

func (e *Event) Sequence_style() YamlSequenceStyle

type EventType

type EventType int8
const (
	NO_EVENT EventType = iota

	STREAM_START_EVENT   // A STREAM-START event.
	STREAM_END_EVENT     // A STREAM-END event.
	DOCUMENT_START_EVENT // A DOCUMENT-START event.
	DOCUMENT_END_EVENT   // A DOCUMENT-END event.
	ALIAS_EVENT          // An ALIAS event.
	SCALAR_EVENT         // A SCALAR event.
	SEQUENCE_START_EVENT // A SEQUENCE-START event.
	SEQUENCE_END_EVENT   // A SEQUENCE-END event.
	MAPPING_START_EVENT  // A MAPPING-START event.
	MAPPING_END_EVENT    // A MAPPING-END event.
	TAIL_COMMENT_EVENT
)

Event types.

func (EventType) String

func (e EventType) String() string

type Position

type Position struct {
	Index  int // The position Index.
	Line   int // The position Line.
	Column int // The position Column.
}

Position is he pointer position.

type SimpleKey

type SimpleKey struct {
	Possible     bool     // Is a simple key Possible?
	Required     bool     // Is a simple key Required?
	Token_number int      // The number of the token.
	Mark         Position // The position Mark.
}

SimpleKey holds information about a potential simple key.

type TagDirective

type TagDirective struct {
	Handle []byte // The tag Handle.
	Prefix []byte // The tag Prefix.
}

type TokenType

type TokenType int
const (
	// An empty token.
	NO_TOKEN TokenType = iota

	STREAM_START_TOKEN // A STREAM-START token.
	STREAM_END_TOKEN   // A STREAM-END token.

	VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token.
	TAG_DIRECTIVE_TOKEN     // A TAG-DIRECTIVE token.
	DOCUMENT_START_TOKEN    // A DOCUMENT-START token.
	DOCUMENT_END_TOKEN      // A DOCUMENT-END token.

	BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token.
	BLOCK_MAPPING_START_TOKEN  // A BLOCK-SEQUENCE-END token.
	BLOCK_END_TOKEN            // A BLOCK-END token.

	FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token.
	FLOW_SEQUENCE_END_TOKEN   // A FLOW-SEQUENCE-END token.
	FLOW_MAPPING_START_TOKEN  // A FLOW-MAPPING-START token.
	FLOW_MAPPING_END_TOKEN    // A FLOW-MAPPING-END token.

	BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token.
	FLOW_ENTRY_TOKEN  // A FLOW-ENTRY token.
	KEY_TOKEN         // A KEY token.
	VALUE_TOKEN       // A VALUE token.

	ALIAS_TOKEN  // An ALIAS token.
	ANCHOR_TOKEN // An ANCHOR token.
	TAG_TOKEN    // A TAG token.
	SCALAR_TOKEN // A SCALAR token.
)

Token types.

func (TokenType) String

func (tt TokenType) String() string

type VersionDirective

type VersionDirective struct {
	Major int8 // The Major version number.
	Minor int8 // The Minor version number.
}

type YamlComment

type YamlComment struct {
	Scan_mark  Position // Position where scanning for comments started
	Token_mark Position // Position after which tokens will be associated with this comment
	Start_mark Position // Position of '#' comment mark
	End_mark   Position // Position where comment terminated

	Head []byte
	Line []byte
	Foot []byte
}

type YamlMappingStyle

type YamlMappingStyle YamlStyle
const (
	// Let the emitter choose the style.
	ANY_MAPPING_STYLE YamlMappingStyle = iota

	BLOCK_MAPPING_STYLE // The block mapping style.
	FLOW_MAPPING_STYLE  // The flow mapping style.
)

Mapping styles.

type YamlScalarStyle

type YamlScalarStyle YamlStyle
const (
	// Let the emitter choose the style.
	ANY_SCALAR_STYLE YamlScalarStyle = 0

	PLAIN_SCALAR_STYLE         YamlScalarStyle = 1 << iota // The plain scalar style.
	SINGLE_QUOTED_SCALAR_STYLE                             // The single-quoted scalar style.
	DOUBLE_QUOTED_SCALAR_STYLE                             // The double-quoted scalar style.
	LITERAL_SCALAR_STYLE                                   // The literal scalar style.
	FOLDED_SCALAR_STYLE                                    // The folded scalar style.
)

Scalar styles.

type YamlSequenceStyle

type YamlSequenceStyle YamlStyle
const (
	// Let the emitter choose the style.
	ANY_SEQUENCE_STYLE YamlSequenceStyle = iota

	BLOCK_SEQUENCE_STYLE // The block sequence style.
	FLOW_SEQUENCE_STYLE  // The flow sequence style.
)

Sequence styles.

type YamlStyle

type YamlStyle int8

type YamlToken

type YamlToken struct {
	// The token type.
	Type TokenType

	// The start/end of the token.
	Start_mark, End_mark Position

	// The stream Encoding (for STREAM_START_TOKEN).
	Encoding Encoding

	// The alias/anchor/scalar Value or tag/tag directive handle
	// (for ALIAS_TOKEN, ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN).
	Value []byte

	// The tag Suffix (for TAG_TOKEN).
	Suffix []byte

	// The tag directive Prefix (for TAG_DIRECTIVE_TOKEN).
	Prefix []byte

	// The scalar Style (for SCALAR_TOKEN).
	Style YamlScalarStyle

	// The version directive Major/minor (for VERSION_DIRECTIVE_TOKEN).
	Major, Minor int8
}

Jump to

Keyboard shortcuts

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