diff options
author | Araq <rumpf_a@web.de> | 2013-07-29 23:52:08 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-07-29 23:52:08 +0200 |
commit | 28ad262a462db5d02ffc046a6682fbe1dbfac5f9 (patch) | |
tree | 6897e4978f435f391c22ef7f07ae9e885345ddaf | |
parent | 6810a0e3e3f82ca40ca4fc51de820212dc90610d (diff) | |
download | Nim-28ad262a462db5d02ffc046a6682fbe1dbfac5f9.tar.gz |
'nimrod pretty': next steps, doesn't work yet
-rw-r--r-- | compiler/main.nim | 1 | ||||
-rw-r--r-- | compiler/pretty.nim | 20 |
2 files changed, 14 insertions, 7 deletions
diff --git a/compiler/main.nim b/compiler/main.nim index d8d8dc8db..6df21f660 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -170,6 +170,7 @@ proc CommandPrettyOld = renderModule(module, getOutFile(mainCommandArg(), "pretty." & NimExt)) proc CommandPretty = + msgs.gErrorMax = high(int) # do not stop after first error semanticPasses() registerPass(prettyPass) compileProject() diff --git a/compiler/pretty.nim b/compiler/pretty.nim index 92de96755..3d59f7e36 100644 --- a/compiler/pretty.nim +++ b/compiler/pretty.nim @@ -25,12 +25,13 @@ type fullpath: string var - gSourceFiles: seq[TSourceFile] + gSourceFiles: seq[TSourceFile] = @[] proc loadFile(info: TLineInfo) = let i = info.fileIndex if i >= gSourceFiles.len: - gSourceFiles.setLen(i) + gSourceFiles.setLen(i+1) + if gSourceFiles[i].lines.isNil: gSourceFiles[i].lines = @[] let path = info.toFullPath gSourceFiles[i].fullpath = path @@ -80,11 +81,14 @@ proc identLen(line: string, start: int): int = inc result proc differ(line: string, a, b: int, x: string): bool = - var j = 0 - for i in a..b: - if line[i] != x[j]: return true - inc j - return false + let y = line[a..b] + result = cmpIgnoreStyle(y, x) == 0 and y != x + when false: + var j = 0 + for i in a..b: + if line[i] != x[j]: return true + inc j + return false var cannotRename = initIntSet() @@ -106,6 +110,8 @@ proc processSym(c: PPassContext, n: PNode): PNode = let line = gSourceFiles[n.info.fileIndex].lines[n.info.line-1] var first = n.info.col.int - len(s.name.s) + if first < 0: return + #inc first, skipIgnoreCase(line, "proc ", first) if line[first] == '`': inc first if {sfImportc, sfExportc} * s.flags != {}: |