Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix filter_tmpl errors
  • Loading branch information
data-man committed May 3, 2018
commit 91e54e18f5abac2707b1e9e40e1eff7a46412cbb
27 changes: 15 additions & 12 deletions compiler/filter_tmpl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ proc scanPar(p: var TTmplParser, d: int) =
let hi = p.x.len - 1
while i <= hi:
case p.x[i]
of '\0': break
of '(': inc(p.par)
of ')': dec(p.par)
of '[': inc(p.bracket)
Expand All @@ -64,16 +63,22 @@ const

proc parseLine(p: var TTmplParser) =
var j = 0
while p.x[j] == ' ': inc(j)
let hi = p.x.len - 1

if hi == 0:
return

while j <= hi and p.x[j] == ' ': inc(j)

if p.x[0] == p.nimDirective and p.x[1] == '?':
newLine(p)
elif p.x[j] == p.nimDirective:
newLine(p)
inc(j)
while p.x[j] == ' ': inc(j)
while j <= hi and p.x[j] == ' ': inc(j)
let d = j
var keyw = ""
while p.x[j] in PatternChars:
while j <= hi and p.x[j] in PatternChars:
add(keyw, p.x[j])
inc(j)

Expand Down Expand Up @@ -127,10 +132,8 @@ proc parseLine(p: var TTmplParser) =
llStreamWrite(p.outp, "(\"")
inc(p.emitPar)
p.state = psTempl
while true:
while j <= hi:
case p.x[j]
of '\0':
break
of '\x01'..'\x1F', '\x80'..'\xFF':
llStreamWrite(p.outp, "\\x")
llStreamWrite(p.outp, toHex(ord(p.x[j]), 2))
Expand All @@ -157,11 +160,8 @@ proc parseLine(p: var TTmplParser) =
llStreamWrite(p.outp, '(')
inc(j)
var curly = 0
while true:
while j <= hi:
case p.x[j]
of '\0':
localError(p.info, errXExpected, "}")
break
of '{':
inc(j)
inc(curly)
Expand All @@ -174,6 +174,9 @@ proc parseLine(p: var TTmplParser) =
else:
llStreamWrite(p.outp, p.x[j])
inc(j)
if curly > 0:
localError(p.info, errXExpected, "}")
break
llStreamWrite(p.outp, ')')
llStreamWrite(p.outp, p.conc)
llStreamWrite(p.outp, '\"')
Expand All @@ -182,7 +185,7 @@ proc parseLine(p: var TTmplParser) =
llStreamWrite(p.outp, p.conc)
llStreamWrite(p.outp, p.toStr)
llStreamWrite(p.outp, '(')
while p.x[j] in PatternChars:
while j <= hi and p.x[j] in PatternChars:
llStreamWrite(p.outp, p.x[j])
inc(j)
llStreamWrite(p.outp, ')')
Expand Down