Renamed *LexerEvent* to *LexerToken*

This commit is contained in:
Felix Krause 2015-11-30 19:52:01 +01:00
parent 8493015042
commit 9a3cf9a524
2 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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":