From: Tom Lane <tgl@sss.pgh.pa.us>
To: Wen Yi <chuxuec@outlook.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: [BeginnerQuestion]Why I compile lex.yy.c failed?
Date: Fri, 30 Sep 2022 09:43:41 -0400
Message-ID: <589577.1664545421@sss.pgh.pa.us> (raw)
In-Reply-To: <TYAP286MB06368D99921B88BA8E957A48A9569@TYAP286MB0636.JPNP286.PROD.OUTLOOK.COM>
References: <TYAP286MB06368D99921B88BA8E957A48A9569@TYAP286MB0636.JPNP286.PROD.OUTLOOK.COM>
Wen Yi <chuxuec@outlook.com> 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 ¡®yylex¡¯:
> lex.yy.c:619:28: error: expected ¡®;¡¯ before ¡®break¡¯
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, chuxuec@outlook.com
Subject: Re: [BeginnerQuestion]Why I compile lex.yy.c failed?
In-Reply-To: <589577.1664545421@sss.pgh.pa.us>
References: <TYAP286MB06368D99921B88BA8E957A48A9569@TYAP286MB0636.JPNP286.PROD.OUTLOOK.COM> <589577.1664545421@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox