Merge branch 'multi-line-comments' into devel
This commit is contained in:
commit
484e285cfd
8 changed files with 159 additions and 39 deletions
|
|
@ -173,7 +173,41 @@ proc nimNextToken(g: var GeneralTokenizer) =
|
|||
while g.buf[pos] in {' ', '\x09'..'\x0D'}: inc(pos)
|
||||
of '#':
|
||||
g.kind = gtComment
|
||||
while not (g.buf[pos] in {'\0', '\x0A', '\x0D'}): inc(pos)
|
||||
inc(pos)
|
||||
var isDoc = false
|
||||
if g.buf[pos] == '#':
|
||||
inc(pos)
|
||||
isDoc = true
|
||||
if g.buf[pos] == '[':
|
||||
g.kind = gtLongComment
|
||||
var nesting = 0
|
||||
while true:
|
||||
case g.buf[pos]
|
||||
of '\0': break
|
||||
of '#':
|
||||
if isDoc:
|
||||
if g.buf[pos+1] == '#' and g.buf[pos+2] == '[':
|
||||
inc nesting
|
||||
elif g.buf[pos+1] == '[':
|
||||
inc nesting
|
||||
inc pos
|
||||
of ']':
|
||||
if isDoc:
|
||||
if g.buf[pos+1] == '#' and g.buf[pos+2] == '#':
|
||||
if nesting == 0:
|
||||
inc(pos, 3)
|
||||
break
|
||||
dec nesting
|
||||
elif g.buf[pos+1] == '#':
|
||||
if nesting == 0:
|
||||
inc(pos, 2)
|
||||
break
|
||||
dec nesting
|
||||
inc pos
|
||||
else:
|
||||
inc pos
|
||||
else:
|
||||
while g.buf[pos] notin {'\0', '\x0A', '\x0D'}: inc(pos)
|
||||
of 'a'..'z', 'A'..'Z', '_', '\x80'..'\xFF':
|
||||
var id = ""
|
||||
while g.buf[pos] in SymChars + {'_'}:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue