diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-06-10 10:50:02 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-06-10 10:50:15 +0200 |
commit | caf93f43554475e36f0526fc6212963338b02cdf (patch) | |
tree | 9adf9fec04e8fbc7d389ace6c87fe3aa6e503a34 /nimpretty | |
parent | 22a1b1203829acabe618102e7295a116315e1bf0 (diff) | |
download | Nim-caf93f43554475e36f0526fc6212963338b02cdf.tar.gz |
nimpretty: smart tabs support, fixes #9399 [bugfix]
Diffstat (limited to 'nimpretty')
-rw-r--r-- | nimpretty/nimpretty.nim | 14 | ||||
-rw-r--r-- | nimpretty/nimpretty.nim.cfg | 1 | ||||
-rw-r--r-- | nimpretty/tests/exhaustive.nim | 13 | ||||
-rw-r--r-- | nimpretty/tests/expected/exhaustive.nim | 21 |
4 files changed, 35 insertions, 14 deletions
diff --git a/nimpretty/nimpretty.nim b/nimpretty/nimpretty.nim index 3e06ccff3..185f8da7c 100644 --- a/nimpretty/nimpretty.nim +++ b/nimpretty/nimpretty.nim @@ -50,15 +50,11 @@ proc prettyPrint(infile, outfile: string, opt: PrettyOptions) = var conf = newConfigRef() let fileIdx = fileInfoIdx(conf, AbsoluteFile infile) conf.outFile = RelativeFile outfile - when defined(nimpretty2): - var p: TParsers - p.parser.em.indWidth = opt.indWidth - if setupParsers(p, fileIdx, newIdentCache(), conf): - discard parseAll(p) - closeParsers(p) - else: - let tree = parseFile(fileIdx, newIdentCache(), conf) - renderModule(tree, infile, outfile, {}, fileIdx, conf) + var p: TParsers + p.parser.em.indWidth = opt.indWidth + if setupParsers(p, fileIdx, newIdentCache(), conf): + discard parseAll(p) + closeParsers(p) proc main = var infile, outfile: string diff --git a/nimpretty/nimpretty.nim.cfg b/nimpretty/nimpretty.nim.cfg index b4fac5377..138bce52e 100644 --- a/nimpretty/nimpretty.nim.cfg +++ b/nimpretty/nimpretty.nim.cfg @@ -1,3 +1,2 @@ --define: nimpretty ---define: nimpretty2 --define: nimOldCaseObjects diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim index 2677c86bf..2f8fe03f2 100644 --- a/nimpretty/tests/exhaustive.nim +++ b/nimpretty/tests/exhaustive.nim @@ -396,3 +396,16 @@ proc main() = discard main() + +type + TCallingConvention* = enum + ccDefault, # proc has no explicit calling convention + ccStdCall, # procedure is stdcall + ccCDecl, # cdecl + ccSafeCall, # safecall + ccSysCall, # system call + ccInline, # proc should be inlined + ccNoInline, # proc should not be inlined + ccFastCall, # fastcall (pass parameters in registers) + ccClosure, # proc has a closure + ccNoConvention # needed for generating proper C procs sometimes diff --git a/nimpretty/tests/expected/exhaustive.nim b/nimpretty/tests/expected/exhaustive.nim index 0e27e32a4..75580081d 100644 --- a/nimpretty/tests/expected/exhaustive.nim +++ b/nimpretty/tests/expected/exhaustive.nim @@ -29,10 +29,10 @@ var x = 1 type GeneralTokenizer* = object of RootObj ## comment here - kind*: TokenClass ## and here - start*, length*: int ## you know how it goes... + kind*: TokenClass ## and here + start*, length*: int ## you know how it goes... buf: cstring - pos: int # other comment here. + pos: int # other comment here. state: TokenClass var x*: string @@ -122,7 +122,7 @@ type inquote {.pragmaHereWrongCurlyEnd.}: bool col, lastLineNumber, lineSpan, indentLevel: int content: string - fixedUntil: int # marks where we must not go in the content + fixedUntil: int # marks where we must not go in the content altSplitPos: array[SplitKind, int] # alternative split positions proc openEmitter*[T, S](em: var Emitter; config: ConfigRef; @@ -406,3 +406,16 @@ proc main() = discard main() + +type + TCallingConvention* = enum + ccDefault, # proc has no explicit calling convention + ccStdCall, # procedure is stdcall + ccCDecl, # cdecl + ccSafeCall, # safecall + ccSysCall, # system call + ccInline, # proc should be inlined + ccNoInline, # proc should not be inlined + ccFastCall, # fastcall (pass parameters in registers) + ccClosure, # proc has a closure + ccNoConvention # needed for generating proper C procs sometimes |