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 1q53Yu-00009Y-I3 for pgsql-general@arkaria.postgresql.org; Fri, 02 Jun 2023 12:07:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q53Ys-00047F-7P for pgsql-general@arkaria.postgresql.org; Fri, 02 Jun 2023 12:07:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q53Yr-000476-L8 for pgsql-general@lists.postgresql.org; Fri, 02 Jun 2023 12:07:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q53Yo-003FTm-Oz for pgsql-general@lists.postgresql.org; Fri, 02 Jun 2023 12:07:16 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 352C7D3q3347966; Fri, 2 Jun 2023 08:07:13 -0400 From: Tom Lane To: "=?ISO-8859-1?B?V2VuIFlp?=" <896634148@qq.com> cc: "=?ISO-8859-1?B?cGdzcWwtZ2VuZXJhbA==?=" Subject: Re: [Beginner Question]A question about yacc & lex In-reply-to: References: Comments: In-reply-to "=?ISO-8859-1?B?V2VuIFlp?=" <896634148@qq.com> message dated "Fri, 02 Jun 2023 08:47:17 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <49209.1685707632.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 02 Jun 2023 08:07:12 -0400 Message-ID: <49210.1685707632@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "=3D?ISO-8859-1?B?V2VuIFlp?=3D" <896634148@qq.com> writes: > I don't know why are there many extra spaces in the output, and why the = error message 'syntax error' is showed. You didn't say exactly what you typed at it, but: Your flex lexer lacks actions for many possible input characters, notably spaces. I seem to recall that the default action in such cases is to print the character on stdout. The grammar lacks any way to deal with any input after the first newline. Anything except EOF will draw a syntax error. regards, tom lane