Macro expander integrated in binder
This commit is contained in:
@@ -81,5 +81,123 @@
|
||||
"Name": "c"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repeat": {
|
||||
"NodeType": "MacroDef",
|
||||
"Name": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "repeat"
|
||||
},
|
||||
"Parameters": [
|
||||
{
|
||||
"NodeType": "Identifier",
|
||||
"Name": "n"
|
||||
},
|
||||
{
|
||||
"NodeType": "Identifier",
|
||||
"Name": "body"
|
||||
}
|
||||
],
|
||||
"Body": {
|
||||
"NodeType": "Quasiquote",
|
||||
"Expression": {
|
||||
"NodeType": "Block",
|
||||
"Expressions": [
|
||||
{
|
||||
"NodeType": "VarDecl",
|
||||
"Identifier": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "loop"
|
||||
},
|
||||
"Initializer": {
|
||||
"NodeType": "LambdaExpr",
|
||||
"Parameters": [
|
||||
{
|
||||
"NodeType": "Identifier",
|
||||
"Name": "counter"
|
||||
}
|
||||
],
|
||||
"Body": {
|
||||
"NodeType": "IfExpr",
|
||||
"Condition": {
|
||||
"NodeType": "BinaryExpr",
|
||||
"Operator": ">",
|
||||
"Left": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "counter"
|
||||
},
|
||||
"Right": {
|
||||
"NodeType": "Constant",
|
||||
"Value": {
|
||||
"Kind": "Scalar",
|
||||
"Value": {
|
||||
"Kind": "Ordinal",
|
||||
"Value": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ThenBranch": {
|
||||
"NodeType": "Block",
|
||||
"Expressions": [
|
||||
{
|
||||
"NodeType": "Unquote",
|
||||
"Expression": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "body"
|
||||
}
|
||||
},
|
||||
{
|
||||
"NodeType": "Recur",
|
||||
"Arguments": [
|
||||
{
|
||||
"NodeType": "BinaryExpr",
|
||||
"Operator": "-",
|
||||
"Left": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "counter"
|
||||
},
|
||||
"Right": {
|
||||
"NodeType": "Constant",
|
||||
"Value": {
|
||||
"Kind": "Scalar",
|
||||
"Value": {
|
||||
"Kind": "Ordinal",
|
||||
"Value": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ElseBranch": {
|
||||
"NodeType": "Block",
|
||||
"Expressions": [
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"NodeType": "FunctionCall",
|
||||
"Callee": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "loop"
|
||||
},
|
||||
"Arguments": [
|
||||
{
|
||||
"NodeType": "Unquote",
|
||||
"Expression": {
|
||||
"NodeType": "Identifier",
|
||||
"Name": "n"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user