Skip to content

Commit

Permalink
[OPER-1484] Add ANTLR syntax for op selection on frontend (#26099)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Similar to the new asset selection syntax, we want to add one for ops on the frontend. This PR just adds grammar, which is just a subset of the asset selection grammar, and the generated files from ANTLR.

## How I Tested These Changes
N/A
  • Loading branch information
briantu authored Dec 13, 2024
1 parent 72c7f5e commit 5d4edc8
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 @@ -10,3 +10,4 @@ packages/ui-core/client.json linguist-generated=true
packages/ui-core/src/asset-selection/generated/* linguist-generated=true
packages/ui-core/src/selection/generated/* linguist-generated=true
packages/ui-core/src/run-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 @@ -17,6 +17,7 @@
"generate-asset-selection": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateAssetSelection.ts && eslint src/asset-selection/generated/ --fix -c .eslintrc.js",
"generate-selection-autocomplete": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateSelection.ts && eslint src/selection/generated/ --fix -c .eslintrc.js",
"generate-run-selection": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateRunSelection.ts && eslint src/run-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

1 comment on commit 5d4edc8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-h7bvm9rg8-elementl.vercel.app

Built with commit 5d4edc8.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.