Skip to content

Commit

Permalink
Refactor property_access_prefix to atomic_expression
Browse files Browse the repository at this point in the history
So it can be used inside asteriskless_andless_expression, avoiding
the need to duplicate the list of possible expressions in two places.
  • Loading branch information
nene committed Oct 31, 2023
1 parent b4153e0 commit b7ec980
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/parser/grammar.ne
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ expression -> ( andless_expression | logic_operator ) {% unwrap %}
andless_expression -> ( asteriskless_andless_expression | asterisk ) {% unwrap %}

asteriskless_andless_expression ->
( atomic_expression | between_predicate | case_expression ) {% unwrap %}

atomic_expression ->
( array_subscript
| between_predicate
| case_expression
| function_call
| property_access
| parenthesis
Expand Down Expand Up @@ -248,7 +249,7 @@ square_brackets -> "[" free_form_sql:* "]" {%
})
%}

property_access -> property_access_prefix _ %DOT _ (identifier | array_subscript | all_columns_asterisk) {%
property_access -> atomic_expression _ %DOT _ (identifier | array_subscript | all_columns_asterisk) {%
// Allowing property to be <array_subscript> is currently a hack.
// A better way would be to allow <property_access> on the left side of array_subscript,
// but we currently can't do that because of another hack that requires
Expand All @@ -262,19 +263,6 @@ property_access -> property_access_prefix _ %DOT _ (identifier | array_subscript
}
%}

property_access_prefix ->
( array_subscript
| function_call
| property_access
| parenthesis
| curly_braces
| square_brackets
| operator
| identifier
| parameter
| literal
| keyword ) {% unwrap %}

between_predicate -> %BETWEEN _ andless_expression_chain _ %AND _ andless_expression {%
([betweenToken, _1, expr1, _2, andToken, _3, expr2]) => ({
type: NodeType.between_predicate,
Expand Down

0 comments on commit b7ec980

Please sign in to comment.