Skip to content

Commit

Permalink
Add ANTLR syntax for op selection on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
briantu committed Nov 22, 2024
1 parent 41f3fab commit 2ae7d85
Show file tree
Hide file tree
Showing 12 changed files with 1,934 additions and 0 deletions.
1 change: 1 addition & 0 deletions js_modules/dagster-ui/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ packages/ui-core/src/graphql/* linguist-generated=true
packages/ui-core/src/**/types/* linguist-generated=true
packages/ui-core/client.json linguist-generated=true
packages/ui-core/src/asset-selection/generated/* linguist-generated=true
packages/ui-core/src/op-selection/generated/* linguist-generated=true
1 change: 1 addition & 0 deletions js_modules/dagster-ui/packages/ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"generate-graphql": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateGraphQLTypes.ts",
"generate-perms": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generatePermissions.ts",
"generate-asset-selection": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateAssetSelection.ts && eslint src/asset-selection/generated/ --fix -c .eslintrc.js",
"generate-op-selection": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateOpSelection.ts && eslint src/op-selection/generated/ --fix -c .eslintrc.js",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
grammar OpSelection;

start: expr EOF;

// Root rule for parsing expressions
expr
: traversalAllowedExpr # TraversalAllowedExpression
| traversal traversalAllowedExpr traversal # UpAndDownTraversalExpression
| traversal traversalAllowedExpr # UpTraversalExpression
| traversalAllowedExpr traversal # DownTraversalExpression
| NOT expr # NotExpression
| expr AND expr # AndExpression
| expr OR expr # OrExpression
| STAR # AllExpression
;

// Allowed expressions for traversals
traversalAllowedExpr
: attributeExpr # AttributeExpression
| LPAREN expr RPAREN # ParenthesizedExpression
;

// Traversal operators
traversal
: STAR
| PLUS+
;

// Attribute expressions for specific attributes
attributeExpr
: NAME COLON value # NameExpr
| NAME_SUBSTRING COLON value # NameSubstringExpr
;

// Value can be a quoted or unquoted string
value
: QUOTED_STRING
| UNQUOTED_STRING
;

// Tokens for operators and keywords
AND : 'and';
OR : 'or';
NOT : 'not';

STAR : '*';
PLUS : '+';

COLON : ':';

LPAREN : '(';
RPAREN : ')';

// Tokens for attributes
NAME : 'name';
NAME_SUBSTRING : 'name_substring';

// Tokens for strings
QUOTED_STRING : '"' (~["\\\r\n])* '"' ;
UNQUOTED_STRING : [a-zA-Z_][a-zA-Z0-9_]*;
// Whitespace
WS : [ \t\r\n]+ -> skip ;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ae7d85

Please sign in to comment.