Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeGK2-0001xt-SK for pgsql-general@arkaria.postgresql.org; Fri, 30 Sep 2022 13:44:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oeGJ2-0008NO-9X for pgsql-general@arkaria.postgresql.org; Fri, 30 Sep 2022 13:43:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeGJ1-0008NE-UX for pgsql-general@lists.postgresql.org; Fri, 30 Sep 2022 13:43:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeGIs-00081N-63 for pgsql-general@postgresql.org; Fri, 30 Sep 2022 13:43:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28UDhfec589578; Fri, 30 Sep 2022 09:43:41 -0400 From: Tom Lane To: Wen Yi cc: pgsql-general Subject: Re: [BeginnerQuestion]Why I compile lex.yy.c failed? In-reply-to: References: Comments: In-reply-to Wen Yi message dated "Fri, 30 Sep 2022 08:42:46 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <589576.1664545421.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 30 Sep 2022 09:43:41 -0400 Message-ID: <589577.1664545421@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Wen Yi writes: > I am a beginner who are interested in database,when I do my study on the= lex and yacc,I write a example.l like this: > %% > .\|n ECHO > %% > and then I generate a lex.yy.c use lex > but when I compile this file,something wrong happend: > [beginnerc@bogon temp]$ flex '/home/beginnerc/work/temp/example.l' > [beginnerc@bogon temp]$ cc lex.yy.c -o first -ll > /home/beginnerc/work/temp/example.l: In function =C2=A1=C2=AEyylex=C2=A1= =C2=AF: > lex.yy.c:619:28: error: expected =C2=A1=C2=AE;=C2=A1=C2=AF before =C2=A1= =C2=AEbreak=C2=A1=C2=AF I'm too lazy to actually go and read the flex manual right now, but that error message suggests strongly that you need a semicolon: .\|n ECHO; This'd make sense since the action is supposed to be a C statement. The universal style in Postgres' flex files is to write braces around each action: .\|n { ECHO; } but I'm not sure that that's actually required, if your action is only one C statement. I suspect it's just making the action into a valid C compound block. regards, tom lane