🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #464

Unexpected parsing error in Gawk

#464
From: Cesar Quiroz
Date: Mon, 02 Oct 1989 22:29
37 lines
1828 bytes
Consider the line marked `*' in this program:

    gawk '
    BEGIN                       {   inleader=1; trailers=0  }
    /^[ \t]*$/ && inleader      {   next }
    inleader                    {   inleader = 0; print; next }
*   !inleader && /^[ \t]*$/     {   trailers++; next }
    !inleader                   {   for (i=0; i<trailers; i++) printf "\n";
                                    print; trailers=0; next }
    '

Gnu Awk (gawk) 2.10beta 07 Apr 1989 complains about it:

    gawk:  syntax error near line 5:
    !inleader && /^[ \t]*$/     {   trailers++; next }


                   ^ parse error


However, it parses correctly this version:

    /^[ \t]*$/ && !inleader     {   trailers++; next }

[Aside: indeed, I can just drop the check on inleader in that
script, that is not the point.]  In awk.y, the rule for simp_pattern
is suspect; I don't see how to generate the simple pattern
expression LEX_AND regexp.  Perhaps it would be better to generate
expressions, simple regexps and dynamic regexps.  Then derive
patterns from these three.

Thanks!
-- 
                                      Cesar Augusto Quiroz Gonzalez
                                      Department of Computer Science
                                      University of Rochester
                                      Rochester,  NY 14627
Technical Details
Message-ID: <1989Oct2.222916.4588@cs.rochester.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!quiroz

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!quiroz
From: quiroz@cs.rochester.edu (Cesar Quiroz)
Newsgroups: gnu.utils.bug
Subject: Unexpected parsing error in Gawk
Message-ID: <1989Oct2.222916.4588@cs.rochester.edu>
Date: 2 Oct 89 22:29:16 GMT
Reply-To: quiroz@cs.rochester.edu (Cesar Quiroz)
Organization: U of Rochester, Dept. of Computer Science, Rochester, NY 14627
Lines: 37
Summary: Gnu Awk (gawk) 2.10beta 07 Apr 1989