Lexer: Fixed parsing verbatim tags

This commit is contained in:
Felix Krause 2015-12-07 19:09:02 +01:00
parent 0544a8bba0
commit ada4a36e6e
2 changed files with 13 additions and 3 deletions

View File

@ -551,8 +551,7 @@ iterator tokens*(my: var YamlLexer): YamlLexerToken {.closure.} =
of '\'': of '\'':
state = ylSingleQuotedScalar state = ylSingleQuotedScalar
of '!': of '!':
my.content.add(c) lastSpecialChar = '!'
state = ylTagHandle
of '&': of '&':
state = ylAnchor state = ylAnchor
of '*': of '*':

View File

@ -183,3 +183,14 @@ foo:
ensure("foo: *bar", [t(yamlLineStart, ""), t(yamlScalar, "foo"), ensure("foo: *bar", [t(yamlLineStart, ""), t(yamlScalar, "foo"),
t(yamlColon, nil), t(yamlAlias, "bar"), t(yamlColon, nil), t(yamlAlias, "bar"),
t(yamlStreamEnd, nil)]) 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("!<tag:http://example.com/str> tagged",
[t(yamlLineStart, ""),
t(yamlVerbatimTag, "tag:http://example.com/str"),
t(yamlScalar, "tagged"), t(yamlStreamEnd, nil)])