Skip to content

Commit

Permalink
merge from dev (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 committed Feb 13, 2024
1 parent 57316df commit c1da257
Show file tree
Hide file tree
Showing 40 changed files with 726 additions and 263 deletions.
4 changes: 2 additions & 2 deletions packages/language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"author": "ZenStack Team",
"license": "MIT",
"devDependencies": {
"langium-cli": "1.2.0",
"langium-cli": "1.3.1",
"plist2": "^1.1.3"
},
"dependencies": {
"langium": "1.2.0"
"langium": "1.3.1"
},
"contributes": {
"languages": [
Expand Down
53 changes: 33 additions & 20 deletions packages/language/src/generated/ast.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
/******************************************************************************
* This file was generated by langium-cli 1.2.0.
* This file was generated by langium-cli 1.3.1.
* DO NOT EDIT MANUALLY!
******************************************************************************/

/* eslint-disable */
import { AstNode, AbstractAstReflection, Reference, ReferenceInfo, TypeMetaData } from 'langium';
import type { AstNode, Reference, ReferenceInfo, TypeMetaData } from 'langium';
import { AbstractAstReflection } from 'langium';

export const ZModelTerminals = {
WS: /\s+/,
INTERNAL_ATTRIBUTE_NAME: /@@@([_a-zA-Z][\w_]*\.)*[_a-zA-Z][\w_]*/,
MODEL_ATTRIBUTE_NAME: /@@([_a-zA-Z][\w_]*\.)*[_a-zA-Z][\w_]*/,
FIELD_ATTRIBUTE_NAME: /@([_a-zA-Z][\w_]*\.)*[_a-zA-Z][\w_]*/,
ID: /[_a-zA-Z][\w_]*/,
STRING: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/,
NUMBER: /[+-]?[0-9]+(\.[0-9]+)?/,
TRIPLE_SLASH_COMMENT: /\/\/\/[^\n\r]*/,
ML_COMMENT: /\/\*[\s\S]*?\*\//,
SL_COMMENT: /\/\/[^\n\r]*/,
};

export type AbstractDeclaration = Attribute | DataModel | DataSource | Enum | FunctionDecl | GeneratorDecl | Plugin;

Expand Down Expand Up @@ -64,10 +78,10 @@ export function isReferenceTarget(item: unknown): item is ReferenceTarget {
return reflection.isInstance(item, ReferenceTarget);
}

export type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'sort' | 'view' | string;
export type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'view' | string;

export function isRegularID(item: unknown): item is RegularID {
return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'sort' || item === 'view' || item === 'import' || (typeof item === 'string' && (/[_a-zA-Z][\w_]*/.test(item)));
return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'view' || item === 'import' || (typeof item === 'string' && (/[_a-zA-Z][\w_]*/.test(item)));
}

export type TypeDeclaration = DataModel | Enum;
Expand All @@ -81,7 +95,6 @@ export function isTypeDeclaration(item: unknown): item is TypeDeclaration {
export interface Argument extends AstNode {
readonly $container: InvocationExpr;
readonly $type: 'Argument';
name?: RegularID
value: Expression
}

Expand All @@ -92,7 +105,7 @@ export function isArgument(item: unknown): item is Argument {
}

export interface ArrayExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ArrayExpr';
items: Array<Expression>
}
Expand Down Expand Up @@ -163,7 +176,7 @@ export function isAttributeParamType(item: unknown): item is AttributeParamType
}

export interface BinaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'BinaryExpr';
left: Expression
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||'
Expand All @@ -177,7 +190,7 @@ export function isBinaryExpr(item: unknown): item is BinaryExpr {
}

export interface BooleanLiteral extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'BooleanLiteral';
value: Boolean
}
Expand All @@ -189,7 +202,7 @@ export function isBooleanLiteral(item: unknown): item is BooleanLiteral {
}

export interface ConfigArrayExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ConfigArrayExpr';
items: Array<ConfigInvocationExpr | LiteralExpr>
}
Expand Down Expand Up @@ -440,7 +453,7 @@ export function isInternalAttribute(item: unknown): item is InternalAttribute {
}

export interface InvocationExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'InvocationExpr';
args: Array<Argument>
function: Reference<FunctionDecl>
Expand All @@ -453,7 +466,7 @@ export function isInvocationExpr(item: unknown): item is InvocationExpr {
}

export interface MemberAccessExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'MemberAccessExpr';
member: Reference<DataModelField>
operand: Expression
Expand Down Expand Up @@ -490,7 +503,7 @@ export function isModelImport(item: unknown): item is ModelImport {
}

export interface NullExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'NullExpr';
value: 'null'
}
Expand All @@ -502,7 +515,7 @@ export function isNullExpr(item: unknown): item is NullExpr {
}

export interface NumberLiteral extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'NumberLiteral';
value: string
}
Expand All @@ -514,7 +527,7 @@ export function isNumberLiteral(item: unknown): item is NumberLiteral {
}

export interface ObjectExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ObjectExpr';
fields: Array<FieldInitializer>
}
Expand Down Expand Up @@ -554,8 +567,8 @@ export function isPluginField(item: unknown): item is PluginField {
export interface ReferenceArg extends AstNode {
readonly $container: ReferenceExpr;
readonly $type: 'ReferenceArg';
name: 'sort'
value: 'Asc' | 'Desc'
name: string
value: Expression
}

export const ReferenceArg = 'ReferenceArg';
Expand All @@ -565,7 +578,7 @@ export function isReferenceArg(item: unknown): item is ReferenceArg {
}

export interface ReferenceExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ReferenceExpr';
args: Array<ReferenceArg>
target: Reference<ReferenceTarget>
Expand All @@ -578,7 +591,7 @@ export function isReferenceExpr(item: unknown): item is ReferenceExpr {
}

export interface StringLiteral extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'StringLiteral';
value: string
}
Expand All @@ -590,7 +603,7 @@ export function isStringLiteral(item: unknown): item is StringLiteral {
}

export interface ThisExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ThisExpr';
value: 'this'
}
Expand All @@ -602,7 +615,7 @@ export function isThisExpr(item: unknown): item is ThisExpr {
}

export interface UnaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'UnaryExpr';
operand: Expression
operator: '!'
Expand Down
97 changes: 32 additions & 65 deletions packages/language/src/generated/grammar.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/******************************************************************************
* This file was generated by langium-cli 1.2.0.
* This file was generated by langium-cli 1.3.1.
* DO NOT EDIT MANUALLY!
******************************************************************************/

import { loadGrammarFromJson, Grammar } from 'langium';
import type { Grammar } from 'langium';
import { loadGrammarFromJson } from 'langium';

