summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-10-06 16:47:15 +0200
committerGitHub <noreply@github.com>2020-10-06 16:47:15 +0200
commit92163fa3304e5b6768a50d36a5243639ce4a2f69 (patch)
treeb7aa2705a4772e8f82d61e765ff9158f7b21b441 /doc
parentacd71dd6bb745eb08f81ab489d635951f8edfcfa (diff)
downloadNim-92163fa3304e5b6768a50d36a5243639ce4a2f69.tar.gz
implements https://github.com/nim-lang/RFCs/issues/258 (#15503)
* implements https://github.com/nim-lang/RFCs/issues/258

* don't be too strict with custom pragma blocks

* cast pragmas: documentation

* added most missing inference query procs to effecttraits.nim
Diffstat (limited to 'doc')
-rw-r--r--doc/grammar.txt22
-rw-r--r--doc/manual.rst8
2 files changed, 15 insertions, 15 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 9d952d372..f5e619ebc 100644
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -6,7 +6,7 @@ colon = ':' COMMENT?
 colcom = ':' COMMENT?
 operator =  OP0 | OP1 | OP2 | OP3 | OP4 | OP5 | OP6 | OP7 | OP8 | OP9
          | 'or' | 'xor' | 'and'
-         | 'is' | 'isnot' | 'in' | 'notin' | 'of' | 'as' | 'from' |
+         | 'is' | 'isnot' | 'in' | 'notin' | 'of' | 'as' | 'from'
          | 'div' | 'mod' | 'shl' | 'shr' | 'not' | 'static' | '..'
 prefixOperator = operator
 optInd = COMMENT? IND?
@@ -31,15 +31,15 @@ dotExpr = expr '.' optInd (symbol | '[:' exprList ']')
 explicitGenericInstantiation = '[:' exprList ']' ( '(' exprColonEqExpr ')' )?
 qualifiedIdent = symbol ('.' optInd symbol)?
 setOrTableConstr = '{' ((exprColonEqExpr comma)* | ':' ) '}'
-castExpr = 'cast' '[' optInd typeDesc optPar ']' '(' optInd expr optPar ')'
+castExpr = 'cast' ('[' optInd typeDesc optPar ']' '(' optInd expr optPar ')') /
 parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try'
         | 'finally' | 'except' | 'for' | 'block' | 'const' | 'let'
         | 'when' | 'var' | 'mixin'
 par = '(' optInd
-          ( &parKeyw complexOrSimpleStmt ^+ ';'
-          | ';' complexOrSimpleStmt ^+ ';'
+          ( &parKeyw (ifExpr \ complexOrSimpleStmt) ^+ ';'
+          | ';' (ifExpr \ complexOrSimpleStmt) ^+ ';'
           | pragmaStmt
-          | simpleExpr ( ('=' expr (';' complexOrSimpleStmt ^+ ';' )? )
+          | simpleExpr ( ('=' expr (';' (ifExpr \ complexOrSimpleStmt) ^+ ';' )? )
                        | (':' expr (',' exprColonEqExpr     ^+ ',' )? ) ) )
           optPar ')'
 literal = | INT_LIT | INT8_LIT | INT16_LIT | INT32_LIT | INT64_LIT
@@ -59,11 +59,6 @@ primarySuffix = '(' (exprColonEqExpr comma?)* ')'
       | '[' optInd exprColonEqExprList optPar ']'
       | '{' optInd exprColonEqExprList optPar '}'
       | &( '`'|IDENT|literal|'cast'|'addr'|'type') expr # command syntax
-condExpr = expr colcom expr optInd
-        ('elif' expr colcom expr optInd)*
-         'else' colcom expr
-ifExpr = 'if' condExpr
-whenExpr = 'when' condExpr
 pragma = '{.' optInd (exprColonEqExpr comma?)* optPar ('.}' | '}')
 identVis = symbol OPR?  # postfix position
 identVisDot = symbol '.' optInd symbol OPR?
@@ -130,6 +125,11 @@ condStmt = expr colcom stmt COMMENT?
            (IND{=} 'else' colcom stmt)?
 ifStmt = 'if' condStmt
 whenStmt = 'when' condStmt
+condExpr = expr colcom expr optInd
+        ('elif' expr colcom expr optInd)*
+         'else' colcom expr
+ifExpr = 'if' condExpr
+whenExpr = 'when' condExpr
 whileStmt = 'while' expr colcom stmt
 ofBranch = 'of' exprList colcom stmt
 ofBranches = ofBranch (IND{=} ofBranch)*
@@ -193,8 +193,8 @@ complexOrSimpleStmt = (ifStmt | whenStmt | whileStmt
                     | tryStmt | forStmt
                     | blockStmt | staticStmt | deferStmt | asmStmt
                     | 'proc' routine
-                    | 'func' routine
                     | 'method' routine
+                    | 'func' routine
                     | 'iterator' routine
                     | 'macro' routine
                     | 'template' routine
diff --git a/doc/manual.rst b/doc/manual.rst
index 11ea6b99c..494a009cb 100644
--- a/doc/manual.rst
+++ b/doc/manual.rst
@@ -6031,12 +6031,12 @@ so that it can be used for debugging routines marked as ``noSideEffect``.
 
 
 To override the compiler's side effect analysis a ``{.noSideEffect.}``
-pragma block can be used:
+``cast`` pragma block can be used:
 
 .. code-block:: nim
 
   func f() =
-    {.noSideEffect.}:
+    {.cast(noSideEffect).}:
       echo "test"
 
 
@@ -7501,7 +7501,7 @@ To disable the GC-safety checking the ``--threadAnalysis:off`` command line
 switch can be used. This is a temporary workaround to ease the porting effort
 from old code to the new threading model.
 
-To override the compiler's gcsafety analysis a ``{.gcsafe.}`` pragma block can
+To override the compiler's gcsafety analysis a ``{.cast(gcsafe).}`` pragma block can
 be used:
 
 .. code-block:: nim
@@ -7511,7 +7511,7 @@ be used:
     perThread {.threadvar.}: string
 
   proc setPerThread() =
-    {.gcsafe.}:
+    {.cast(gcsafe).}:
       deepCopy(perThread, someGlobal)