diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | compiler/commands.nim | 9 | ||||
-rw-r--r-- | compiler/extccomp.nim | 2 | ||||
-rw-r--r-- | compiler/nimrod.dot | 591 | ||||
-rw-r--r-- | compiler/options.nim | 1 | ||||
-rw-r--r-- | install.txt | 6 | ||||
-rw-r--r-- | lib/packages/docutils/rstgen.nim | 13 | ||||
-rw-r--r-- | lib/pure/asyncio.nim | 7 | ||||
-rw-r--r-- | lib/pure/httpclient.nim | 3 | ||||
-rw-r--r-- | lib/pure/os.nim | 8 | ||||
-rw-r--r-- | lib/pure/unicode.nim | 4 | ||||
-rw-r--r-- | lib/system.nim | 19 | ||||
-rw-r--r-- | tests/showoff/tformatopt.nim | 57 | ||||
-rw-r--r-- | tests/showoff/thello2.nim | 11 | ||||
-rw-r--r-- | tests/showoff/thtml1.nim | 11 | ||||
-rw-r--r-- | tests/showoff/thtml2.nim | 37 | ||||
-rw-r--r-- | tests/showoff/tonce.nim | 22 | ||||
-rw-r--r-- | tests/showoff/tquasiquote.nim | 14 | ||||
-rw-r--r-- | tools/niminst/buildbat.tmpl | 4 | ||||
-rw-r--r-- | tools/niminst/buildsh.tmpl | 4 | ||||
-rw-r--r-- | tools/niminst/niminst.nim | 10 | ||||
-rw-r--r-- | web/community.txt | 2 |
22 files changed, 225 insertions, 611 deletions
diff --git a/.gitignore b/.gitignore index f5719848b..15272385f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ examples/cross_calculator/android/tags # Generated files. /compile.json /compiler/c2nim/c2nim +/compiler/nimrod.dot /compiler/pas2nim/pas2nim /compiler/service /examples/allany diff --git a/compiler/commands.nim b/compiler/commands.nim index 03c71ff5a..7179b07c1 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -1,7 +1,7 @@ # # # The Nimrod Compiler -# (c) Copyright 2013 Andreas Rumpf +# (c) Copyright 2014 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -249,10 +249,13 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = expectArg(switch, arg, pass, info) addPath(processPath(arg), info) of "babelpath": - if pass in {passCmd2, passPP}: + if pass in {passCmd2, passPP} and not options.gNoBabelPath: expectArg(switch, arg, pass, info) let path = processPath(arg, notRelativeToProj=true) - babelPath(path, info) + babelpath(path, info) + of "nobabelpath": + expectNoArg(switch, arg, pass, info) + options.gNoBabelPath = true of "excludepath": expectArg(switch, arg, pass, info) let path = processPath(arg) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 95778941e..12761f1d4 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -614,7 +614,7 @@ proc callCCompiler*(projectfile: string) = exefile = splitFile(projectfile).name & platform.OS[targetOS].exeExt builddll = "" if options.outFile.len > 0: - exefile = options.outFile + exefile = options.outFile.expandTilde if not noAbsolutePaths(): if not exefile.isAbsolute(): exefile = joinPath(splitFile(projectfile).dir, exefile) diff --git a/compiler/nimrod.dot b/compiler/nimrod.dot deleted file mode 100644 index e9663d7c5..000000000 --- a/compiler/nimrod.dot +++ /dev/null @@ -1,591 +0,0 @@ -digraph nimrod { -times -> strutils; -os -> strutils; -os -> times; -posix -> times; -os -> posix; -nhashes -> strutils; -nstrtabs -> os; -nstrtabs -> nhashes; -nstrtabs -> strutils; -options -> os; -options -> lists; -options -> strutils; -options -> nstrtabs; -msgs -> options; -msgs -> strutils; -msgs -> os; -crc -> strutils; -platform -> strutils; -ropes -> msgs; -ropes -> strutils; -ropes -> platform; -ropes -> nhashes; -ropes -> crc; -idents -> nhashes; -idents -> strutils; -ast -> msgs; -ast -> nhashes; -ast -> nversion; -ast -> options; -ast -> strutils; -ast -> crc; -ast -> ropes; -ast -> idents; -ast -> lists; -astalgo -> ast; -astalgo -> nhashes; -astalgo -> strutils; -astalgo -> options; -astalgo -> msgs; -astalgo -> ropes; -astalgo -> idents; -condsyms -> ast; -condsyms -> astalgo; -condsyms -> msgs; -condsyms -> nhashes; -condsyms -> platform; -condsyms -> strutils; -condsyms -> idents; -hashes -> strutils; -strtabs -> os; -strtabs -> hashes; -strtabs -> strutils; -osproc -> strutils; -osproc -> os; -osproc -> strtabs; -osproc -> streams; -osproc -> posix; -extccomp -> lists; -extccomp -> ropes; -extccomp -> os; -extccomp -> strutils; -extccomp -> osproc; -extccomp -> platform; -extccomp -> condsyms; -extccomp -> options; -extccomp -> msgs; -wordrecg -> nhashes; -wordrecg -> strutils; -wordrecg -> idents; -commands -> os; -commands -> msgs; -commands -> options; -commands -> nversion; -commands -> condsyms; -commands -> strutils; -commands -> extccomp; -commands -> platform; -commands -> lists; -commands -> wordrecg; -llstream -> strutils; -lexbase -> llstream; -lexbase -> strutils; -scanner -> nhashes; -scanner -> options; -scanner -> msgs; -scanner -> strutils; -scanner -> platform; -scanner -> idents; -scanner -> lexbase; -scanner -> llstream; -scanner -> wordrecg; -nimconf -> llstream; -nimconf -> nversion; -nimconf -> commands; -nimconf -> os; -nimconf -> strutils; -nimconf -> msgs; -nimconf -> platform; -nimconf -> condsyms; -nimconf -> scanner; -nimconf -> options; -nimconf -> idents; -nimconf -> wordrecg; -pnimsyn -> llstream; -pnimsyn -> scanner; -pnimsyn -> idents; -pnimsyn -> strutils; -pnimsyn -> ast; -pnimsyn -> msgs; -pbraces -> llstream; -pbraces -> scanner; -pbraces -> idents; -pbraces -> strutils; -pbraces -> ast; -pbraces -> msgs; -pbraces -> pnimsyn; -rnimsyn -> scanner; -rnimsyn -> options; -rnimsyn -> idents; -rnimsyn -> strutils; -rnimsyn -> ast; -rnimsyn -> msgs; -rnimsyn -> lists; -filters -> llstream; -filters -> os; -filters -> wordrecg; -filters -> idents; -filters -> strutils; -filters -> ast; -filters -> astalgo; -filters -> msgs; -filters -> options; -filters -> rnimsyn; -ptmplsyn -> llstream; -ptmplsyn -> os; -ptmplsyn -> wordrecg; -ptmplsyn -> idents; -ptmplsyn -> strutils; -ptmplsyn -> ast; -ptmplsyn -> astalgo; -ptmplsyn -> msgs; -ptmplsyn -> options; -ptmplsyn -> rnimsyn; -ptmplsyn -> filters; -syntaxes -> strutils; -syntaxes -> llstream; -syntaxes -> ast; -syntaxes -> astalgo; -syntaxes -> idents; -syntaxes -> scanner; -syntaxes -> options; -syntaxes -> msgs; -syntaxes -> pnimsyn; -syntaxes -> pbraces; -syntaxes -> ptmplsyn; -syntaxes -> filters; -syntaxes -> rnimsyn; -paslex -> nhashes; -paslex -> options; -paslex -> msgs; -paslex -> strutils; -paslex -> platform; -paslex -> idents; -paslex -> lexbase; -paslex -> wordrecg; -paslex -> scanner; -pasparse -> os; -pasparse -> llstream; -pasparse -> scanner; -pasparse -> paslex; -pasparse -> idents; -pasparse -> wordrecg; -pasparse -> strutils; -pasparse -> ast; -pasparse -> astalgo; -pasparse -> msgs; -pasparse -> options; -rodread -> os; -rodread -> options; -rodread -> strutils; -rodread -> nversion; -rodread -> ast; -rodread -> astalgo; -rodread -> msgs; -rodread -> platform; -rodread -> condsyms; -rodread -> ropes; -rodread -> idents; -rodread -> crc; -trees -> ast; -trees -> astalgo; -trees -> scanner; -trees -> msgs; -trees -> strutils; -types -> ast; -types -> astalgo; -types -> trees; -types -> msgs; -types -> strutils; -types -> platform; -magicsys -> ast; -magicsys -> astalgo; -magicsys -> nhashes; -magicsys -> msgs; -magicsys -> platform; -magicsys -> nversion; -magicsys -> times; -magicsys -> idents; -magicsys -> rodread; -nimsets -> ast; -nimsets -> astalgo; -nimsets -> trees; -nimsets -> nversion; -nimsets -> msgs; -nimsets -> platform; -nimsets -> bitsets; -nimsets -> types; -nimsets -> rnimsyn; -passes -> strutils; -passes -> lists; -passes -> options; -passes -> ast; -passes -> astalgo; -passes -> llstream; -passes -> msgs; -passes -> platform; -passes -> os; -passes -> condsyms; -passes -> idents; -passes -> rnimsyn; -passes -> types; -passes -> extccomp; -passes -> math; -passes -> magicsys; -passes -> nversion; -passes -> nimsets; -passes -> syntaxes; -passes -> times; -passes -> rodread; -treetab -> nhashes; -treetab -> ast; -treetab -> astalgo; -treetab -> types; -semdata -> strutils; -semdata -> lists; -semdata -> options; -semdata -> scanner; -semdata -> ast; -semdata -> astalgo; -semdata -> trees; -semdata -> treetab; -semdata -> wordrecg; -semdata -> ropes; -semdata -> msgs; -semdata -> platform; -semdata -> os; -semdata -> condsyms; -semdata -> idents; -semdata -> rnimsyn; -semdata -> types; -semdata -> extccomp; -semdata -> math; -semdata -> magicsys; -semdata -> nversion; -semdata -> nimsets; -semdata -> pnimsyn; -semdata -> times; -semdata -> passes; -semdata -> rodread; -lookups -> ast; -lookups -> astalgo; -lookups -> idents; -lookups -> semdata; -lookups -> types; -lookups -> msgs; -lookups -> options; -lookups -> rodread; -lookups -> rnimsyn; -importer -> strutils; -importer -> os; -importer -> ast; -importer -> astalgo; -importer -> msgs; -importer -> options; -importer -> idents; -importer -> rodread; -importer -> lookups; -importer -> semdata; -importer -> passes; -rodwrite -> os; -rodwrite -> options; -rodwrite -> strutils; -rodwrite -> nversion; -rodwrite -> ast; -rodwrite -> astalgo; -rodwrite -> msgs; -rodwrite -> platform; -rodwrite -> condsyms; -rodwrite -> ropes; -rodwrite -> idents; -rodwrite -> crc; -rodwrite -> rodread; -rodwrite -> passes; -rodwrite -> importer; -semfold -> strutils; -semfold -> lists; -semfold -> options; -semfold -> ast; -semfold -> astalgo; -semfold -> trees; -semfold -> treetab; -semfold -> nimsets; -semfold -> times; -semfold -> nversion; -semfold -> platform; -semfold -> math; -semfold -> msgs; -semfold -> os; -semfold -> condsyms; -semfold -> idents; -semfold -> rnimsyn; -semfold -> types; -evals -> strutils; -evals -> magicsys; -evals -> lists; -evals -> options; -evals -> ast; -evals -> astalgo; -evals -> trees; -evals -> treetab; -evals -> nimsets; -evals -> msgs; -evals -> os; -evals -> condsyms; -evals -> idents; -evals -> rnimsyn; -evals -> types; -evals -> passes; -evals -> semfold; -procfind -> ast; -procfind -> astalgo; -procfind -> msgs; -procfind -> semdata; -procfind -> types; -procfind -> trees; -pragmas -> os; -pragmas -> platform; -pragmas -> condsyms; -pragmas -> ast; -pragmas -> astalgo; -pragmas -> idents; -pragmas -> semdata; -pragmas -> msgs; -pragmas -> rnimsyn; -pragmas -> wordrecg; -pragmas -> ropes; -pragmas -> options; -pragmas -> strutils; -pragmas -> lists; -pragmas -> extccomp; -pragmas -> math; -pragmas -> magicsys; -pragmas -> trees; -sem -> strutils; -sem -> nhashes; -sem -> lists; -sem -> options; -sem -> scanner; -sem -> ast; -sem -> astalgo; -sem -> trees; -sem -> treetab; -sem -> wordrecg; -sem -> ropes; -sem -> msgs; -sem -> os; -sem -> condsyms; -sem -> idents; -sem -> rnimsyn; -sem -> types; -sem -> platform; -sem -> math; -sem -> magicsys; -sem -> pnimsyn; -sem -> nversion; -sem -> nimsets; -sem -> semdata; -sem -> evals; -sem -> semfold; -sem -> importer; -sem -> procfind; -sem -> lookups; -sem -> rodread; -sem -> pragmas; -sem -> passes; -rst -> os; -rst -> msgs; -rst -> strutils; -rst -> platform; -rst -> nhashes; -rst -> ropes; -rst -> options; -highlite -> nhashes; -highlite -> options; -highlite -> msgs; -highlite -> strutils; -highlite -> platform; -highlite -> idents; -highlite -> lexbase; -highlite -> wordrecg; -highlite -> scanner; -docgen -> ast; -docgen -> astalgo; -docgen -> strutils; -docgen -> nhashes; -docgen -> options; -docgen -> nversion; -docgen -> msgs; -docgen -> os; -docgen -> ropes; -docgen -> idents; -docgen -> wordrecg; -docgen -> math; -docgen -> syntaxes; -docgen -> rnimsyn; -docgen -> scanner; -docgen -> rst; -docgen -> times; -docgen -> highlite; -ccgutils -> ast; -ccgutils -> astalgo; -ccgutils -> ropes; -ccgutils -> lists; -ccgutils -> nhashes; -ccgutils -> strutils; -ccgutils -> types; -ccgutils -> msgs; -cgmeth -> options; -cgmeth -> ast; -cgmeth -> astalgo; -cgmeth -> msgs; -cgmeth -> idents; -cgmeth -> rnimsyn; -cgmeth -> types; -cgmeth -> magicsys; -cgen -> ast; -cgen -> astalgo; -cgen -> strutils; -cgen -> nhashes; -cgen -> trees; -cgen -> platform; -cgen -> magicsys; -cgen -> extccomp; -cgen -> options; -cgen -> nversion; -cgen -> nimsets; -cgen -> msgs; -cgen -> crc; -cgen -> bitsets; -cgen -> idents; -cgen -> lists; -cgen -> types; -cgen -> ccgutils; -cgen -> os; -cgen -> times; -cgen -> ropes; -cgen -> math; -cgen -> passes; -cgen -> rodread; -cgen -> wordrecg; -cgen -> rnimsyn; -cgen -> treetab; -cgen -> cgmeth; -jsgen -> ast; -jsgen -> astalgo; -jsgen -> strutils; -jsgen -> nhashes; -jsgen -> trees; -jsgen -> platform; -jsgen -> magicsys; -jsgen -> extccomp; -jsgen -> options; -jsgen -> nversion; -jsgen -> nimsets; -jsgen -> msgs; -jsgen -> crc; -jsgen -> bitsets; -jsgen -> idents; -jsgen -> lists; -jsgen -> types; -jsgen -> os; -jsgen -> times; -jsgen -> ropes; -jsgen -> math; -jsgen -> passes; -jsgen -> ccgutils; -jsgen -> wordrecg; -jsgen -> rnimsyn; -jsgen -> rodread; -interact -> llstream; -interact -> strutils; -interact -> ropes; -interact -> nstrtabs; -interact -> msgs; -passaux -> strutils; -passaux -> ast; -passaux -> astalgo; -passaux -> passes; -passaux -> msgs; -passaux -> options; -depends -> os; -depends -> options; -depends -> ast; -depends -> astalgo; -depends -> msgs; -depends -> ropes; -depends -> idents; -depends -> passes; -depends -> importer; -transf -> strutils; -transf -> lists; -transf -> options; -transf -> ast; -transf -> astalgo; -transf -> trees; -transf -> treetab; -transf -> evals; -transf -> msgs; -transf -> os; -transf -> idents; -transf -> rnimsyn; -transf -> types; -transf -> passes; -transf -> semfold; -transf -> magicsys; -transf -> cgmeth; -main -> llstream; -main -> strutils; -main -> ast; -main -> astalgo; -main -> scanner; -main -> syntaxes; -main -> rnimsyn; -main -> options; -main -> msgs; -main -> os; -main -> lists; -main -> condsyms; -main -> paslex; -main -> pasparse; -main -> rodread; -main -> rodwrite; -main -> ropes; -main -> trees; -main -> wordrecg; -main -> sem; -main -> semdata; -main -> idents; -main -> passes; -main -> docgen; -main -> extccomp; -main -> cgen; -main -> jsgen; -main -> platform; -main -> interact; -main -> nimconf; -main -> importer; -main -> passaux; -main -> depends; -main -> transf; -main -> evals; -main -> types; -parseopt -> os; -parseopt -> strutils; -nimrod -> times; -nimrod -> commands; -nimrod -> scanner; -nimrod -> condsyms; -nimrod -> options; -nimrod -> msgs; -nimrod -> nversion; -nimrod -> nimconf; -nimrod -> ropes; -nimrod -> extccomp; -nimrod -> strutils; -nimrod -> os; -nimrod -> platform; -nimrod -> main; -nimrod -> parseopt; -} diff --git a/compiler/options.nim b/compiler/options.nim index 9b0cbf0c9..4f642e626 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -111,6 +111,7 @@ var gDirtyBufferIdx* = 0'i32 # indicates the fileIdx of the dirty version of # the tracked source X, saved by the CAAS client. gDirtyOriginalIdx* = 0'i32 # the original source file of the dirtified buffer. + gNoBabelPath* = false proc importantComments*(): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools} proc usesNativeGC*(): bool {.inline.} = gSelectedGC >= gcRefc diff --git a/install.txt b/install.txt index 11c502235..2883c8495 100644 --- a/install.txt +++ b/install.txt @@ -62,3 +62,9 @@ Currently, the following C compilers are supported under Windows: | http://www.digitalmars.com/download/freecompiler.html However, most testing is done with GCC. + +Bootstrapping from Github +------------------------- + +Take a look at the readme file on github `here <https://github.com/Araq/Nimrod#readme>`_ +for instructions. diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 5afd70319..a56f62448 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -699,7 +699,18 @@ proc formatNamedVars*(frmt: string, varnames: openArray[string], proc defaultConfig*(): PStringTable = - ## creates a default configuration for HTML generation. + ## Returns a default configuration for embedded HTML generation. + ## + ## The returned ``PStringTable`` contains the paramters used by the HTML + ## engine to build the final output. For information on what these parameters + ## are and their purpose, please look up the file ``config/nimdoc.cfg`` + ## bundled with the compiler. + ## + ## The only difference between the contents of that file and the values + ## provided by this proc is the ``doc.file`` variable. The ``doc.file`` + ## variable of the configuration file contains HTML to build standalone + ## pages, while this proc returns just the content for procs like + ## ``rstToHtml`` to generate the bare minimum HTML. result = newStringTable(modeStyleInsensitive) template setConfigVar(key, val: expr) = diff --git a/lib/pure/asyncio.nim b/lib/pure/asyncio.nim index c4a07d751..3c2a5c17a 100644 --- a/lib/pure/asyncio.nim +++ b/lib/pure/asyncio.nim @@ -233,8 +233,11 @@ proc asyncSockHandleWrite(h: PObject) = let sock = PAsyncSocket(h) try: let bytesSent = sock.socket.sendAsync(sock.sendBuffer) - assert bytesSent > 0 - if bytesSent != sock.sendBuffer.len: + if bytesSent == 0: + # Apparently the socket cannot be written to. Even though select + # just told us that it can be... This used to be an assert. Just + # do nothing instead. + elif bytesSent != sock.sendBuffer.len: sock.sendBuffer = sock.sendBuffer[bytesSent .. -1] elif bytesSent == sock.sendBuffer.len: sock.sendBuffer = "" diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 2c0e7b835..bb9835fe7 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -220,9 +220,8 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse = inc(linei, le) if line[linei] != ':': httpError("invalid headers") inc(linei) # Skip : - linei += skipWhitespace(line, linei) - result.headers[name] = line[linei.. -1] + result.headers[name] = line[linei.. -1].strip() if not fullyRead: httpError("Connection was closed before full request has been made") if getBody: diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 504343d67..448ecc1e3 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -387,6 +387,14 @@ proc existsDir*(dir: string): bool {.rtl, extern: "nos$1", tags: [FReadDir].} = var res: TStat return stat(dir, res) >= 0'i32 and S_ISDIR(res.st_mode) +proc fileExists*(filename: string): bool {.inline.} = + ## Synonym for existsFile + existsFile(filename) + +proc dirExists*(dir: string): bool {.inline.} = + ## Synonym for existsDir + existsDir(dir) + proc getLastModificationTime*(file: string): TTime {.rtl, extern: "nos$1".} = ## Returns the `file`'s last modification time. when defined(posix): diff --git a/lib/pure/unicode.nim b/lib/pure/unicode.nim index 37a64a8f3..6e73eea3f 100644 --- a/lib/pure/unicode.nim +++ b/lib/pure/unicode.nim @@ -132,6 +132,10 @@ proc toUTF8*(c: TRune): string {.rtl, extern: "nuc$1".} = result = newString(1) result[0] = chr(i) +proc `$`*(rune: TRune): string = + ## converts a rune to a string + rune.toUTF8 + proc `$`*(runes: seq[TRune]): string = ## converts a sequence of runes to a string result = "" diff --git a/lib/system.nim b/lib/system.nim index 70c8a529a..75bebf702 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2708,7 +2708,23 @@ proc locals*(): TObject {.magic: "Locals", noSideEffect.} = ## in the current scope. This is quite fast as it does not rely ## on any debug or runtime information. Note that in constrast to what ## the official signature says, the return type is not ``TObject`` but a - ## tuple of a structure that depends on the current scope. + ## tuple of a structure that depends on the current scope. Example: + ## + ## .. code-block:: nimrod + ## proc testLocals() = + ## var + ## a = "something" + ## b = 4 + ## c = locals() + ## d = "super!" + ## + ## b = 1 + ## for name, value in fieldPairs(c): + ## echo "name ", name, " with value ", value + ## echo "B is ", b + ## # -> name a with value something + ## # -> name b with value 4 + ## # -> B is 1 discard when not defined(booting): @@ -2719,4 +2735,3 @@ when not defined(booting): template isStatic*(x): expr = compiles(static(x)) # checks whether `x` is a value known at compile-time - diff --git a/tests/showoff/tformatopt.nim b/tests/showoff/tformatopt.nim new file mode 100644 index 000000000..f33ed6921 --- /dev/null +++ b/tests/showoff/tformatopt.nim @@ -0,0 +1,57 @@ +discard """ + output: '''(a: 3 +b: 4 +s: abc +)''' +""" + +import macros + +proc invalidFormatString() = + echo "invalidFormatString" + +template formatImpl(handleChar: expr) = + var i = 0 + while i < f.len: + if f[i] == '$': + case f[i+1] + of '1'..'9': + var j = 0 + i += 1 + while f[i] in {'0'..'9'}: + j = j * 10 + ord(f[i]) - ord('0') + i += 1 + result.add(a[j-1]) + else: + invalidFormatString() + else: + result.add(handleChar(f[i])) + i += 1 + +proc `%`*(f: string, a: openArray[string]): string = + template identity(x: expr): expr = x + result = "" + formatImpl(identity) + +macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): expr = + result = newNimNode(nnkBracket) + let f = f.strVal + formatImpl(newLit) + result = nestList(!"&", result) + +template optAdd1{x = y; add(x, z)}(x, y, z: string) = + x = y & z + +proc `/&` [T: object](x: T): string = + result = "(" + for name, value in fieldPairs(x): + result.add("$1: $2\n" % [name, $value]) + result.add(")") + +type + MyObject = object + a, b: int + s: string + +let obj = MyObject(a: 3, b: 4, s: "abc") +echo(/&obj) diff --git a/tests/showoff/thello2.nim b/tests/showoff/thello2.nim new file mode 100644 index 000000000..d2e2f6227 --- /dev/null +++ b/tests/showoff/thello2.nim @@ -0,0 +1,11 @@ +discard """ + output: '''(a: 3, b: 4, s: abc)''' +""" + +type + MyObject = object + a, b: int + s: string + +let obj = MyObject(a: 3, b: 4, s: "abc") +echo obj diff --git a/tests/showoff/thtml1.nim b/tests/showoff/thtml1.nim new file mode 100644 index 000000000..cd95c7971 --- /dev/null +++ b/tests/showoff/thtml1.nim @@ -0,0 +1,11 @@ +discard """ + output: "<br>" +""" + +template htmlTag(tag: expr) {.immediate.} = + proc tag(): string = "<" & astToStr(tag) & ">" + +htmlTag(br) +htmlTag(html) + +echo br() diff --git a/tests/showoff/thtml2.nim b/tests/showoff/thtml2.nim new file mode 100644 index 000000000..8a451ebf1 --- /dev/null +++ b/tests/showoff/thtml2.nim @@ -0,0 +1,37 @@ +discard """ + output: "<html><head><title>now look at this</title></head><body><ul><li>Nimrod is quite capable</li></ul></body></html>" +""" + +import strutils + +template html(name: expr, matter: stmt) {.immediate.} = + proc name(): string = + result = "<html>" + matter + result.add("</html>") + +template nestedTag(tag: expr) {.immediate.} = + template tag(matter: stmt) {.immediate.} = + result.add("<" & astToStr(tag) & ">") + matter + result.add("</" & astToStr(tag) & ">") + +template simpleTag(tag: expr) {.immediate.} = + template tag(matter: expr) {.immediate.} = + result.add("<$1>$2</$1>" % [astToStr(tag), matter]) + +nestedTag body +nestedTag head +nestedTag ul +simpleTag title +simpleTag li + + +html mainPage: + head: + title "now look at this" + body: + ul: + li "Nimrod is quite capable" + +echo mainPage() diff --git a/tests/showoff/tonce.nim b/tests/showoff/tonce.nim new file mode 100644 index 000000000..6fc372e87 --- /dev/null +++ b/tests/showoff/tonce.nim @@ -0,0 +1,22 @@ +discard """ + output: '''first call of p +some call of p +new instantiation +some call of p''' +""" + +template once(body: stmt) = + var x {.global.} = false + if not x: + x = true + body + +proc p() = + once: + echo "first call of p" + echo "some call of p" + +p() +once: + echo "new instantiation" +p() diff --git a/tests/showoff/tquasiquote.nim b/tests/showoff/tquasiquote.nim new file mode 100644 index 000000000..df7fccc33 --- /dev/null +++ b/tests/showoff/tquasiquote.nim @@ -0,0 +1,14 @@ +discard """ + outputsub: '''tquasiquote.nim(14,8): Check failed: 1 > 2''' +""" + +import macros + +macro check(ex: expr): stmt = + var info = ex.lineInfo + var expString = ex.toStrLit + result = quote do: + if not `ex`: + echo `info`, ": Check failed: ", `expString` + +check 1 > 2 diff --git a/tools/niminst/buildbat.tmpl b/tools/niminst/buildbat.tmpl index ca76b0ef2..9a19fc70b 100644 --- a/tools/niminst/buildbat.tmpl +++ b/tools/niminst/buildbat.tmpl @@ -17,8 +17,8 @@ REM call the compiler: # var linkCmd = "" # for ff in items(c.cfiles[winIndex][cpuIndex]): # let f = ff.toWin -ECHO %CC% %COMP_FLAGS% -Inimcache -c ?{f} -o ?{changeFileExt(f, "o")} -%CC% %COMP_FLAGS% -Inimcache -c ?{f} -o ?{changeFileExt(f, "o")} +ECHO %CC% %COMP_FLAGS% -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")} +%CC% %COMP_FLAGS% -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")} # linkCmd.add(" " & changeFileExt(f, "o")) # end for diff --git a/tools/niminst/buildsh.tmpl b/tools/niminst/buildsh.tmpl index 37ea35bd3..4966af07a 100644 --- a/tools/niminst/buildsh.tmpl +++ b/tools/niminst/buildsh.tmpl @@ -128,8 +128,8 @@ case $myos in # var linkCmd = "" # for ff in items(c.cfiles[osA][cpuA]): # let f = ff.toUnix - echo "$CC $COMP_FLAGS -Inimcache -c ?{f} -o ?{changeFileExt(f, "o")}" - $CC $COMP_FLAGS -Inimcache -c ?{f} -o ?{changeFileExt(f, "o")} + echo "$CC $COMP_FLAGS -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")}" + $CC $COMP_FLAGS -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")} # add(linkCmd, " \\\n" & changeFileExt(f, "o")) # end for echo "$LINKER -o ?{"$binDir/" & toLower(c.name)} ?linkCmd $LINK_FLAGS" diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim index da0815aa2..bf8a7a84f 100644 --- a/tools/niminst/niminst.nim +++ b/tools/niminst/niminst.nim @@ -392,7 +392,7 @@ proc readCFiles(c: var TConfigData, osA, cpuA: int) = quit("Cannot open: " & f) proc buildDir(os, cpu: int): string = - return "nimcache" / ($os & "_" & $cpu) + return "c_code" / ($os & "_" & $cpu) proc getOutputDir(c: var TConfigData): string = if c.outdir.len > 0: c.outdir else: "build" @@ -432,11 +432,11 @@ proc writeInstallScripts(c: var TConfigData) = writeFile(deinstallShFile, generateDeinstallScript(c), "\10") proc srcdist(c: var TConfigData) = - if not existsDir(getOutputDir(c) / "nimcache"): - createDir(getOutputDir(c) / "nimcache") + if not existsDir(getOutputDir(c) / "c_code"): + createDir(getOutputDir(c) / "c_code") for x in walkFiles(c.libpath / "lib/*.h"): - echo(getOutputDir(c) / "nimcache" / extractFilename(x)) - copyFile(dest=getOutputDir(c) / "nimcache" / extractFilename(x), source=x) + echo(getOutputDir(c) / "c_code" / extractFilename(x)) + copyFile(dest=getOutputDir(c) / "c_code" / extractFilename(x), source=x) var winIndex = -1 var intel32Index = -1 var intel64Index = -1 diff --git a/web/community.txt b/web/community.txt index 6e2306f8f..b9a0a4196 100644 --- a/web/community.txt +++ b/web/community.txt @@ -9,6 +9,8 @@ Bug reports: http://github.com/Araq/Nimrod/issues. For quickest feedback, join our IRC channel: irc://irc.freenode.net/nimrod (logs at `<http://build.nimrod-code.org/irclogs/>`_). +Check out our Twitter account for latest news and announcements: `@nimrodlang <http://twitter.com/nimrodlang>`_. + How to help =========== |