mirror of https://github.com/status-im/NimYAML.git
Renamed *LexerEvent* to *LexerToken*
This commit is contained in:
parent
8493015042
commit
9a3cf9a524
|
@ -9,7 +9,7 @@ type
|
|||
UTF32LE, ## UTF-32 Little Endian
|
||||
UTF32BE ## UTF-32 Big Endian
|
||||
|
||||
YamlLexerEventKind* = enum
|
||||
YamlLexerTokenKind* = enum
|
||||
# separating tokens
|
||||
yamlDirectivesEnd, yamlDocumentEnd, yamlStreamEnd,
|
||||
# tokens only in directives
|
||||
|
@ -37,8 +37,8 @@ type
|
|||
yamlError
|
||||
|
||||
|
||||
YamlLexerEvent* = tuple
|
||||
kind: YamlLexerEventKind
|
||||
YamlLexerToken* = tuple
|
||||
kind: YamlLexerTokenKind
|
||||
position: int # X position relative to line start (0-based)
|
||||
|
||||
YamlLexerState = enum
|
||||
|
@ -142,7 +142,7 @@ proc open*(my: var YamlLexer, input: Stream) =
|
|||
my.detect_encoding()
|
||||
my.content = ""
|
||||
|
||||
template yieldToken(mKind: YamlLexerEventKind) {.dirty.} =
|
||||
template yieldToken(mKind: YamlLexerTokenKind) {.dirty.} =
|
||||
yield (kind: mKind, position: position)
|
||||
my.content = ""
|
||||
|
||||
|
@ -162,7 +162,7 @@ template handleLF() {.dirty.} =
|
|||
template `or`(r: Rune, i: int): Rune =
|
||||
cast[Rune](cast[int](r) or i)
|
||||
|
||||
iterator tokens*(my: var YamlLexer): YamlLexerEvent =
|
||||
iterator tokens*(my: var YamlLexer): YamlLexerToken =
|
||||
var
|
||||
# the following three values are used for parsing escaped unicode chars
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ import streams, unicode
|
|||
|
||||
import unittest
|
||||
|
||||
type BasicLexerEvent = tuple[kind: YamlLexerEventKind, content: string]
|
||||
type BasicLexerToken = tuple[kind: YamlLexerTokenKind, content: string]
|
||||
|
||||
template ensure(input: string, expected: openarray[BasicLexerEvent]) =
|
||||
template ensure(input: string, expected: openarray[BasicLexerToken]) =
|
||||
var
|
||||
i = 0
|
||||
lex: YamlLexer
|
||||
|
@ -35,7 +35,7 @@ template ensure(input: string, expected: openarray[BasicLexerEvent]) =
|
|||
echo "received less tokens than expected (first missing = ",
|
||||
expected[i].kind, ")"
|
||||
|
||||
proc t(kind: YamlLexerEventKind, content: string): BasicLexerEvent =
|
||||
proc t(kind: YamlLexerTokenKind, content: string): BasicLexerToken =
|
||||
(kind: kind, content: content)
|
||||
|
||||
suite "Lexing":
|
||||
|
|
Loading…
Reference in New Issue