mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
';' as statement separator
This commit is contained in:
@@ -1481,7 +1481,7 @@ proc parseStmt(p: var TParser): PNode =
|
||||
getTok(p)
|
||||
while true:
|
||||
case p.tok.tokType
|
||||
of tkSad: getTok(p)
|
||||
of tkSad, tkSemicolon: getTok(p)
|
||||
of tkEof: break
|
||||
of tkDed:
|
||||
getTok(p)
|
||||
@@ -1494,16 +1494,17 @@ proc parseStmt(p: var TParser): PNode =
|
||||
break
|
||||
addSon(result, a)
|
||||
popInd(p.lex)
|
||||
else:
|
||||
else:
|
||||
# the case statement is only needed for better error messages:
|
||||
case p.tok.tokType
|
||||
of tkIf, tkWhile, tkCase, tkTry, tkFor, tkBlock, tkAsm, tkProc, tkIterator,
|
||||
tkMacro, tkType, tkConst, tkWhen, tkVar:
|
||||
of tkIf, tkWhile, tkCase, tkTry, tkFor, tkBlock, tkAsm, tkProc, tkIterator,
|
||||
tkMacro, tkType, tkConst, tkWhen, tkVar:
|
||||
parMessage(p, errComplexStmtRequiresInd)
|
||||
result = ast.emptyNode
|
||||
else:
|
||||
else:
|
||||
result = simpleStmt(p)
|
||||
if result.kind == nkEmpty: parMessage(p, errExprExpected, p.tok)
|
||||
if p.tok.tokType == tkSemicolon: getTok(p)
|
||||
if p.tok.tokType == tkSad: getTok(p)
|
||||
|
||||
proc parseAll(p: var TParser): PNode =
|
||||
@@ -1522,7 +1523,7 @@ proc parseTopLevelStmt(p: var TParser): PNode =
|
||||
result = ast.emptyNode
|
||||
while true:
|
||||
case p.tok.tokType
|
||||
of tkSad: getTok(p)
|
||||
of tkSad, tkSemicolon: getTok(p)
|
||||
of tkDed, tkInd:
|
||||
parMessage(p, errInvalidIndentation)
|
||||
getTok(p)
|
||||
|
||||
@@ -614,11 +614,11 @@ Nimrod requires `interval arithmetic`:idx: for subrange types over a set
|
||||
of built-in operators that involve constants: ``x mod 3`` is of
|
||||
type ``range[0..2]``. The following built-in operators for integers are
|
||||
affected by this rule: ``-``, ``+``, ``*``, ``min``, ``max``, ``succ``,
|
||||
``pred``, ``mod``, ``div``, ``and`` (bitwise and).
|
||||
``pred``, ``mod``, ``div``, ``and`` (bitwise ``and``).
|
||||
|
||||
Bitwise and only produces a ``range`` if one of its operands is a
|
||||
Bitwise ``and`` only produces a ``range`` if one of its operands is a
|
||||
constant *x* so that (x+1) is a number of two.
|
||||
(Bitwise and then behaves as a ``mod`` operation.)
|
||||
(Bitwise ``and`` is then a ``mod`` operation.)
|
||||
|
||||
This means that the following code is accepted:
|
||||
|
||||
|
||||
3
todo.txt
3
todo.txt
@@ -15,7 +15,6 @@ New pragmas:
|
||||
- document destructors
|
||||
|
||||
- ``borrow`` needs to take type classes into account
|
||||
- introduce ``;`` to the parser: inc a; inc b
|
||||
- make use of ``tyIter`` to fix the implicit items/pairs issue
|
||||
- ``=`` should be overloadable; requires specialization for ``=``
|
||||
- optimize genericAssign in the code generator
|
||||
@@ -38,6 +37,8 @@ Bugs
|
||||
|
||||
- bug: pragma statements in combination with symbol files are evaluated twice
|
||||
but this can lead to compilation errors
|
||||
- bug: the parser is not strict enough with newlines: 'echo "a" echo "b"'
|
||||
compiles
|
||||
|
||||
|
||||
version 0.9.XX
|
||||
|
||||
@@ -124,12 +124,14 @@ Language Additions
|
||||
allowing for *sigil-like* operators.
|
||||
- Stand-alone ``finally`` and ``except`` blocks are now supported.
|
||||
- Macros and templates can now be invoked as pragmas.
|
||||
- The apostrophe in type suffixes for numerical literal is now optional.
|
||||
- The apostrophe in type suffixes for numerical literals is now optional.
|
||||
- Unsigned integer types have been added.
|
||||
- The integer promotion rules changed.
|
||||
- Nimrod now tracks proper intervals for ``range`` over some built-in operators.
|
||||
- In parameter lists a semicolon instead of a comma can be used to improve
|
||||
readability: ``proc divmod(a, b: int; resA, resB: var int)``.
|
||||
- A semicolon can now be used to have multiple simple statements on a single
|
||||
line: ``inc i; inc j``.
|
||||
|
||||
|
||||
2012-02-09 Version 0.8.14 released
|
||||
|
||||
Reference in New Issue
Block a user