diff options
Diffstat (limited to 'rod')
-rwxr-xr-x | rod/docgen.nim | 47 | ||||
-rwxr-xr-x | rod/pas2nim/pas2nim.cfg | 4 | ||||
-rwxr-xr-x | rod/scanner.nim | 6 | ||||
-rwxr-xr-x | rod/wordrecg.nim | 6 |
4 files changed, 27 insertions, 36 deletions
diff --git a/rod/docgen.nim b/rod/docgen.nim index 711848e5f..3a7ef14d8 100755 --- a/rod/docgen.nim +++ b/rod/docgen.nim @@ -91,20 +91,19 @@ proc initIndexFile(d: PDoc) = addSon(d.indexFile, h) proc newDocumentor(filename: string): PDoc = - var s: string new(result) result.tocPart = @ [] result.filename = filename result.id = 100 result.splitAfter = 20 - s = getConfigVar("split.item.toc") + var s = getConfigVar("split.item.toc") if s != "": result.splitAfter = parseInt(s) proc getVarIdx(varnames: openarray[string], id: string): int = for i in countup(0, high(varnames)): if cmpIgnoreStyle(varnames[i], id) == 0: return i - result = - 1 + result = -1 proc ropeFormatNamedVars(frmt: TFormatStr, varnames: openarray[string], varvalues: openarray[PRope]): PRope = @@ -277,12 +276,9 @@ proc genComment(d: PDoc, n: PNode): PRope = result = renderRstToOut(d, rstParse(n.comment, true, toFilename(n.info), toLineNumber(n.info), toColumn(n.info), dummyHasToc)) - else: - result = nil proc genRecComment(d: PDoc, n: PNode): PRope = - if n == nil: - return nil + if n == nil: return nil result = genComment(d, n) if result == nil: if not (n.kind in {nkEmpty..nkNilLit}): @@ -293,11 +289,10 @@ proc genRecComment(d: PDoc, n: PNode): PRope = n.comment = nil proc isVisible(n: PNode): bool = - var v: PIdent result = false if n.kind == nkPostfix: if (sonsLen(n) == 2) and (n.sons[0].kind == nkIdent): - v = n.sons[0].ident + var v = n.sons[0].ident result = (v.id == ord(wStar)) or (v.id == ord(wMinus)) elif n.kind == nkSym: result = sfInInterface in n.sym.flags @@ -388,14 +383,11 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = setIndexForSourceTerm(d, getRstName(nameNode), d.id) proc renderHeadline(d: PDoc, n: PRstNode): PRope = - var - length: int - refname: PRope result = nil for i in countup(0, rsonsLen(n) - 1): app(result, renderRstToOut(d, n.sons[i])) - refname = toRope(rstnodeToRefname(n)) + var refname = toRope(rstnodeToRefname(n)) if d.hasToc: - length = len(d.tocPart) + var length = len(d.tocPart) setlen(d.tocPart, length + 1) d.tocPart[length].refname = refname d.tocPart[length].n = n @@ -424,8 +416,8 @@ proc renderOverline(d: PDoc, n: PRstNode): PRope = proc renderRstToRst(d: PDoc, n: PRstNode): PRope proc renderRstSons(d: PDoc, n: PRstNode): PRope = - result = nil - for i in countup(0, rsonsLen(n) - 1): app(result, renderRstToRst(d, n.sons[i])) + for i in countup(0, rsonsLen(n) - 1): + app(result, renderRstToRst(d, n.sons[i])) proc renderRstToRst(d: PDoc, n: PRstNode): PRope = # this is needed for the index generation; it may also be useful for @@ -612,9 +604,8 @@ proc renderCodeBlock(d: PDoc, n: PRstNode): PRope = [result]) proc renderContainer(d: PDoc, n: PRstNode): PRope = - var arg: PRope result = renderRstToOut(d, n.sons[2]) - arg = toRope(strip(getArgument(n))) + var arg = toRope(strip(getArgument(n))) if arg == nil: result = dispF("<div>$1</div>", "$1", [result]) else: result = dispF("<div class=\"$1\">$2</div>", "$2", [arg, result]) @@ -874,12 +865,9 @@ proc generateIndex(d: PDoc) = writeRope(renderRstToRst(d, d.indexFile), gIndexFile) proc CommandDoc(filename: string) = - var - ast: PNode - d: PDoc - ast = parseFile(addFileExt(filename, nimExt)) + var ast = parseFile(addFileExt(filename, nimExt)) if ast == nil: return - d = newDocumentor(filename) + var d = newDocumentor(filename) initIndexFile(d) d.hasToc = true generateDoc(d, ast) @@ -887,17 +875,12 @@ proc CommandDoc(filename: string) = generateIndex(d) proc CommandRstAux(filename, outExt: string) = - var - filen: string - d: PDoc - rst: PRstNode - code: PRope - filen = addFileExt(filename, "txt") - d = newDocumentor(filen) + var filen = addFileExt(filename, "txt") + var d = newDocumentor(filen) initIndexFile(d) - rst = rstParse(readFile(filen), false, filen, 0, 1, d.hasToc) + var rst = rstParse(readFile(filen), false, filen, 0, 1, d.hasToc) d.modDesc = renderRstToOut(d, rst) - code = genOutFile(d) + var code = genOutFile(d) writeRope(code, getOutFile(filename, outExt)) generateIndex(d) diff --git a/rod/pas2nim/pas2nim.cfg b/rod/pas2nim/pas2nim.cfg new file mode 100755 index 000000000..789e6ec7f --- /dev/null +++ b/rod/pas2nim/pas2nim.cfg @@ -0,0 +1,4 @@ +# Use the modules of the compiler + +path: "$nimrod/rod" + diff --git a/rod/scanner.nim b/rod/scanner.nim index dd6bedac4..9367208da 100755 --- a/rod/scanner.nim +++ b/rod/scanner.nim @@ -46,7 +46,8 @@ type # i = i + 1 #cog.out(idents) #]]] - tkAddr, tkAnd, tkAs, tkAsm, tkBind, tkBlock, tkBreak, tkCase, tkCast, + tkAddr, tkAnd, tkAs, tkAsm, tkAtomic, + tkBind, tkBlock, tkBreak, tkCase, tkCast, tkConst, tkContinue, tkConverter, tkDiscard, tkDistinct, tkDiv, tkElif, tkElse, tkEnd, tkEnum, tkExcept, tkFinally, tkFor, tkFrom, tkGeneric, tkIf, tkImplies, tkImport, tkIn, tkInclude, tkIs, tkIsnot, tkIterator, tkLambda, @@ -77,7 +78,8 @@ const "tkSymbol", #[[[cog #cog.out(strings) #]]] - "addr", "and", "as", "asm", "bind", "block", "break", "case", "cast", + "addr", "and", "as", "asm", "atomic", + "bind", "block", "break", "case", "cast", "const", "continue", "converter", "discard", "distinct", "div", "elif", "else", "end", "enum", "except", "finally", "for", "from", "generic", "if", "implies", "import", "in", "include", "is", "isnot", "iterator", "lambda", diff --git a/rod/wordrecg.nim b/rod/wordrecg.nim index b090d5a35..1d078dfcc 100755 --- a/rod/wordrecg.nim +++ b/rod/wordrecg.nim @@ -22,7 +22,8 @@ type TSpecialWord* = enum wInvalid, - wAddr, wAnd, wAs, wAsm, wBind, wBlock, wBreak, wCase, wCast, wConst, + wAddr, wAnd, wAs, wAsm, wAtomic, + wBind, wBlock, wBreak, wCase, wCast, wConst, wContinue, wConverter, wDiscard, wDistinct, wDiv, wElif, wElse, wEnd, wEnum, wExcept, wFinally, wFor, wFrom, wGeneric, wIf, wImplies, wImport, wIn, wInclude, wIs, wIsnot, wIterator, wLambda, wMacro, wMethod, wMod, wNil, @@ -62,7 +63,8 @@ const oprHigh* = ord(wHat) specialWords*: array[low(TSpecialWord)..high(TSpecialWord), string] = ["", - "addr", "and", "as", "asm", "bind", "block", "break", "case", "cast", + "addr", "and", "as", "asm", "atomic", + "bind", "block", "break", "case", "cast", "const", "continue", "converter", "discard", "distinct", "div", "elif", "else", "end", "enum", "except", "finally", "for", "from", "generic", "if", "implies", "import", "in", "include", "is", "isnot", "iterator", "lambda", |