Minor fixes to astspec
Closing parenthesis. Couple of indentation fixes.
This commit is contained in:
parent
29b09a3c7d
commit
20cc7c17b0
1 changed files with 39 additions and 38 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
The AST in Nim
|
The AST in Nim
|
||||||
=================
|
==============
|
||||||
|
|
||||||
This section describes how the AST is modelled with Nim's type system.
|
This section describes how the AST is modelled with Nim's type system.
|
||||||
The AST consists of nodes (``NimNode``) with a variable number of
|
The AST consists of nodes (``NimNode``) with a variable number of
|
||||||
children. Each node has a field named ``kind`` which describes what the node
|
children. Each node has a field named ``kind`` which describes what the node
|
||||||
|
|
@ -24,9 +25,9 @@ contains:
|
||||||
of nnkNone, nnkEmpty, nnkNilLit:
|
of nnkNone, nnkEmpty, nnkNilLit:
|
||||||
discard ## node contains no additional fields
|
discard ## node contains no additional fields
|
||||||
of nnkCharLit..nnkUInt64Lit:
|
of nnkCharLit..nnkUInt64Lit:
|
||||||
intVal: biggestInt ## the int literal
|
intVal: BiggestInt ## the int literal
|
||||||
of nnkFloatLit..nnkFloat64Lit:
|
of nnkFloatLit..nnkFloat64Lit:
|
||||||
floatVal: biggestFloat ## the float literal
|
floatVal: BiggestFloat ## the float literal
|
||||||
of nnkStrLit..nnkTripleStrLit:
|
of nnkStrLit..nnkTripleStrLit:
|
||||||
strVal: string ## the string literal
|
strVal: string ## the string literal
|
||||||
of nnkIdent:
|
of nnkIdent:
|
||||||
|
|
@ -360,7 +361,7 @@ AST:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
nnkCurly(nnkIntLit(1), nnkIntLit(2), nnkIntLit(3))
|
nnkCurly(nnkIntLit(1), nnkIntLit(2), nnkIntLit(3))
|
||||||
|
|
||||||
When used as a table constructor, the syntax (and result) is different.
|
When used as a table constructor, the syntax is different.
|
||||||
|
|
||||||
Concrete syntax:
|
Concrete syntax:
|
||||||
|
|
||||||
|
|
@ -411,7 +412,7 @@ AST:
|
||||||
If expression
|
If expression
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
The representation of the if expression is subtle, but easy to traverse.
|
The representation of the ``if`` expression is subtle, but easy to traverse.
|
||||||
|
|
||||||
Concrete syntax:
|
Concrete syntax:
|
||||||
|
|
||||||
|
|
@ -472,7 +473,7 @@ AST:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
As many ``nnkIdent``s appear as there are pragmas between ``{..}``. Note that
|
As many ``nnkIdent`` appear as there are pragmas between ``{..}``. Note that
|
||||||
the declaration of new pragmas is essentially the same:
|
the declaration of new pragmas is essentially the same:
|
||||||
|
|
||||||
Concrete syntax:
|
Concrete syntax:
|
||||||
|
|
@ -824,7 +825,7 @@ AST:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
nnkExportStmt(nnkIdent(!"unsigned"))
|
nnkExportStmt(nnkIdent(!"unsigned"))
|
||||||
|
|
||||||
Similar to the ``import`` statement, the AST is different for
|
Similar to the ``import`` statement, the AST is different for
|
||||||
``export ... except``.
|
``export ... except``.
|
||||||
|
|
||||||
Concrete syntax:
|
Concrete syntax:
|
||||||
|
|
@ -1035,42 +1036,42 @@ AST:
|
||||||
nnkEmpty(),
|
nnkEmpty(),
|
||||||
nnkRecList( # list of object parameters
|
nnkRecList( # list of object parameters
|
||||||
nnkIdentDefs(
|
nnkIdentDefs(
|
||||||
nnkIdent(!"name"),
|
nnkIdent(!"name"),
|
||||||
nnkIdent(!"string"),
|
nnkIdent(!"string"),
|
||||||
nnkEmpty()
|
nnkEmpty()
|
||||||
),
|
),
|
||||||
nnkRecCase( # case statement within object (not nnkCaseStmt)
|
nnkRecCase( # case statement within object (not nnkCaseStmt)
|
||||||
nnkIdentDefs(
|
nnkIdentDefs(
|
||||||
nnkIdent(!"isFat"),
|
nnkIdent(!"isFat"),
|
||||||
nnkIdent(!"bool"),
|
nnkIdent(!"bool"),
|
||||||
|
nnkEmpty()
|
||||||
|
),
|
||||||
|
nnkOfBranch(
|
||||||
|
nnkIdent(!"true"),
|
||||||
|
nnkRecList( # again, a list of object parameters
|
||||||
|
nnkIdentDefs(
|
||||||
|
nnkIdent(!"m"),
|
||||||
|
nnkBracketExpr(
|
||||||
|
nnkIdent(!"array"),
|
||||||
|
nnkIntLit(100000),
|
||||||
|
nnkIdent(!"T")
|
||||||
|
),
|
||||||
nnkEmpty()
|
nnkEmpty()
|
||||||
|
)
|
||||||
),
|
),
|
||||||
nnkOfBranch(
|
nnkOfBranch(
|
||||||
nnkIdent(!"true"),
|
nnkIdent(!"false"),
|
||||||
nnkRecList( # again, a list of object parameters
|
nnkRecList(
|
||||||
nnkIdentDefs(
|
nnkIdentDefs(
|
||||||
nnkIdent(!"m"),
|
nnkIdent(!"m"),
|
||||||
nnkBracketExpr(
|
nnkBracketExpr(
|
||||||
nnkIdent(!"array"),
|
nnkIdent(!"array"),
|
||||||
nnkIntLit(100000),
|
nnkIntLit(10),
|
||||||
nnkIdent(!"T")
|
nnkIdent(!"T")
|
||||||
),
|
),
|
||||||
nnkEmpty()
|
nnkEmpty()
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
nnkOfBranch(
|
|
||||||
nnkIdent(!"false"),
|
|
||||||
nnkRecList(
|
|
||||||
nnkIdentDefs(
|
|
||||||
nnkIdent(!"m"),
|
|
||||||
nnkBracketExpr(
|
|
||||||
nnkIdent(!"array"),
|
|
||||||
nnkIntLit(10),
|
|
||||||
nnkIdent(!"T")
|
|
||||||
),
|
|
||||||
nnkEmpty()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -1135,7 +1136,7 @@ AST:
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
In general, declaring types mirrors this syntax (i.e., ``nnkStaticTy`` for
|
In general, declaring types mirrors this syntax (i.e., ``nnkStaticTy`` for
|
||||||
``static``, etc.). Examples follow (exceptions marked by ``*``:
|
``static``, etc.). Examples follow (exceptions marked by ``*``):
|
||||||
|
|
||||||
------------- ---------------------------------------------
|
------------- ---------------------------------------------
|
||||||
Nim type Corresponding AST
|
Nim type Corresponding AST
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue