ecpg: avoid breaking the IDENT precedence level in two.
authorTom Lane <[email protected]>
Mon, 14 Oct 2024 19:41:42 +0000 (15:41 -0400)
committerTom Lane <[email protected]>
Mon, 14 Oct 2024 19:42:02 +0000 (15:42 -0400)
Careless string hacking caused parse.pl to transform gram.y's
declaration

%nonassoc    IDENT PARTITION RANGE ROWS ...

into

%nonassoc IDENT
%nonassoc CSTRING PARTITION RANGE ROWS ...

It turns out that this has no semantic impact, because the
generated preproc.c is exactly the same either way (if you
inject a blank line to keep line numbers the same).

Nonetheless, given the great emphasis that the commentary in
gram.y places on keeping those other keywords at the same
precedence level as IDENT, this seems like foolishly risking ecpg
behaving differently from the core parser.  Adjust the code so
that CSTRING is added to the precedence line without breaking it
into two lines.

Discussion: https://postgr.es/m/2157151.1713540065@sss.pgh.pa.us

src/interfaces/ecpg/preproc/parse.pl

index 9ebe4bd793041229c9f42381aaf18ab5130771d4..d5798e58ee7258cb46c857ec180dec053ec4059a 100644 (file)
@@ -289,11 +289,10 @@ sub main
                # Accumulate the line in $str.
                $str = $str . ' ' . $a;
 
-               # HACK: insert our own %nonassoc line after IDENT.
-               # XXX: this seems pretty wrong, IDENT is not last on its line!
+               # Give our token CSTRING the same precedence as IDENT.
                if ($a eq 'IDENT' && $arr[0] eq '%nonassoc')
                {
-                   $str = $str . "\n%nonassoc CSTRING";
+                   $str = $str . " CSTRING";
                }
            }
            # Save the lightly-processed line in orig_tokens.