Skip to main content
Version: 3.8

语言概览

分类概念概念标题JSON AST 示例文本化 NASLNatural TS
basics/typesTypeAnnotation类型标注Boolean 布尔值
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Boolean",
"inferred": false,
"ruleMap": {}
}
Boolean
Boolean
Integer 整数
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
Integer
Long
Decimal 小数
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Decimal",
"inferred": false,
"ruleMap": {}
}
Decimal
Decimal
String 字符串
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
}
String
String
basics/typesDatabaseTypeAnnotation数据库存储类型
{
"concept": "DatabaseTypeAnnotation",
"typeName": "decimal",
"arguments": {
"precision": "31"
}
}
@DatabaseTypeAnnotation(
typeName = "decimal",
arguments = [ "precision" -> "31" ],
)
basics/typesTypeParam类型参数
{
"concept": "TypeParam",
"name": "T"
}
T
T
basics/typesStructure数据结构
{
"concept": "Structure",
"name": "ProductOrder",
"description": "",
"properties": [
{
"concept": "StructureProperty",
"name": "product",
"label": "商品",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "Product",
"inferred": false,
"ruleMap": {}
},
"jsonName": "",
"description": ""
},
{
"concept": "StructureProperty",
"name": "order",
"label": "订单",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "OrderForm",
"inferred": false,
"ruleMap": {}
},
"jsonName": "",
"description": ""
},
{
"concept": "StructureProperty",
"name": "count",
"label": "数量",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"jsonName": "",
"description": ""
}
]
}
@(description = "")
struct ProductOrder {
@(
label = "商品",
description = "",
jsonName = "",
)
product: app::dataSources::defaultDS::entities::Product;

@(
label = "订单",
description = "",
jsonName = "",
)
order: app::dataSources::defaultDS::entities::OrderForm;

@(
label = "数量",
description = "",
jsonName = "",
)
count: Integer;
}
class ProductOrder {
product: Product;
order: OrderForm;
count: Long;
}
带描述的示例
{
"concept": "Structure",
"name": "ProductOrder",
"description": "表示商品订单的结构",
"properties": [
{
"concept": "StructureProperty",
"name": "product",
"label": "商品",
"description": "商品属性",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "Product",
"inferred": false,
"ruleMap": {}
},
"jsonName": "product-"
},
{
"concept": "StructureProperty",
"name": "order",
"label": "订单",
"description": "订单属性",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "OrderForm",
"inferred": false,
"ruleMap": {}
},
"jsonName": "order-"
},
{
"concept": "StructureProperty",
"name": "count",
"label": "数量",
"description": "订单中该商品的数量",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"jsonName": "count-",
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "NumericLiteral",
"value": "120",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"playground": []
}
}
]
}
@(description = "表示商品订单的结构")
struct ProductOrder {
@(
label = "商品",
description = "商品属性",
jsonName = "product-",
)
product: app::dataSources::defaultDS::entities::Product;

@(
label = "订单",
description = "订单属性",
jsonName = "order-",
)
order: app::dataSources::defaultDS::entities::OrderForm;

@(
label = "数量",
description = "订单中该商品的数量",
jsonName = "count-",
)
count: Integer = 120;
}
class ProductOrder {
product: Product;
order: OrderForm;
count: Long;
}
{
"concept": "Structure",
"name": "ExtendedList",
"description": "",
"typeParams": [
{
"concept": "TypeParam",
"name": "T"
}
],
"properties": [
{
"concept": "StructureProperty",
"name": "length",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Integer",
"inferred": false,
"ruleMap": {}
},
"description": "",
"jsonName": ""
}
]
}
@(description = "")
struct ExtendedList<T> {
@(
description = "",
jsonName = "",
)
length: Integer;
}
class ExtendedList<T> {
length: Integer;
}
basics/typesStructureProperty数据结构属性
{
"concept": "StructureProperty",
"name": "count",
"label": "数量",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"description": "",
"jsonName": ""
}
@(
label = "数量",
description = "",
jsonName = "",
)
count: Integer
count: Long
{
"concept": "StructureProperty",
"name": "count",
"label": "数量",
"description": "订单中该商品的数量",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"jsonName": "count-",
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "NumericLiteral",
"value": "120",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"playground": []
}
}
@(
label = "数量",
description = "订单中该商品的数量",
jsonName = "count-",
)
count: Integer = 120
count: Long
basics/typesEnum枚举
{
"concept": "Enum",
"name": "ProductStatus",
"label": "",
"description": "",
"valueType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"enumItems": [
{
"concept": "EnumItem",
"value": "Listing",
"label": {
"concept": "StaticString",
"value": "上架"
}
},
{
"concept": "EnumItem",
"value": "Delisting",
"label": {
"concept": "StaticString",
"value": "下架"
}
}
]
}
@(
label = "",
description = "",
)
enum ProductStatus {
@(label = '上架')
case Listing;

@(label = '下架')
case Delisting;
}
enum ProductStatus {
'Listing' = '上架',
'Delisting' = '下架',
}
带描述的示例
{
"concept": "Enum",
"name": "ProductStatus",
"label": "商品状态",
"description": "表示商品状态的枚举",
"valueType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"enumItems": [
{
"concept": "EnumItem",
"value": "Listing",
"label": {
"concept": "StaticString",
"value": "上架"
}
},
{
"concept": "EnumItem",
"value": "Delisting",
"label": {
"concept": "StaticString",
"value": "下架"
}
}
]
}
@(
label = "商品状态",
description = "表示商品状态的枚举",
)
enum ProductStatus {
@(label = '上架')
case Listing;

@(label = '下架')
case Delisting;
}
enum ProductStatus {
'Listing' = '上架',
'Delisting' = '下架',
}
basics/typesEnumItem枚举值带描述的示例
{
"concept": "EnumItem",
"value": "Listing",
"label": {
"concept": "StaticString",
"value": "上架"
}
}
@(label = '上架')
case Listing
'Listing' = '上架'
basics/typesMetadataType元数据类型
{
"concept": "MetadataType",
"name": "Currency",
"label": "货币",
"uuid": "83450632af284642ab5c967e82d49be4",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Decimal",
"inferred": false,
"ruleMap": {}
},
"rules": [
{
"concept": "ValidationRule",
"calleeNamespace": "nasl.validation",
"calleeName": "min",
"arguments": [
{
"concept": "Argument",
"keyword": "min",
"expression": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
],
"enableServerValidation": true
},
{
"concept": "ValidationRule",
"calleeNamespace": "nasl.validation",
"calleeName": "max",
"arguments": [
{
"concept": "Argument",
"keyword": "max",
"expression": {
"concept": "NumericLiteral",
"value": "99999999",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
],
"enableServerValidation": true
}
],
"playground": []
}
@(
label = "货币",
uuid = "83450632af284642ab5c967e82d49be4",
)
type Currency = Decimal {
expect min(0)(
enableServerValidation = true,
);
expect max(99999999)(
enableServerValidation = true,
);
}
type Currency = Decimal;
basics/literalsNullLiteral空字面量
{
"concept": "NullLiteral"
}
null
null
basics/literalsBooleanLiteral布尔型字面量
{
"concept": "BooleanLiteral",
"value": "true"
}
true
true
basics/literalsStringLiteral字符串字面量
{
"concept": "StringLiteral",
"value": "这是一段文本"
}
'这是一段文本'
'这是一段文本'
basics/literalsStringInterpolation字符串插值
{
"concept": "StringInterpolation",
"expressions": [
{
"concept": "StringLiteral",
"value": "总数:"
},
{
"concept": "Identifier",
"namespace": "",
"name": "total"
},
{
"concept": "StringLiteral",
"value": "\n价格:"
},
{
"concept": "Identifier",
"namespace": "",
"name": "price"
}
]
}
s"总数:${total}
价格:${price}"
`总数:${total}
价格:${price}`
basics/literalsStaticString静态字符串
{
"concept": "StaticString",
"value": "这是一段文本",
"i18nKey": "21daa460e9976a46d1b948c13f211550"
}
@(i18nKey = "21daa460e9976a46d1b948c13f211550")
'这是一段文本'
'这是一段文本'
basics/literalsNumericLiteral数字字面量
{
"concept": "NumericLiteral",
"value": "24",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeNamespace": "nasl.core",
"typeKind": "primitive",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
24
24
basics/expressionsCallFunction调用函数
{
"concept": "CallFunction",
"label": "调用逻辑",
"calleeNamespace": "nasl.util",
"calleeName": "Clone",
"arguments": [
{
"concept": "Argument",
"keyword": "obj",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "student"
}
}
]
}
nasl::util::Clone(student)
nasl.util.Clone(student)
带 lambda 的入参
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "ListFilter",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
},
{
"concept": "Argument",
"keyword": "by",
"expression": {
"concept": "AnonymousFunction",
"params": [
{
"concept": "Param",
"name": "item",
"description": ""
}
],
"body": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "item"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "productReport"
}
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "executed"
}
},
"right": {
"concept": "NullLiteral"
},
"operator": "!="
}
}
}
]
}
nasl::util::ListFilter(list, { item: String => item.productReport.executed != null })
nasl.util.ListFilter(list, (item: String) => item.productReport.executed != null)
basics/expressionsValidationRule验证规则
{
"concept": "ValidationRule",
"calleeNamespace": "nasl.validation",
"calleeName": "maxLength",
"arguments": [
{
"concept": "Argument",
"keyword": "max",
"expression": {
"concept": "NumericLiteral",
"value": "100",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
],
"enableServerValidation": true
}
expect maxLength(100)(
enableServerValidation = true,
)
nasl.validation.maxLength(100)
{
"concept": "ValidationRule",
"calleeNamespace": "nasl.validation",
"calleeName": "maxLength",
"arguments": [
{
"concept": "Argument",
"keyword": "max",
"expression": {
"concept": "NumericLiteral",
"value": "100",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
],
"errorMessage": {
"concept": "StringLiteral",
"value": "格式不正确"
},
"target": {
"concept": "Identifier",
"namespace": "",
"name": "param1"
},
"enableServerValidation": true
}
expect maxLength(100)(
enableServerValidation = true,
errorMessage = '格式不正确',
target = param1,
)
nasl.validation.maxLength(100)
basics/expressionsIdentifier标识符
{
"concept": "Identifier",
"namespace": "",
"name": "student"
}
student
student
枚举标识符
{
"concept": "Identifier",
"namespace": "app.enums",
"name": "StatusEnum"
}
app::enums::StatusEnum
app.enums.StatusEnum
basics/expressionsBinaryExpression二元表达式
{
"concept": "BinaryExpression",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "ratio"
},
"operator": "*",
"right": {
"concept": "NumericLiteral",
"value": "100",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
ratio * 100
ratio * 100
{
"concept": "BinaryExpression",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "ratio"
},
"operator": "==",
"right": {
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
ratio == 1
ratio == 1
{
"concept": "BinaryExpression",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "condition1"
},
"operator": "||",
"right": {
"concept": "BinaryExpression",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "ratio"
},
"operator": ">",
"right": {
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
}
condition1 || ratio > 1
condition1 || ratio > 1
数据查询中的二元表达式
{
"concept": "BinaryExpression",
"left": {
"concept": "QueryFieldExpression",
"isDotStar": false,
"entityAsName": "Student",
"propertyName": "fullName",
"asName": ""
},
"right": {
"concept": "Identifier",
"namespace": "",
"name": "name"
},
"operator": "like"
}
LIKE(Student.fullName, name)
LIKE(Student.fullName, name)
basics/expressionsMatchCase匹配分支
{
"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
}
true => {
1
}
1
{
"concept": "MatchCase",
"patterns": [],
"body": [],
"isMatchedTypeEnumable": false
}
_ => {
}
basics/expressionsMatch匹配
{
"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
}
]
}
match item.productReport.executed {
true => 1
false => 0
}
(function match(_value) {
if (item.productReport.executed === true) {
return 1
} else if (item.productReport.executed === false) {
return 0
} else {
}
})(item.productReport.executed)
basics/expressionsUnaryExpression一元表达式
{
"concept": "UnaryExpression",
"operator": "!",
"argument": {
"concept": "Identifier",
"namespace": "",
"name": "condition"
}
}
!condition
!(condition)
数据查询中的一元表达式
{
"concept": "UnaryExpression",
"operator": "isNull",
"argument": {
"concept": "Identifier",
"namespace": "",
"name": "condition"
}
}
(condition) === null
((condition) === null)
basics/expressionsMemberExpression成员表达式
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "student"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "name"
}
}
student.name
student.name
{
"concept": "MemberExpression",
"object": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "item"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "student"
}
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "name"
}
}
item.student.name
item.student.name
枚举标识符
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "app.enums",
"name": "Status"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "Normal"
}
}
app::enums::Status::Normal
app.enums.Status['Normal']
数值枚举标识符
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "app.enums",
"name": "Status"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "0"
}
}
app::enums::Status::0
app.enums.Status['0']
basics/expressionsUnparsed未解析的
basics/expressionsNew构造器
{
"concept": "New"
}
[编译方法未实现]
__IDENTIFIER__
basics/expressionsNewComposite实体/(匿名)数据结构构造器
{
"concept": "NewComposite",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "Student",
"inferred": false,
"ruleMap": {}
},
"properties": [
{
"concept": "Identifier",
"namespace": "",
"name": "id"
},
{
"concept": "Identifier",
"namespace": "",
"name": "createdTime"
},
{
"concept": "Identifier",
"namespace": "",
"name": "updatedTime"
},
{
"concept": "Identifier",
"namespace": "",
"name": "createdBy"
},
{
"concept": "Identifier",
"namespace": "",
"name": "updatedBy"
},
{
"concept": "Identifier",
"namespace": "",
"name": "name"
}
],
"rights": [
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "StringLiteral",
"value": "学生甲"
},
"members": []
}
],
"assignmentLines": [
{
"concept": "AssignmentLine",
"leftIndex": [
0,
5
],
"rightIndex": [
0
]
}
],
"hideProperties": false,
"hideDefaults": false,
"autoConnection": true
}
app::dataSources::defaultDS::entities::Student {
id = '学生甲',
}
nasl.util.NewEntity<Student>({ id: '学生甲', createdTime: undefined, updatedTime: undefined, createdBy: undefined, updatedBy: undefined, name: undefined })
新建匿名数据结构
{
"concept": "NewComposite",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "anonymousStructure",
"typeNamespace": "",
"typeName": "",
"inferred": false,
"ruleMap": {},
"properties": [
{
"concept": "StructureProperty",
"name": "name"
},
{
"concept": "StructureProperty",
"name": "age"
}
]
},
"properties": [
{
"concept": "Identifier",
"namespace": "",
"name": "name"
},
{
"concept": "Identifier",
"namespace": "",
"name": "age"
}
],
"rights": [
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "NumericLiteral",
"value": "24",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "StringLiteral",
"value": "学生甲"
},
"members": []
}
],
"assignmentLines": [
{
"concept": "AssignmentLine",
"leftIndex": [
0,
0
],
"rightIndex": [
1
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
1
],
"rightIndex": [
0
]
}
],
"hideProperties": false,
"hideDefaults": false,
"autoConnection": true
}
{
name = 24,
age = '学生甲',
}
nasl.util.NewAnonymousStructure({ name: 24, age: '学生甲' })
basics/expressionsNewList列表构造器
{
"concept": "NewList",
"items": [
{
"concept": "StringLiteral",
"value": "选项1"
},
{
"concept": "StringLiteral",
"value": "选项2"
},
{
"concept": "StringLiteral",
"value": "选项3"
}
]
}
['选项1', '选项2', '选项3']
nasl.util.NewList<__IDENTIFIER__>(['选项1', '选项2', '选项3'])
basics/expressionsNewMapMap 构造器
{
"concept": "NewMap",
"keys": [
{
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
{
"concept": "NumericLiteral",
"value": "2",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
{
"concept": "NumericLiteral",
"value": "3",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
],
"values": [
{
"concept": "StringLiteral",
"value": "选项1"
},
{
"concept": "StringLiteral",
"value": "选项2"
},
{
"concept": "StringLiteral",
"value": "选项3"
}
]
}
[1 -> '选项1', 2 -> '选项2', 3 -> '选项3']
nasl.util.NewMap<__IDENTIFIER__>({ 1: '选项1', 2: '选项2', 3: '选项3' })
basics/expressionsPaginate分页
basics/statementsAbort中止表达式
{
"concept": "Abort"
}
abort
throw new Error('程序中止');
basics/statementsStart开始节点
{
"concept": "Start"
}
basics/statementsEnd结束节点
{
"concept": "End"
}
end
return;
basics/statementsIfStatement条件分支
{
"concept": "IfStatement",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"right": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"operator": "=="
},
"consequent": [
{
"concept": "Assignment",
"label": "赋值",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"right": {
"concept": "NullLiteral"
}
}
],
"alternate": [
{
"concept": "Assignment",
"label": "赋值",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"right": {
"concept": "BinaryExpression",
"left": {
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "ListSum",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
}
]
},
"right": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"operator": "/"
}
}
]
}
if (list.length == 0) {
result = null
} else {
result = nasl::util::ListSum(list) / list.length
}
if (list.length == 0) {
result = null
} else {
result = nasl.util.ListSum(list) / list.length
}
basics/statementsSwitchStatement选择分支
{
"concept": "SwitchStatement",
"cases": [
{
"concept": "SwitchCase",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"right": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"operator": "=="
},
"consequent": [
{
"concept": "CallLogic",
"uuid": "1a3ec5f53ff84d5f87cd9d81b741bd39",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringLiteral",
"value": "情况1"
}
}
]
}
]
},
{
"concept": "SwitchCase",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"right": {
"concept": "NumericLiteral",
"value": "10",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"operator": "<="
},
"consequent": [
{
"concept": "CallLogic",
"uuid": "08d83151df934c3e904ab8704e14b2ae",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringLiteral",
"value": "情况2"
}
}
]
}
]
},
{
"concept": "SwitchCase",
"consequent": [
{
"concept": "CallLogic",
"uuid": "11fe6dacbd3f42749c14c272fad6ffbb",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringLiteral",
"value": "其它情况"
}
}
]
}
]
}
]
}
switch {
list.length == 0 => {
nasl::logging::INFO('情况1')
}
list.length <= 10 => {
nasl::logging::INFO('情况2')
}
_ => {
nasl::logging::INFO('其它情况')
}
}
if (list.length == 0) {
nasl.logging.INFO('情况1')
}
else if (list.length <= 10) {
nasl.logging.INFO('情况2')
}
else {
nasl.logging.INFO('其它情况')
}
basics/statementsSwitchCase选择分支情况
{
"concept": "SwitchCase",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"right": {
"concept": "NumericLiteral",
"value": "10",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"operator": "<="
},
"consequent": [
{
"concept": "CallLogic",
"uuid": "08d83151df934c3e904ab8704e14b2ae",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringLiteral",
"value": "情况2"
}
}
]
}
]
}
list.length <= 10 => {
nasl::logging::INFO('情况2')
}
if (list.length <= 10) {
nasl.logging.INFO('情况2')
}
else
{
"concept": "SwitchCase",
"consequent": [
{
"concept": "CallLogic",
"uuid": "11fe6dacbd3f42749c14c272fad6ffbb",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringLiteral",
"value": "其它情况"
}
}
]
}
]
}
_ => {
nasl::logging::INFO('其它情况')
}
if (__IDENTIFIER__) {
nasl.logging.INFO('其它情况')
}
basics/statementsForEachStatementForEach 循环分支
{
"concept": "ForEachStatement",
"each": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"item": {
"concept": "Param",
"name": "item",
"description": ""
},
"index": {
"concept": "Param",
"name": "index",
"description": ""
},
"start": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"body": [
{
"concept": "IfStatement",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "item"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "productReport"
}
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "accepted"
}
},
"right": {
"concept": "BooleanLiteral",
"value": "true"
},
"operator": "=="
},
"consequent": [
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "Add",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "fullAcceptedList"
}
},
{
"concept": "Argument",
"keyword": "item",
"expression": {
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
]
}
],
"alternate": [
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "Add",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "fullAcceptedList"
}
},
{
"concept": "Argument",
"keyword": "item",
"expression": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
]
}
]
}
]
}
for (item in list, index) {
if (item.productReport.accepted == true) {
nasl::util::Add(fullAcceptedList, 1)
} else {
nasl::util::Add(fullAcceptedList, 0)
}
}
ForEach(list, 0, __IDENTIFIER__, (item, index) => {
if (item.productReport.accepted == true) {
nasl.util.Add(fullAcceptedList, 1)
} else {
nasl.util.Add(fullAcceptedList, 0)
}
})
{
"concept": "ForEachStatement",
"each": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"item": {
"concept": "Param",
"name": "item",
"description": ""
},
"index": {
"concept": "Param",
"name": "index",
"description": ""
},
"start": {
"concept": "NumericLiteral",
"value": "3",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"end": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"operator": "-",
"right": {
"concept": "NumericLiteral",
"value": "3",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
},
"body": [
{
"concept": "IfStatement",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "item"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "productReport"
}
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "accepted"
}
},
"right": {
"concept": "BooleanLiteral",
"value": "true"
},
"operator": "=="
},
"consequent": [
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "Add",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "fullAcceptedList"
}
},
{
"concept": "Argument",
"keyword": "item",
"expression": {
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
]
}
],
"alternate": [
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "Add",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "fullAcceptedList"
}
},
{
"concept": "Argument",
"keyword": "item",
"expression": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
]
}
]
}
]
}
for (item in list, index in 3 to list.length - 3) {
if (item.productReport.accepted == true) {
nasl::util::Add(fullAcceptedList, 1)
} else {
nasl::util::Add(fullAcceptedList, 0)
}
}
ForEach(list, 3, list.length - 3, (item, index) => {
if (item.productReport.accepted == true) {
nasl.util.Add(fullAcceptedList, 1)
} else {
nasl.util.Add(fullAcceptedList, 0)
}
})
basics/statementsWhileStatementWhile 循环分支
{
"concept": "WhileStatement",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"operator": ">",
"right": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
},
"body": [
{
"concept": "CallFunction",
"calleeNamespace": "nasl.util",
"calleeName": "RemoveAt",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
},
{
"concept": "Argument",
"keyword": "index",
"expression": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
]
}
]
}
while (list.length > 0) {
nasl::util::RemoveAt(list, 0);
}
while (list.length > 0) {
nasl.util.RemoveAt(list, 0);
}
basics/statementsAssignment赋值语句
{
"concept": "Assignment",
"label": "赋值",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"right": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "product"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "price"
}
}
}
result = product.price
result = product.price
basics/statementsBatchAssignment批量赋值语句
{
"concept": "BatchAssignment",
"label": "批量赋值",
"left": {
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"members": [
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "accepted"
}
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "executed"
}
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "fullAccepted"
}
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "success"
}
}
]
},
"rights": [
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "52f1329c82414b9a8c320815cf703425",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "executedList"
}
}
]
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "aabee80d05b94a64ab797bae0f11aa85",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "successList"
}
}
]
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "a274f5173af049feaee53c1b968c17c1",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "acceptedList"
}
}
]
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "6ac10af536c446acbc7179b4f525d3d6",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "fullAcceptedList"
}
}
]
},
"members": []
}
],
"assignmentLines": [
{
"concept": "AssignmentLine",
"leftIndex": [
0,
2
],
"rightIndex": [
3
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
0
],
"rightIndex": [
2
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
3
],
"rightIndex": [
1
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
1
],
"rightIndex": [
0
]
}
],
"autoConnection": true
}
{
result.fullAccepted = app::logics::computeRatio(fullAcceptedList);
result.accepted = app::logics::computeRatio(acceptedList);
result.success = app::logics::computeRatio(successList);
result.executed = app::logics::computeRatio(executedList);
}
{
result.fullAccepted = app.logics.computeRatio(fullAcceptedList);
result.accepted = app.logics.computeRatio(acceptedList);
result.success = app.logics.computeRatio(successList);
result.executed = app.logics.computeRatio(executedList);
}
basics/statementsComment注释
{
"concept": "Comment",
"value": "这是一段注释,用户可自行修改。"
}
/* 这是一段注释,用户可自行修改。 */
/* 这是一段注释,用户可自行修改。 */
basics/statementsCallLogic调用逻辑
{
"uuid": "43a14fc183ed4b1bab03a839ea7fce9f",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "elements.saveModal_1.logics",
"calleeName": "open",
"arguments": []
}
$refs::saveModal_1::open()
$refs.saveModal_1.open()
带 shortcut
{
"uuid": "d5ab84861fa64b5f928b655182c9a19d",
"concept": "CallLogic",
"label": "输出日志",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringInterpolation",
"expressions": [
{
"concept": "StringLiteral",
"value": "count: "
},
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "ListSum",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
}
]
},
{
"concept": "StringLiteral",
"value": ", length: "
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
}
]
}
}
]
}
nasl::logging::INFO(s"count: ${nasl::util::ListSum(list)}, length: ${list.length}")
nasl.logging.INFO(`count: ${nasl.util.ListSum(list)}, length: ${list.length}`)
basics/statementsCallEvent触发事件
basics/statementsCallInterface调用接口
basics/statementsDestination跳转页面
{
"concept": "Destination",
"viewNamespace": "app.frontendTypes.pc.frontends.pc.views.dashboard.views",
"viewName": "productList",
"arguments": [],
"target": "_self",
"anchor": {
"concept": "Anchor",
"expression": {
"concept": "StringLiteral",
"value": "标题1"
}
}
}
goto app::frontendTypes::pc::frontends::pc::views::dashboard::views::productList()(
target = "_self",
anchor = '标题1',
)
nasl.ui.destination('undefined.dashboard_view.productList_view')
basics/statementsExternalDestination跳转到外部链接
{
"concept": "ExternalDestination"