Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base
* Unify add calls
* Unify len invocations
* Unify range operators
* Fix oversight
* Remove {.procvar.} pragma
* initCandidate -> newCandidate where reasonable
* Unify safeLen calls
This commit is contained in:
parent
b662842bd0
commit
7e747d11c6
109 changed files with 6115 additions and 6254 deletions
|
|
@ -85,20 +85,20 @@ proc parsePipe(filename: AbsoluteFile, inputStream: PLLStream; cache: IdentCache
|
|||
llStreamClose(s)
|
||||
|
||||
proc getFilter(ident: PIdent): TFilterKind =
|
||||
for i in low(TFilterKind) .. high(TFilterKind):
|
||||
for i in low(TFilterKind)..high(TFilterKind):
|
||||
if cmpIgnoreStyle(ident.s, filterNames[i]) == 0:
|
||||
return i
|
||||
result = filtNone
|
||||
|
||||
proc getParser(conf: ConfigRef; n: PNode; ident: PIdent): TParserKind =
|
||||
for i in low(TParserKind) .. high(TParserKind):
|
||||
for i in low(TParserKind)..high(TParserKind):
|
||||
if cmpIgnoreStyle(ident.s, parserNames[i]) == 0:
|
||||
return i
|
||||
localError(conf, n.info, "unknown parser: " & ident.s)
|
||||
|
||||
proc getCallee(conf: ConfigRef; n: PNode): PIdent =
|
||||
if n.kind in nkCallKinds and n.sons[0].kind == nkIdent:
|
||||
result = n.sons[0].ident
|
||||
if n.kind in nkCallKinds and n[0].kind == nkIdent:
|
||||
result = n[0].ident
|
||||
elif n.kind == nkIdent:
|
||||
result = n.ident
|
||||
else:
|
||||
|
|
@ -131,13 +131,13 @@ proc evalPipe(p: var TParsers, n: PNode, filename: AbsoluteFile,
|
|||
result = start
|
||||
if n.kind == nkEmpty: return
|
||||
if n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s == "|":
|
||||
for i in 1 .. 2:
|
||||
if n.sons[i].kind == nkInfix:
|
||||
result = evalPipe(p, n.sons[i], filename, result)
|
||||
for i in 1..2:
|
||||
if n[i].kind == nkInfix:
|
||||
result = evalPipe(p, n[i], filename, result)
|
||||
else:
|
||||
result = applyFilter(p, n.sons[i], filename, result)
|
||||
result = applyFilter(p, n[i], filename, result)
|
||||
elif n.kind == nkStmtList:
|
||||
result = evalPipe(p, n.sons[0], filename, result)
|
||||
result = evalPipe(p, n[0], filename, result)
|
||||
else:
|
||||
result = applyFilter(p, n, filename, result)
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ proc setupParsers*(p: var TParsers; fileIdx: FileIndex; cache: IdentCache;
|
|||
openParsers(p, fileIdx, llStreamOpen(f), cache, config)
|
||||
result = true
|
||||
|
||||
proc parseFile*(fileIdx: FileIndex; cache: IdentCache; config: ConfigRef): PNode {.procvar.} =
|
||||
proc parseFile*(fileIdx: FileIndex; cache: IdentCache; config: ConfigRef): PNode =
|
||||
var p: TParsers
|
||||
if setupParsers(p, fileIdx, cache, config):
|
||||
result = parseAll(p)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue