Skip to content

Commit

Permalink
Add key and key_subset to grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
briantu committed Nov 7, 2024
1 parent 632f025 commit fdb0ac3
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ start: expr EOF;

// Root rule for parsing expressions
expr
: assetExpr # AssetExpression
| attributeExpr # AttributeExpression
: attributeExpr # AttributeExpression
| traversal expr # UpTraversalExpression
| traversal expr traversal # UpAndDownTraversalExpression
| expr traversal # DownTraversalExpression
Expand All @@ -14,6 +13,7 @@ expr
| expr OR expr # OrExpression
| functionName LPAREN expr RPAREN # FunctionCallExpression
| LPAREN expr RPAREN # ParenthesizedExpression
| STAR # AllExpression
;

// Traversal operators
Expand All @@ -30,7 +30,9 @@ functionName

// Attribute expressions for specific attributes
attributeExpr
: TAG COLON value (EQUAL value)? # TagAttributeExpr
: KEY COLON value # KeyExpr
| KEY_SUBSET COLON value # KeySubsetExpr
| TAG COLON value (EQUAL value)? # TagAttributeExpr
| OWNER COLON value # OwnerAttributeExpr
| GROUP COLON value # GroupAttributeExpr
| KIND COLON value # KindAttributeExpr
Expand All @@ -46,12 +48,6 @@ value
| UNQUOTED_STRING
;

// Asset expressions
assetExpr
: QUOTED_STRING # ExactMatchAsset
| UNQUOTED_STRING # PrefixMatchAsset
;

// Tokens for operators and keywords
AND : 'and';
OR : 'or';
Expand All @@ -66,7 +62,9 @@ LPAREN : '(';
RPAREN : ')';
COMMA : ',';

// Tokens for keys
// Tokens for attributes
KEY : 'key';
KEY_SUBSET : 'key_subset';
OWNER : 'owner';
GROUP : 'group';
TAG : 'tag';
Expand Down

0 comments on commit fdb0ac3

Please sign in to comment.