MatchCase 匹配分支
1. 结构声明
- TS Declaration
- JSON Schema
class MatchCase extends LogicItem {
patterns: Array<LogicItem | TypeAnnotation>;
body: Array<LogicItem>;
isMatchedTypeEnumable: boolean = false;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"changedTime": {
"$ref": "#/definitions/long"
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"typeAnnotation": {
"$ref": "#/definitions/TypeAnnotation"
},
"breakpoint": {
"type": "string",
"enum": [
"ENABLED",
"DISABLED"
]
},
"patterns": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/LogicItem"
},
{
"$ref": "#/definitions/TypeAnnotation"
}
]
}
},
"body": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
},
"isMatchedTypeEnumable": {
"type": "boolean"
}
},
"required": [
"patterns",
"body",
"isMatchedTypeEnumable"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "MatchCase",
"patterns": [
{
"concept": "BooleanLiteral",
"value": "true"
}
],
"body": [
{
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
],
"isMatchedTypeEnumable": true
}
concept: MatchCase
patterns:
- concept: BooleanLiteral
value: "true"
body:
- concept: NumericLiteral
value: "1"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
isMatchedTypeEnumable: true
对应的代码如下:
- 文本化 NASL
- Natural TS
true => {
1
}
1
(2) 示例
AST 如下:
- JSON
- YAML
{
"concept": "MatchCase",
"patterns": [],
"body": [],
"isMatchedTypeEnumable": false
}
concept: MatchCase
patterns: []
body: []
isMatchedTypeEnumable: false
对应的代码如下:
- 文本化 NASL
- Natural TS
_ => {
}