let loadedZModelGrammar: Grammar | undefined;
export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModelGrammar = loadGrammarFromJson(`{
Expand Down Expand Up @@ -1052,8 +1053,11 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"feature": "name",
"operator": "=",
"terminal": {
"$type": "Keyword",
"value": "sort"
"$type": "RuleCall",
"rule": {
"$ref": "#/rules@62"
},
"arguments": []
}
},
{
Expand All @@ -1065,17 +1069,11 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"feature": "value",
"operator": "=",
"terminal": {
"$type": "Alternatives",
"elements": [
{
"$type": "Keyword",
"value": "Asc"
},
{
"$type": "Keyword",
"value": "Desc"
}
]
"$type": "RuleCall",
"rule": {
"$ref": "#/rules@8"
},
"arguments": []
}
}
]
Expand Down Expand Up @@ -1865,43 +1863,16 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"$type": "ParserRule",
"name": "Argument",
"definition": {
"$type": "Group",
"elements": [
{
"$type": "Group",
"elements": [
{
"$type": "Assignment",
"feature": "name",
"operator": "=",
"terminal": {
"$type": "RuleCall",
"rule": {
"$ref": "#/rules@46"
},
"arguments": []
}
},
{
"$type": "Keyword",
"value": ":"
}
],
"cardinality": "?"
"$type": "Assignment",
"feature": "value",
"operator": "=",
"terminal": {
"$type": "RuleCall",
"rule": {
"$ref": "#/rules@8"
},
{
"$type": "Assignment",
"feature": "value",
"operator": "=",
"terminal": {
"$type": "RuleCall",
"rule": {
"$ref": "#/rules@8"
},
"arguments": []
}
}
]
"arguments": []
}
},
"definesHiddenTokens": false,
"entry": false,
Expand Down Expand Up @@ -2723,10 +2694,6 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"$type": "Keyword",
"value": "in"
},
{
"$type": "Keyword",
"value": "sort"
},
{
"$type": "Keyword",
"value": "view"
Expand Down Expand Up @@ -3452,7 +3419,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "WS",
"definition": {
"$type": "RegexToken",
"regex": "\\\\s+"
"regex": "/\\\\s+/"
},
"fragment": false
},
Expand All @@ -3461,7 +3428,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "INTERNAL_ATTRIBUTE_NAME",
"definition": {
"$type": "RegexToken",
"regex": "@@@([_a-zA-Z][\\\\w_]*\\\\.)*[_a-zA-Z][\\\\w_]*"
"regex": "/@@@([_a-zA-Z][\\\\w_]*\\\\.)*[_a-zA-Z][\\\\w_]*/"
},
"fragment": false,
"hidden": false
Expand All @@ -3471,7 +3438,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "MODEL_ATTRIBUTE_NAME",
"definition": {
"$type": "RegexToken",
"regex": "@@([_a-zA-Z][\\\\w_]*\\\\.)*[_a-zA-Z][\\\\w_]*"
"regex": "/@@([_a-zA-Z][\\\\w_]*\\\\.)*[_a-zA-Z][\\\\w_]*/"
},
"fragment": false,
"hidden": false
Expand All @@ -3481,7 +3448,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "FIELD_ATTRIBUTE_NAME",
"definition": {
"$type": "RegexToken",
"regex": "@([_a-zA-Z][\\\\w_]*\\\\.)*[_a-zA-Z][\\\\w_]*"
"regex": "/@([_a-zA-Z][\\\\w_]*\\\\.)*[_a-zA-Z][\\\\w_]*/"
},
"fragment": false,
"hidden": false
Expand All @@ -3491,7 +3458,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "ID",
"definition": {
"$type": "RegexToken",
"regex": "[_a-zA-Z][\\\\w_]*"
"regex": "/[_a-zA-Z][\\\\w_]*/"
},
"fragment": false,
"hidden": false
Expand All @@ -3501,7 +3468,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "STRING",
"definition": {
"$type": "RegexToken",
"regex": "\\"(\\\\\\\\.|[^\\"\\\\\\\\])*\\"|'(\\\\\\\\.|[^'\\\\\\\\])*'"
"regex": "/\\"(\\\\\\\\.|[^\\"\\\\\\\\])*\\"|'(\\\\\\\\.|[^'\\\\\\\\])*'/"
},
"fragment": false,
"hidden": false
Expand All @@ -3511,7 +3478,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "NUMBER",
"definition": {
"$type": "RegexToken",
"regex": "[+-]?[0-9]+(\\\\.[0-9]+)?"
"regex": "/[+-]?[0-9]+(\\\\.[0-9]+)?/"
},
"fragment": false,
"hidden": false
Expand All @@ -3521,7 +3488,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "TRIPLE_SLASH_COMMENT",
"definition": {
"$type": "RegexToken",
"regex": "\\\\/\\\\/\\\\/[^\\\\n\\\\r]*"
"regex": "/\\\\/\\\\/\\\\/[^\\\\n\\\\r]*/"
},
"fragment": false,
"hidden": false
Expand All @@ -3532,7 +3499,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "ML_COMMENT",
"definition": {
"$type": "RegexToken",
"regex": "\\\\/\\\\*[\\\\s\\\\S]*?\\\\*\\\\/"
"regex": "/\\\\/\\\\*[\\\\s\\\\S]*?\\\\*\\\\//"
},
"fragment": false
},
Expand All @@ -3542,7 +3509,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
"name": "SL_COMMENT",
"definition": {
"$type": "RegexToken",
"regex": "\\\\/\\\\/[^\\\\n\\\\r]*"
"regex": "/\\\\/\\\\/[^\\\\n\\\\r]*/"
},
"fragment": false
}
Expand Down
Loading

0 comments on commit c1da257

Please sign in to comment.