summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-desktop>2009-12-16 00:38:35 +0100
committerAndreas Rumpf <andreas@andreas-desktop>2009-12-16 00:38:35 +0100
commit10ab814fbae0a54151028efd42ee9f806cc6bacd (patch)
treed06000186a08fb7eacdf48516f46d9c1bb046c41 /doc
parent7063670a2cfc9cccfa9078f2dc479cccd16f526e (diff)
downloadNim-10ab814fbae0a54151028efd42ee9f806cc6bacd.tar.gz
exprs for dynlib; indentation parsing
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/grammar.txt24
-rwxr-xr-xdoc/nimrodc.txt28
2 files changed, 36 insertions, 16 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 8cb6fb8dc..3ce919b44 100755
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -8,7 +8,7 @@ operator ::= OP0 | OR | XOR | AND | OP3 | OP4 | OP5 | OP6 | OP7
 prefixOperator ::= OP0 | OP3 | OP4 | OP5 | OP6 | OP7 | 'not'
 
 optInd ::= [COMMENT] [IND]
-
+optPar ::= [IND] | [SAD]
 
 lowestExpr ::= orExpr (OP0 optInd orExpr)*
 orExpr ::= andExpr (OR | 'xor' optInd andExpr)*
@@ -21,16 +21,16 @@ dollarExpr ::= primary (OP7 optInd primary)*
 
 indexExpr ::= '..' [expr] | expr ['=' expr | '..' expr]
 
-castExpr ::= 'cast' '[' optInd typeDesc [SAD] ']' '(' optInd expr [SAD] ')'
-addrExpr ::= 'addr' '(' optInd expr ')'
+castExpr ::= 'cast' '[' optInd typeDesc optPar ']' '(' optInd expr optPar ')'
+addrExpr ::= 'addr' '(' optInd expr optPar ')'
 symbol ::= '`' (KEYWORD | IDENT | operator | '(' ')'
                | '[' ']' | '=' | literal)+ '`'
          | IDENT
          
 primaryPrefix ::= (prefixOperator | 'bind') optInd
 primarySuffix ::= '.' optInd symbol
-                | '(' optInd namedExprList [SAD] ')'
-                | '[' optInd [indexExpr (comma indexExpr)* [comma]] [SAD] ']'
+                | '(' optInd namedExprList optPar ')'
+                | '[' optInd [indexExpr (comma indexExpr)* [comma]] optPar ']'
                 | '^'
                 | pragma
 
@@ -44,9 +44,9 @@ literal ::= INT_LIT | INT8_LIT | INT16_LIT | INT32_LIT | INT64_LIT
           | NIL
 
 constructor ::= literal
-          | '[' optInd colonExprList [SAD] ']'
-          | '{' optInd sliceExprList [SAD] '}'
-          | '(' optInd colonExprList [SAD] ')'
+          | '[' optInd colonExprList optPar ']'
+          | '{' optInd sliceExprList optPar '}'
+          | '(' optInd colonExprList optPar ')'
 
 colonExpr ::= expr [':' expr]
 colonExprList ::= [colonExpr (comma colonExpr)* [comma]]
@@ -128,13 +128,13 @@ importStmt ::= 'import' filename (comma filename)*
 includeStmt ::= 'include' filename (comma filename)*
 fromStmt ::= 'from' filename 'import' symbol (comma symbol)*
 
-pragma ::= '{.' optInd (colonExpr [comma])* [SAD] ('.}' | '}')
+pragma ::= '{.' optInd (colonExpr [comma])* optPar ('.}' | '}')
 
 param ::= symbol (comma symbol)* (':' typeDesc ['=' expr] | '=' expr)
-paramList ::= ['(' [param (comma param)*] [SAD] ')'] [':' typeDesc]
+paramList ::= ['(' [param (comma param)*] optPar ')'] [':' typeDesc]
 
 genericParam ::= symbol [':' typeDesc] ['=' expr]
-genericParams ::= '[' genericParam (comma genericParam)* [SAD] ']'
+genericParams ::= '[' genericParam (comma genericParam)* optPar ']'
 
 
 routineDecl := symbol ['*'] [genericParams] paramList [pragma] ['=' stmt]
@@ -164,7 +164,7 @@ objectCase ::= 'case' expr ':' typeDesc [COMMENT]
 
 objectPart ::= objectWhen | objectCase | objectIdentPart | 'nil'
              | indPush objectPart (SAD objectPart)* DED indPop
-tupleDesc ::= '[' optInd [param (comma param)*] [SAD] ']'
+tupleDesc ::= '[' optInd [param (comma param)*] optPar ']'
 
 objectDef ::= 'object' [pragma] ['of' typeDesc] objectPart
 enumField ::= symbol ['=' expr]
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt
index 4a94bc8cf..3c83cf76c 100755
--- a/doc/nimrodc.txt
+++ b/doc/nimrodc.txt
@@ -118,17 +118,37 @@ The ``dynlib`` import mechanism supports a versioning scheme:
 
 .. code-block:: nimrod 
   proc Tcl_Eval(interp: pTcl_Interp, script: cstring): int {.cdecl, 
-    importc, dynlib: "libtcl(8.5|8.4|8.3).so.(1|0)".}
+    importc, dynlib: "libtcl(|8.5|8.4|8.3).so.(1|0)".}
 
 At runtime the dynamic library is searched for (in this order)::
   
-  libtcl8.5.so.1
-  libtcl8.4.so.1
-  libtcl8.3.so.1
+  libtcl.so.1  
+  libtcl.so.0
+  libtcl8.5.so.1  
   libtcl8.5.so.0
+  libtcl8.4.so.1
   libtcl8.4.so.0
+  libtcl8.3.so.1
   libtcl8.3.so.0
 
+The ``dynlib`` pragma supports not only constant strings as argument but also
+string expressions in general:
+
+.. code-block:: nimrod
+  import os
+
+  proc getDllName: string = 
+    result = "mylib.dll"
+    if ExistsFile(result): return
+    result = "mylib2.dll"
+    if ExistsFile(result): return
+    quit("could not load dynamic library")
+  
+  proc myImport(s: cstring) {.cdecl, importc, dynlib: getDllName().}
+
+**Note**: Patterns like ``libtcl(|8.5|8.4).so`` are only supported in constant
+strings, because they are precompiled.
+
 
 NoDecl Pragma
 ~~~~~~~~~~~~~