Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for filter operator functions #289

Merged
merged 4 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ env:
DO_NOT_TRACK: '1'

on:
push:
branches: ['dev', 'main', 'canary']
pull_request:
branches: ['dev', 'main', 'canary']

jobs:
build-test:
runs-on: ubuntu-latest
runs-on: buildjet-4vcpu-ubuntu-2204

strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "1.0.0-alpha.81",
"version": "1.0.0-alpha.82",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "1.0.0-alpha.81",
"version": "1.0.0-alpha.82",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
7 changes: 4 additions & 3 deletions packages/language/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export const BinaryExprOperatorPriority: Record<BinaryExpr['operator'], number>
'<': 3,
'>=': 3,
'<=': 3,
in: 4,
//CollectionPredicateExpr
'^': 4,
'?': 4,
'!': 4,
'^': 5,
'?': 5,
'!': 5,
};

declare module './generated/ast' {
Expand Down
11 changes: 10 additions & 1 deletion packages/language/src/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export interface BinaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'BinaryExpr';
left: Expression
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | '||'
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||'
right: Expression
}

Expand Down Expand Up @@ -318,6 +318,7 @@ export interface FunctionParam extends AstNode {
readonly $container: DataModel | Enum | FunctionDecl;
readonly $type: 'FunctionParam';
name: string
optional: boolean
type: FunctionParamType
}

Expand Down Expand Up @@ -752,6 +753,14 @@ export class ZModelAstReflection extends AbstractAstReflection {
]
};
}
case 'FunctionParam': {
return {
name: 'FunctionParam',
mandatory: [
{ name: 'optional', type: 'boolean' }
]
};
}
case 'FunctionParamType': {
return {
name: 'FunctionParamType',
Expand Down
Loading