This commit is contained in:
Andreas Rumpf
2016-10-20 21:03:49 +02:00
parent 7c0fa52bbd
commit 20ee65af6d
2 changed files with 21 additions and 12 deletions

View File

@@ -37,14 +37,20 @@ proc renderType(n: PNode): string =
of nkIdent: result = n.ident.s
of nkSym: result = typeToString(n.sym.typ)
of nkVarTy:
assert len(n) == 1
result = renderType(n[0])
if n.len == 1:
result = renderType(n[0])
else:
result = "var"
of nkRefTy:
assert len(n) == 1
result = "ref." & renderType(n[0])
if n.len == 1:
result = "ref." & renderType(n[0])
else:
result = "ref"
of nkPtrTy:
assert len(n) == 1
result = "ptr." & renderType(n[0])
if n.len == 1:
result = "ptr." & renderType(n[0])
else:
result = "ptr"
of nkProcTy:
assert len(n) > 1
let params = n[0]

View File

@@ -242,14 +242,17 @@ proc nimNextToken(g: var GeneralTokenizer) =
inc(pos)
case g.buf[pos]
of 'b', 'B':
g.kind = gtBinNumber
inc(pos)
while g.buf[pos] in binChars: inc(pos)
pos = nimNumberPostfix(g, pos)
of 'x', 'X':
g.kind = gtHexNumber
inc(pos)
while g.buf[pos] in hexChars: inc(pos)
pos = nimNumberPostfix(g, pos)
of 'o', 'O':
g.kind = gtOctNumber
inc(pos)
while g.buf[pos] in octChars: inc(pos)
pos = nimNumberPostfix(g, pos)
@@ -700,8 +703,8 @@ proc yamlNextToken(g: var GeneralTokenizer) =
g.state = gtLongStringLit
elif g.state == gtLongStringLit:
# beware, this is the only token where we actually have to parse
# indentation.
# indentation.
g.kind = gtLongStringLit
# first, we have to find the parent indentation of the block scalar, so that
# we know when to stop
@@ -738,20 +741,20 @@ proc yamlNextToken(g: var GeneralTokenizer) =
# because lookbehind was at newline char when calculating indentation, we're
# off by one. fix that. top level's parent will have indentation of -1.
let parentIndentation = indentation - 1
# find first content
while g.buf[pos] in {' ', '\x0A', '\x0D'}:
if g.buf[pos] == ' ': inc(indentation)
else: indentation = 0
inc(pos)
var minIndentation = indentation
# for stupid edge cases, we must check whether an explicit indentation depth
# is given at the header.
while g.buf[headerStart] in {'>', '|', '+', '-'}: inc(headerStart)
if g.buf[headerStart] in {'0'..'9'}:
minIndentation = min(minIndentation, ord(g.buf[headerStart]) - ord('0'))
# process content lines
while indentation > parentIndentation and g.buf[pos] != '\0':
if (indentation < minIndentation and g.buf[pos] == '#') or
@@ -766,7 +769,7 @@ proc yamlNextToken(g: var GeneralTokenizer) =
if g.buf[pos] == ' ': inc(indentation)
else: indentation = 0
inc(pos)
g.state = gtOther
elif g.state == gtOther:
# gtOther means 'inside YAML document'