NimYAML/src/yaml.nim

47 lines
1.4 KiB
Nim
Raw Normal View History

2015-12-23 11:35:07 +00:00
import streams, unicode, lexbase, tables, strutils
type
YamlTypeHint* = enum
yTypeInteger, yTypeFloat, yTypeBoolean, yTypeNull, yTypeString,
yTypeUnknown
YamlParserEventKind* = enum
yamlStartDocument, yamlEndDocument, yamlStartMap, yamlEndMap,
yamlStartSequence, yamlEndSequence, yamlScalar, yamlAlias,
yamlError, yamlWarning
TagId* = distinct int
AnchorId* = distinct int
YamlParserEvent* = ref object
case kind*: YamlParserEventKind
of yamlStartMap, yamlStartSequence:
objAnchor* : AnchorId
objTag* : TagId
of yamlScalar:
scalarAnchor* : AnchorId
scalarTag* : TagId
scalarContent*: string # may not be nil (but empty)
scalarType* : YamlTypeHint
2015-12-23 11:35:07 +00:00
of yamlEndMap, yamlEndSequence, yamlStartDocument, yamlEndDocument:
discard
of yamlAlias:
aliasTarget* : AnchorId
of yamlError, yamlWarning:
description* : string
line* : int
column* : int
YamlSequentialParser* = ref object
tags: OrderedTable[string, TagId]
anchors: OrderedTable[string, AnchorId]
# interface
proc parse*(parser: YamlSequentialParser, s: Stream):
iterator(): YamlParserEvent
2015-12-23 11:35:07 +00:00
# implementation
include private.lexer
include private.sequential