This commit is contained in:
Andreas Rumpf 2016-07-15 15:40:26 +02:00
commit 11b499f3ca
2 changed files with 23 additions and 4 deletions

View file

@ -686,11 +686,19 @@ proc primarySuffix(p: var TParser, r: PNode, baseIndent: int): PNode =
#| | '{' optInd indexExprList optPar '}' #| | '{' optInd indexExprList optPar '}'
#| | &( '`'|IDENT|literal|'cast'|'addr'|'type') expr # command syntax #| | &( '`'|IDENT|literal|'cast'|'addr'|'type') expr # command syntax
result = r result = r
template somePar() =
if p.tok.strongSpaceA > 0:
if p.strongSpaces:
break
else:
parMessage(p, warnDeprecated,
"a [b] will be parsed as command syntax; spacing")
while p.tok.indent < 0 or while p.tok.indent < 0 or
(p.tok.tokType == tkDot and p.tok.indent >= baseIndent): (p.tok.tokType == tkDot and p.tok.indent >= baseIndent):
case p.tok.tokType case p.tok.tokType
of tkParLe: of tkParLe:
if p.strongSpaces and p.tok.strongSpaceA > 0: break somePar()
result = namedParams(p, result, nkCall, tkParRi) result = namedParams(p, result, nkCall, tkParRi)
if result.len > 1 and result.sons[1].kind == nkExprColonExpr: if result.len > 1 and result.sons[1].kind == nkExprColonExpr:
result.kind = nkObjConstr result.kind = nkObjConstr
@ -705,10 +713,10 @@ proc primarySuffix(p: var TParser, r: PNode, baseIndent: int): PNode =
result = dotExpr(p, result) result = dotExpr(p, result)
result = parseGStrLit(p, result) result = parseGStrLit(p, result)
of tkBracketLe: of tkBracketLe:
if p.strongSpaces and p.tok.strongSpaceA > 0: break somePar()
result = namedParams(p, result, nkBracketExpr, tkBracketRi) result = namedParams(p, result, nkBracketExpr, tkBracketRi)
of tkCurlyLe: of tkCurlyLe:
if p.strongSpaces and p.tok.strongSpaceA > 0: break somePar()
result = namedParams(p, result, nkCurlyExpr, tkCurlyRi) result = namedParams(p, result, nkCurlyExpr, tkCurlyRi)
of tkSymbol, tkAccent, tkIntLit..tkCharLit, tkNil, tkCast, tkAddr, tkType: of tkSymbol, tkAccent, tkIntLit..tkCharLit, tkNil, tkCast, tkAddr, tkType:
if p.inPragma == 0: if p.inPragma == 0:

View file

@ -17,7 +17,18 @@ Changes affecting backwards compatibility
no longer strips and splits characters out of the target string no longer strips and splits characters out of the target string
by the entire set of characters. Instead, it now behaves in a by the entire set of characters. Instead, it now behaves in a
similar fashion to ``split`` with ``string`` and ``char`` similar fashion to ``split`` with ``string`` and ``char``
delimiters. delimiters. Use ``splitWhitespace`` to get the old behaviour.
- The command invocation syntax will soon apply to open brackets
and curlies too. This means that code like ``a [i]`` will be
interpreted as ``a([i])`` and not as ``a[i]`` anymore. Likewise
``f (a, b)`` means that the tuple ``(a, b)`` is passed to ``f``.
The compiler produces a warning for ``a [i]``::
Warning: a [b] will be parsed as command syntax; spacing is deprecated
See `https://github.com/nim-lang/Nim/issues/3898`_ for the relevant
discussion.
Library Additions Library Additions
----------------- -----------------