A model representing an ASL conditional statement. Models the following structures:
if a == '00' then
return '00';
end
if a == '00' then
return '00';
elsif a == '01' then
return '01';
else
return '11';
end
| Properties | Type | Description |
|---|---|---|
| _meta | Meta |
See
Meta
for more information.
|
| _type |
|
|
| condition◊ | Traits.HasCondition |
The condition determining the branch to take.
See
definitions.condition in
Traits.HasCondition
for more information.
|
| else_clause |
oneOf [
null
]
|
The clause to execute if the condition is not satisfied.
oneOf StatementBlock
oneOf null
Default
|
| if_clause◊ | StatementBlock |
The clause to execute if the condition is satisfied.
See
StatementBlock
for more information.
|
|
||
|
||
{
"_type": "AST.If",
"condition": {
"_type": "AST.BinaryOp",
"left": {
"_type": "AST.Identifier",
"value": "a"
},
"op": "==",
"right": {
"_type": "Values.Value",
"value": "'00'"
}
},
"if_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'00'"
}
}
]
}
}
{
"_type": "AST.If",
"condition": {
"_type": "AST.BinaryOp",
"left": {
"_type": "AST.Identifier",
"value": "a"
},
"op": "==",
"right": {
"_type": "Values.Value",
"value": "'00'"
}
},
"if_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'00'"
}
}
]
},
"else_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.If",
"condition": {
"_type": "AST.BinaryOp",
"left": {
"_type": "AST.Identifier",
"value": "a"
},
"op": "==",
"right": {
"_type": "Values.Value",
"value": "'01'"
}
},
"if_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'01'"
}
}
]
},
"else_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'11'"
}
}
]
}
}
]
}
}
{
"title": "If Block",
"info": [
"A model representing an ASL conditional statement. Models the following structures:",
[
"* Simple If statements",
"```",
"if a == '00' then",
" return '00';",
"end",
"```",
"* Nested If blocks",
"```",
"if a == '00' then",
" return '00';",
"elsif a == '01' then",
" return '01';",
"else",
" return '11';",
"end",
"```"
]
],
"examples": [
{
"_type": "AST.If",
"condition": {
"_type": "AST.BinaryOp",
"left": {
"_type": "AST.Identifier",
"value": "a"
},
"op": "==",
"right": {
"_type": "Values.Value",
"value": "'00'"
}
},
"if_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'00'"
}
}
]
}
},
{
"_type": "AST.If",
"condition": {
"_type": "AST.BinaryOp",
"left": {
"_type": "AST.Identifier",
"value": "a"
},
"op": "==",
"right": {
"_type": "Values.Value",
"value": "'00'"
}
},
"if_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'00'"
}
}
]
},
"else_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.If",
"condition": {
"_type": "AST.BinaryOp",
"left": {
"_type": "AST.Identifier",
"value": "a"
},
"op": "==",
"right": {
"_type": "Values.Value",
"value": "'01'"
}
},
"if_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'01'"
}
}
]
},
"else_clause": {
"_type": "AST.StatementBlock",
"statements": [
{
"_type": "AST.Return",
"val": {
"_type": "Values.Value",
"value": "'11'"
}
}
]
}
}
]
}
}
],
"properties": {
"_meta": {
"$ref": "../Meta.json"
},
"_type": {
"enum": [
"AST.If"
]
},
"condition": {
"info": [
"The condition determining the branch to take."
],
"$ref": "../Traits/HasCondition.json#/definitions/condition"
},
"if_clause": {
"info": [
"The clause to execute if the condition is satisfied."
],
"$ref": "StatementBlock.json"
},
"else_clause": {
"info": [
"The clause to execute if the condition is not satisfied."
],
"default": null,
"oneOf": [
{
"$ref": "StatementBlock.json"
},
{
"type": "null"
}
]
}
},
"required": [
"condition",
"if_clause"
],
"type": "object",
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-04/schema#"
}