From ada4a36e6eb74829b8a59815e7264b9691acdc4a Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Mon, 7 Dec 2015 19:09:02 +0100 Subject: [PATCH] Lexer: Fixed parsing verbatim tags --- src/yaml/private/lexer.nim | 3 +-- test/lexing.nim | 13 ++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/yaml/private/lexer.nim b/src/yaml/private/lexer.nim index 64a5f7e..ca37970 100644 --- a/src/yaml/private/lexer.nim +++ b/src/yaml/private/lexer.nim @@ -551,8 +551,7 @@ iterator tokens*(my: var YamlLexer): YamlLexerToken {.closure.} = of '\'': state = ylSingleQuotedScalar of '!': - my.content.add(c) - state = ylTagHandle + lastSpecialChar = '!' of '&': state = ylAnchor of '*': diff --git a/test/lexing.nim b/test/lexing.nim index c90a898..5974cfc 100644 --- a/test/lexing.nim +++ b/test/lexing.nim @@ -182,4 +182,15 @@ foo: test "Alias": ensure("foo: *bar", [t(yamlLineStart, ""), t(yamlScalar, "foo"), t(yamlColon, nil), t(yamlAlias, "bar"), - t(yamlStreamEnd, nil)]) \ No newline at end of file + t(yamlStreamEnd, nil)]) + + test "Tag handle": + ensure("!t!str tagged", [t(yamlLineStart, ""), t(yamlTagHandle, "!t!"), + t(yamlTagSuffix, "str"), + t(yamlScalar, "tagged"), t(yamlStreamEnd, nil)]) + + test "Verbatim tag handle": + ensure("! tagged", + [t(yamlLineStart, ""), + t(yamlVerbatimTag, "tag:http://example.com/str"), + t(yamlScalar, "tagged"), t(yamlStreamEnd, nil)]) \ No newline at end of file