Documentation ¶
Index ¶
- Variables
- func DetectLineBreakCharacter(src string) string
- func IsNeedQuoted(value string) bool
- func LiteralBlockHeader(value string) string
- type Character
- type CharacterType
- type Indicator
- type NumberType
- type NumberValue
- type Position
- type ReservedTagKeyword
- type Token
- func Alias(org string, pos *Position) *Token
- func Anchor(org string, pos *Position) *Token
- func CollectEntry(org string, pos *Position) *Token
- func Comment(value string, org string, pos *Position) *Token
- func Directive(org string, pos *Position) *Token
- func DocumentEnd(org string, pos *Position) *Token
- func DocumentHeader(org string, pos *Position) *Token
- func DoubleQuote(value string, org string, pos *Position) *Token
- func Folded(value string, org string, pos *Position) *Token
- func Invalid(err string, org string, pos *Position) *Token
- func Literal(value string, org string, pos *Position) *Token
- func MappingEnd(org string, pos *Position) *Token
- func MappingKey(pos *Position) *Token
- func MappingStart(org string, pos *Position) *Token
- func MappingValue(pos *Position) *Token
- func MergeKey(org string, pos *Position) *Token
- func New(value string, org string, pos *Position) *Token
- func SequenceEnd(org string, pos *Position) *Token
- func SequenceEntry(org string, pos *Position) *Token
- func SequenceStart(org string, pos *Position) *Token
- func SingleQuote(value string, org string, pos *Position) *Token
- func Space(pos *Position) *Token
- func String(value string, org string, pos *Position) *Token
- func Tag(value string, org string, pos *Position) *Token
- type Tokens
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ReservedTagKeywordMap map for reserved tag keywords ReservedTagKeywordMap = map[ReservedTagKeyword]func(string, string, *Position) *Token{ IntegerTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, FloatTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, NullTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, SequenceTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, MappingTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, StringTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, BinaryTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, OrderedMapTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, SetTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, TimestampTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, BooleanTag: func(value, org string, pos *Position) *Token { return &Token{ Type: TagType, CharacterType: CharacterTypeIndicator, Indicator: NodePropertyIndicator, Value: value, Origin: org, Position: pos, } }, } )
Functions ¶
func DetectLineBreakCharacter ¶ added in v1.3.1
DetectLineBreakCharacter detect line break character in only one inside scalar content scope.
func IsNeedQuoted ¶
IsNeedQuoted whether need quote for passed string or not
func LiteralBlockHeader ¶ added in v1.3.1
LiteralBlockHeader detect literal block scalar header
Types ¶
type Character ¶
type Character byte
Character type for character
const ( // SequenceEntryCharacter character for sequence entry SequenceEntryCharacter Character = '-' // MappingKeyCharacter character for mapping key MappingKeyCharacter Character = '?' // MappingValueCharacter character for mapping value MappingValueCharacter Character = ':' // CollectEntryCharacter character for collect entry CollectEntryCharacter Character = ',' // SequenceStartCharacter character for sequence start SequenceStartCharacter Character = '[' // SequenceEndCharacter character for sequence end SequenceEndCharacter Character = ']' // MappingStartCharacter character for mapping start MappingStartCharacter Character = '{' // MappingEndCharacter character for mapping end MappingEndCharacter Character = '}' // CommentCharacter character for comment CommentCharacter Character = '#' // AnchorCharacter character for anchor AnchorCharacter Character = '&' // AliasCharacter character for alias AliasCharacter Character = '*' // TagCharacter character for tag TagCharacter Character = '!' // LiteralCharacter character for literal LiteralCharacter Character = '|' // FoldedCharacter character for folded FoldedCharacter Character = '>' // SingleQuoteCharacter character for single quote SingleQuoteCharacter Character = '\'' // DoubleQuoteCharacter character for double quote DoubleQuoteCharacter Character = '"' // DirectiveCharacter character for directive DirectiveCharacter Character = '%' // SpaceCharacter character for space SpaceCharacter Character = ' ' // LineBreakCharacter character for line break LineBreakCharacter Character = '\n' )
type CharacterType ¶
type CharacterType int
CharacterType type for character category
const ( // CharacterTypeIndicator type of indicator character CharacterTypeIndicator CharacterType = iota // CharacterTypeWhiteSpace type of white space character CharacterTypeWhiteSpace // CharacterTypeMiscellaneous type of miscellaneous character CharacterTypeMiscellaneous // CharacterTypeEscaped type of escaped character CharacterTypeEscaped // CharacterTypeInvalid type for a invalid token. CharacterTypeInvalid )
func (CharacterType) String ¶
func (c CharacterType) String() string
String character type identifier to text
type Indicator ¶
type Indicator int
Indicator type for indicator
const ( // NotIndicator not indicator NotIndicator Indicator = iota // BlockStructureIndicator indicator for block structure ( '-', '?', ':' ) BlockStructureIndicator // FlowCollectionIndicator indicator for flow collection ( '[', ']', '{', '}', ',' ) FlowCollectionIndicator // CommentIndicator indicator for comment ( '#' ) CommentIndicator // NodePropertyIndicator indicator for node property ( '!', '&', '*' ) NodePropertyIndicator // BlockScalarIndicator indicator for block scalar ( '|', '>' ) BlockScalarIndicator // QuotedScalarIndicator indicator for quoted scalar ( ”', '"' ) QuotedScalarIndicator // DirectiveIndicator indicator for directive ( '%' ) DirectiveIndicator // InvalidUseOfReservedIndicator indicator for invalid use of reserved keyword ( '@', '`' ) InvalidUseOfReservedIndicator )
type NumberType ¶ added in v1.13.6
type NumberType string
const ( NumberTypeDecimal NumberType = "decimal" NumberTypeBinary NumberType = "binary" NumberTypeOctet NumberType = "octet" NumberTypeHex NumberType = "hex" NumberTypeFloat NumberType = "float" )
type NumberValue ¶ added in v1.13.6
type NumberValue struct { Type NumberType Value any Text string }
func ToNumber ¶ added in v1.13.6
func ToNumber(value string) *NumberValue
type ReservedTagKeyword ¶
type ReservedTagKeyword string
ReservedTagKeyword type of reserved tag keyword
const ( // IntegerTag `!!int` tag IntegerTag ReservedTagKeyword = "!!int" // FloatTag `!!float` tag FloatTag ReservedTagKeyword = "!!float" // NullTag `!!null` tag NullTag ReservedTagKeyword = "!!null" // SequenceTag `!!seq` tag SequenceTag ReservedTagKeyword = "!!seq" // MappingTag `!!map` tag MappingTag ReservedTagKeyword = "!!map" // StringTag `!!str` tag StringTag ReservedTagKeyword = "!!str" // BinaryTag `!!binary` tag BinaryTag ReservedTagKeyword = "!!binary" // OrderedMapTag `!!omap` tag OrderedMapTag ReservedTagKeyword = "!!omap" // SetTag `!!set` tag SetTag ReservedTagKeyword = "!!set" // TimestampTag `!!timestamp` tag TimestampTag ReservedTagKeyword = "!!timestamp" // BooleanTag `!!bool` tag BooleanTag ReservedTagKeyword = "!!bool" )
type Token ¶
type Token struct { // Type is a token type. Type Type // CharacterType is a character type. CharacterType CharacterType // Indicator is a indicator type. Indicator Indicator // Value is a string extracted with only meaningful characters, with spaces and such removed. Value string // Origin is a string that stores the original text as-is. Origin string // Error keeps error message for InvalidToken. Error string // Position is a token position. Position *Position // Next is a next token reference. Next *Token // Prev is a previous token reference. Prev *Token }
Token type for token
func CollectEntry ¶
CollectEntry create token for CollectEntry
func DocumentEnd ¶
DocumentEnd create token for DocumentEnd
func DocumentHeader ¶
DocumentHeader create token for DocumentHeader
func DoubleQuote ¶
DoubleQuote create token for DoubleQuote
func MappingEnd ¶
MappingEnd create token for MappingEnd
func MappingStart ¶
MappingStart create token for MappingStart
func MappingValue ¶
MappingValue create token for MappingValue
func SequenceEnd ¶
SequenceEnd create token for SequenceEnd
func SequenceEntry ¶
SequenceEntry create token for SequenceEntry
func SequenceStart ¶
SequenceStart create token for SequenceStart
func SingleQuote ¶
SingleQuote create token for SingleQuote
func (*Token) AddColumn ¶ added in v1.1.4
AddColumn append column number to current position of column
type Tokens ¶
type Tokens []*Token
Tokens type of token collection
func (Tokens) InvalidToken ¶ added in v1.13.1
type Type ¶
type Type int
Type type identifier for token
const ( // UnknownType reserve for invalid type UnknownType Type = iota // DocumentHeaderType type for DocumentHeader token DocumentHeaderType // DocumentEndType type for DocumentEnd token DocumentEndType // SequenceEntryType type for SequenceEntry token SequenceEntryType // MappingKeyType type for MappingKey token MappingKeyType // MappingValueType type for MappingValue token MappingValueType // MergeKeyType type for MergeKey token MergeKeyType // CollectEntryType type for CollectEntry token CollectEntryType // SequenceStartType type for SequenceStart token SequenceStartType // SequenceEndType type for SequenceEnd token SequenceEndType // MappingStartType type for MappingStart token MappingStartType // MappingEndType type for MappingEnd token MappingEndType // CommentType type for Comment token CommentType // AnchorType type for Anchor token AnchorType // AliasType type for Alias token AliasType // TagType type for Tag token TagType // LiteralType type for Literal token LiteralType // FoldedType type for Folded token FoldedType // SingleQuoteType type for SingleQuote token SingleQuoteType // DoubleQuoteType type for DoubleQuote token DoubleQuoteType // DirectiveType type for Directive token DirectiveType // SpaceType type for Space token SpaceType // NullType type for Null token NullType // InfinityType type for Infinity token InfinityType // NanType type for Nan token NanType // IntegerType type for Integer token IntegerType // BinaryIntegerType type for BinaryInteger token BinaryIntegerType // OctetIntegerType type for OctetInteger token OctetIntegerType // HexIntegerType type for HexInteger token HexIntegerType // FloatType type for Float token FloatType // StringType type for String token StringType // BoolType type for Bool token BoolType // InvalidType type for invalid token InvalidType )