Documentation ¶
Index ¶
- type SaxParser
- func (s *SaxParser) AdditionalText() string
- func (s *SaxParser) Bool() bool
- func (s *SaxParser) IsAttributeName() bool
- func (s *SaxParser) IsBinary() bool
- func (s *SaxParser) IsBool() bool
- func (s *SaxParser) IsChar() bool
- func (s *SaxParser) IsCloseTag() bool
- func (s *SaxParser) IsDate() bool
- func (s *SaxParser) IsDateTime() bool
- func (s *SaxParser) IsDecimal() bool
- func (s *SaxParser) IsDouble() bool
- func (s *SaxParser) IsEof() bool
- func (s *SaxParser) IsFloat() bool
- func (s *SaxParser) IsInteger() bool
- func (s *SaxParser) IsLong() bool
- func (s *SaxParser) IsNewLine() bool
- func (s *SaxParser) IsNull() bool
- func (s *SaxParser) IsOpenTag() bool
- func (s *SaxParser) IsString() bool
- func (s *SaxParser) IsTagName() bool
- func (s *SaxParser) IsTimeSpan() bool
- func (s *SaxParser) NewError(offset int, msg string) error
- func (s *SaxParser) Next() error
- func (p SaxParser) ParseIntoAst() (SdlTag, error)
- func (s *SaxParser) Text() string
- func (s *SaxParser) Time() time.Time
- func (s *SaxParser) TimeSpan() time.Duration
- type SdlAttribute
- type SdlDebugLocation
- type SdlTag
- type SdlValue
- func (v SdlValue) Binary() ([]byte, error)
- func (v SdlValue) Bool() (bool, error)
- func (v SdlValue) DateTime() (time.Time, error)
- func (v SdlValue) Float() (float64, error)
- func (v SdlValue) Int() (int64, error)
- func (v SdlValue) IsBinary() bool
- func (v SdlValue) IsBool() bool
- func (v SdlValue) IsDateTime() bool
- func (v SdlValue) IsFloat() bool
- func (v SdlValue) IsInt() bool
- func (v SdlValue) IsNull() bool
- func (v SdlValue) IsString() bool
- func (v SdlValue) IsTimeSpan() bool
- func (v SdlValue) String() (string, error)
- func (v SdlValue) TimeSpan() (time.Duration, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SaxParser ¶
type SaxParser struct { // Input is the input to parse. Input string // FileName is used for debug messages. FileName string // contains filtered or unexported fields }
SaxParser provides a SAX-style of parsing. This is more efficient than constructing an AST, but involves more effort on the user's side.
func (*SaxParser) AdditionalText ¶
Additional text is some additional text to compliment the main text. For tag/attribute names, this is the namespace value.
func (*SaxParser) IsAttributeName ¶
func (*SaxParser) IsCloseTag ¶
func (*SaxParser) IsDateTime ¶
func (*SaxParser) IsTimeSpan ¶
func (*SaxParser) Next ¶
Next parses the next token. You can query which token was parsed via the `IsBool`, `IsString`, `Is..` etc. functions. You can use the likes of `Text`, `DateTime`, and so on to retrieve the parsed values. You should keep calling this function until either an error is returned, or `IsEof` returns true. Error messages are already formatted for a user-friendly experience.
func (SaxParser) ParseIntoAst ¶
Using the given SaxParser, an AST is constructed. The returned value contains the root tag, which is nameless and only contains children.
func (*SaxParser) Text ¶
Text is the parsed text. For tag/attribute names, this is the non-namespace value.
type SdlAttribute ¶
type SdlAttribute struct { // Namespace is the namespace of this attribute. Namespace string // Name is the name of this attribute. Name string // QualifiedName is the fully qualified ("namespace:name") name of this attribute. QualifiedName string // Value is the value. Value SdlValue DebugLocation SdlDebugLocation }
SdlAttribute is a Key-Value pair between a string and an SdlValue
type SdlDebugLocation ¶ added in v0.1.2
type SdlTag ¶
type SdlTag struct { // Namespace is the namespace of this tag. Namespace string // Name is the name of this tag. Name string // QualifiedName is the fully qualified ("namespace:name") name of this tag. QualifiedName string // Children contains the children of this tag. It is safe (and expected) to modify this value. Children []SdlTag // Children contains the attribtues of this tag. It is safe (and expected) to modify this value. Attributes map[string]SdlAttribute // Children contains the values of this tag. It is safe (and expected) to modify this value. Values []SdlValue DebugLocation SdlDebugLocation }
SdlTag is a container consisting of a name; child tags; attributes, and values.
func (SdlTag) ForEachChild ¶
ForEachChild applies the function `f` onto each child of the tag.
func (SdlTag) ForEachChildByName ¶
ForEachChildByName applies the function `f` onto each child of the tag that has the specified `name`.
func (SdlTag) ForEachChildByNamespace ¶
ForEachChildByName applies the function `f` onto each child of the tag that has the specified `namespace`.
type SdlValue ¶
type SdlValue struct { DebugLocation SdlDebugLocation // contains filtered or unexported fields }
SdlValue is a tagged union for every possible type representable in SDLang.