From 3d408420889097a87919fc2f8e9e5de837a35506 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 20 Nov 2012 17:46:11 +0100 Subject: doc2 improvements; small lexer bugfix: backslashes in comments --- compiler/commands.nim | 3 +++ compiler/docgen2.nim | 11 +++++---- compiler/lexer.nim | 1 + compiler/main.nim | 14 +++++++++-- compiler/options.nim | 2 ++ compiler/sempass2.nim | 65 +++++++++++++++++++++++++++------------------------ compiler/semstmts.nim | 4 ++++ compiler/transf.nim | 8 +++++++ doc/advopt.txt | 1 + lib/system.nim | 17 +++++++++----- todo.txt | 9 +------ web/news.txt | 2 ++ web/nimrod.ini | 44 +++++++++++++++++----------------- web/question.txt | 2 +- 14 files changed, 108 insertions(+), 75 deletions(-) diff --git a/compiler/commands.nim b/compiler/commands.nim index b6ef02fe1..50b4a1e6f 100755 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -268,6 +268,9 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) = of "forcebuild", "f": expectNoArg(switch, arg, pass, info) incl(gGlobalOptions, optForceFullMake) + of "project": + expectNoArg(switch, arg, pass, info) + gWholeProject = true of "gc": expectArg(switch, arg, pass, info) case arg.normalize diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim index ba3f5d4ca..2d175adbf 100644 --- a/compiler/docgen2.nim +++ b/compiler/docgen2.nim @@ -23,11 +23,12 @@ type proc close(p: PPassContext, n: PNode): PNode = var g = PGen(p) let useWarning = sfMainModule notin g.module.flags - writeOutput(g.doc, g.filename, HtmlExt, useWarning) - try: - generateIndex(g.doc) - except EIO: - nil + if gWholeProject or sfMainModule in g.module.flags: + writeOutput(g.doc, g.filename, HtmlExt, useWarning) + try: + generateIndex(g.doc) + except EIO: + nil proc processNode(c: PPassContext, n: PNode): PNode = result = n diff --git a/compiler/lexer.nim b/compiler/lexer.nim index faa9fc672..59e367962 100755 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -679,6 +679,7 @@ proc scanComment(L: var TLexer, tok: var TToken) = inc(indent) if buf[pos] == '#' and (col == indent or lastBackslash > 0): tok.literal.add "\n" + col = indent else: if buf[pos] > ' ': L.indentAhead = indent diff --git a/compiler/main.nim b/compiler/main.nim index 26b3c9c4c..9aefa3eb3 100755 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -83,9 +83,19 @@ proc CompileModule(filename: string, flags: TSymFlags): PSym = result.id = getID() processModule(result, f, nil, rd) +proc `==^`(a, b: string): bool = + try: + result = sameFile(a, b) + except EOS: + result = false + proc CompileProject(projectFile = gProjectFull) = - discard CompileModule(options.libpath / "system", {sfSystemModule}) - discard CompileModule(projectFile, {sfMainModule}) + let systemFile = options.libpath / "system" + if projectFile.addFileExt(nimExt) ==^ systemFile.addFileExt(nimExt): + discard CompileModule(projectFile, {sfMainModule, sfSystemModule}) + else: + discard CompileModule(systemFile, {sfSystemModule}) + discard CompileModule(projectFile, {sfMainModule}) proc semanticPasses = registerPass(verbosePass()) diff --git a/compiler/options.nim b/compiler/options.nim index 2051953ce..42fca1ad1 100755 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -95,6 +95,8 @@ var gVerbosity*: int # how verbose the compiler is gNumberOfProcessors*: int # number of processors + gWholeProject*: bool # for 'doc2': output any dependency + const genSubDir* = "nimcache" NimExt* = "nim" diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index c3e2ce8bc..bd8a3ba02 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -9,7 +9,7 @@ import intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees, - wordrecg, strutils + wordrecg, strutils, options # Second semantic checking pass over the AST. Necessary because the old # way had some inherent problems. Performs: @@ -92,30 +92,44 @@ proc excType(n: PNode): PType = let t = if n.kind == nkEmpty: sysTypeFromName"E_Base" else: n.typ result = skipTypes(t, skipPtrs) +proc createRaise(n: PNode): PNode = + result = newNode(nkType) + result.typ = sysTypeFromName"E_Base" + if not n.isNil: result.info = n.info + +proc createTag(n: PNode): PNode = + result = newNode(nkType) + result.typ = sysTypeFromName"TEffect" + if not n.isNil: result.info = n.info + proc addEffect(a: PEffects, e: PNode, useLineInfo=true) = assert e.kind != nkRaiseStmt var aa = a.exc for i in a.bottom ..