diff options
author | Araq <rumpf_a@web.de> | 2012-07-11 18:17:39 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-07-11 18:17:39 +0200 |
commit | b4a9aca2d391f5baa4293444135a98a816ebc043 (patch) | |
tree | ba44c9fb27cd909d18b63bb340ab79411cb62012 /compiler | |
parent | 6074a9c129677cd7846309d02479d7bea684672f (diff) | |
download | Nim-b4a9aca2d391f5baa4293444135a98a816ebc043.tar.gz |
';' now valid for parameter lists
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/parser.nim | 6 | ||||
-rwxr-xr-x | compiler/renderer.nim | 13 |
2 files changed, 12 insertions, 7 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index df31a7df8..194b61f2a 100755 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -629,7 +629,7 @@ proc parseTuple(p: var TParser): PNode = while (p.tok.tokType == tkSymbol) or (p.tok.tokType == tkAccent): var a = parseIdentColonEquals(p, {}) addSon(result, a) - if p.tok.tokType != tkComma: break + if p.tok.tokType notin {tkComma, tkSemicolon}: break getTok(p) optInd(p, a) optPar(p) @@ -652,7 +652,7 @@ proc parseParamList(p: var TParser, retColon = true): PNode = parMessage(p, errTokenExpected, ")") break addSon(result, a) - if p.tok.tokType != tkComma: break + if p.tok.tokType notin {tkComma, tkSemicolon}: break getTok(p) optInd(p, a) optPar(p) @@ -1135,7 +1135,7 @@ proc parseGenericParamList(p: var TParser): PNode = while (p.tok.tokType == tkSymbol) or (p.tok.tokType == tkAccent): var a = parseGenericParam(p) addSon(result, a) - if p.tok.tokType != tkComma: break + if p.tok.tokType notin {tkComma, tkSemicolon}: break getTok(p) optInd(p, a) optPar(p) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 58c60834f..5d8a04198 100755 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -485,14 +485,14 @@ proc putWithSpace(g: var TSrcGen, kind: TTokType, s: string) = put(g, tkSpaces, Space) proc gcommaAux(g: var TSrcGen, n: PNode, ind: int, start: int = 0, - theEnd: int = - 1) = + theEnd: int = - 1, separator = tkComma) = for i in countup(start, sonsLen(n) + theEnd): var c = i < sonsLen(n) + theEnd var sublen = lsub(n.sons[i]) + ord(c) if not fits(g, sublen) and (ind + sublen < maxLineLen): optNL(g, ind) gsub(g, n.sons[i]) if c: - putWithSpace(g, tkComma, ",") + putWithSpace(g, separator, TokTypeToStr[separator]) if hasCom(n.sons[i]): gcoms(g) optNL(g, ind) @@ -512,6 +512,11 @@ proc gcomma(g: var TSrcGen, n: PNode, start: int = 0, theEnd: int = - 1) = if ind > maxLineLen div 2: ind = g.indent + longIndentWid gcommaAux(g, n, ind, start, theEnd) +proc gsemicolon(g: var TSrcGen, n: PNode, start: int = 0, theEnd: int = - 1) = + var ind = g.lineLen + if ind > maxLineLen div 2: ind = g.indent + longIndentWid + gcommaAux(g, n, ind, start, theEnd, tkSemicolon) + proc gsons(g: var TSrcGen, n: PNode, c: TContext, start: int = 0, theEnd: int = - 1) = for i in countup(start, sonsLen(n) + theEnd): gsub(g, n.sons[i], c) @@ -719,7 +724,7 @@ proc gident(g: var TSrcGen, n: PNode) = proc doParamsAux(g: var TSrcGen, params: PNode) = if params.len > 1: put(g, tkParLe, "(") - gcomma(g, params, 1) + gsemicolon(g, params, 1) put(g, tkParRi, ")") if params.sons[0].kind != nkEmpty: @@ -1159,7 +1164,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = put(g, tkBracketRi, "]") of nkFormalParams: put(g, tkParLe, "(") - gcomma(g, n, 1) + gsemicolon(g, n, 1) put(g, tkParRi, ")") if n.sons[0].kind != nkEmpty: putWithSpace(g, tkColon, ":") |