From b7ec980176418744a857d8749982d553cd9aabf1 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Tue, 31 Oct 2023 14:17:09 +0200 Subject: [PATCH] Refactor property_access_prefix to atomic_expression So it can be used inside asteriskless_andless_expression, avoiding the need to duplicate the list of possible expressions in two places. --- src/parser/grammar.ne | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/parser/grammar.ne b/src/parser/grammar.ne index dcb917dd57..ca7061fb3d 100644 --- a/src/parser/grammar.ne +++ b/src/parser/grammar.ne @@ -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 @@ -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 is currently a hack. // A better way would be to allow on the left side of array_subscript, // but we currently can't do that because of another hack that requires @@ -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,