From 9a3cf9a5247e6538ea7b29f20e032bfb07b2a183 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Mon, 30 Nov 2015 19:52:01 +0100 Subject: [PATCH] Renamed *LexerEvent* to *LexerToken* --- src/yaml/private/lexer.nim | 10 +++++----- test/lexing.nim | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/yaml/private/lexer.nim b/src/yaml/private/lexer.nim index 8789c2b..f702d60 100644 --- a/src/yaml/private/lexer.nim +++ b/src/yaml/private/lexer.nim @@ -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 diff --git a/test/lexing.nim b/test/lexing.nim index 58d06bb..bdb7bb9 100644 --- a/test/lexing.nim +++ b/test/lexing.nim @@ -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":