mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
refs https://github.com/nim-lang/RFCs/issues/559 Parses as an `nkIdentDefs` with an `nkEmpty` name. Pragma is allowed, can remove this if necessary. Fine to close and postpone for later
82 lines
1.6 KiB
Nim
82 lines
1.6 KiB
Nim
discard """
|
|
nimout: '''
|
|
StmtList
|
|
TypeSection
|
|
TypeDef
|
|
Ident "Node"
|
|
Empty
|
|
RefTy
|
|
ObjectTy
|
|
Empty
|
|
Empty
|
|
RecList
|
|
RecCase
|
|
IdentDefs
|
|
Empty
|
|
Empty
|
|
Empty
|
|
OfBranch
|
|
Ident "AddOpr"
|
|
Ident "SubOpr"
|
|
Ident "MulOpr"
|
|
Ident "DivOpr"
|
|
RecList
|
|
IdentDefs
|
|
Ident "a"
|
|
Ident "b"
|
|
Ident "Node"
|
|
Empty
|
|
OfBranch
|
|
Ident "Value"
|
|
RecList
|
|
NilLit
|
|
IdentDefs
|
|
Ident "info"
|
|
Ident "LineInfo"
|
|
Empty
|
|
RecCase
|
|
IdentDefs
|
|
PragmaExpr
|
|
Empty
|
|
Pragma
|
|
ExprColonExpr
|
|
Ident "size"
|
|
IntLit 1
|
|
Empty
|
|
Empty
|
|
OfBranch
|
|
Ident "Foo"
|
|
NilLit
|
|
|
|
type
|
|
Node = ref object
|
|
case
|
|
of AddOpr, SubOpr, MulOpr, DivOpr:
|
|
a, b: Node
|
|
of Value:
|
|
nil
|
|
info: LineInfo
|
|
case {.size: 1.}
|
|
of Foo:
|
|
nil
|
|
'''
|
|
"""
|
|
|
|
import std/macros
|
|
|
|
macro foo(x: untyped) =
|
|
echo x.treeRepr
|
|
echo x.repr
|
|
|
|
foo:
|
|
type
|
|
Node = ref object
|
|
case
|
|
of AddOpr, SubOpr, MulOpr, DivOpr:
|
|
a, b: Node
|
|
of Value:
|
|
discard
|
|
info: LineInfo
|
|
case {.size: 1.}
|
|
of Foo: discard
|