Skip to main content
Version: 3.3

Match 匹配

1. 结构声明

class Match extends LogicItem {
expression: LogicItem;
isExpression: boolean = false;
cases: Array<MatchCase>;
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "Match",
"expression": {
"concept": "MemberExpression",
"object": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "item"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "productReport"
}
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "executed"
}
},
"isExpression": true,
"cases": [
{
"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": "false"
}
],
"body": [
{
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
],
"isMatchedTypeEnumable": true
},
{
"concept": "MatchCase",
"patterns": [],
"body": [],
"isMatchedTypeEnumable": false
}
]
}