Re: [BeginnerQuestion]Why I compile lex.yy.c failed?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wen Yi <chuxuec(at)outlook(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: [BeginnerQuestion]Why I compile lex.yy.c failed?
Date: 2022-09-30 13:43:41
Message-ID: 589577.1664545421@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Wen Yi <chuxuec(at)outlook(dot)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(at)bogon temp]$ flex '/home/beginnerc/work/temp/example.l'
> [beginnerc(at)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2022-09-30 15:36:47 Is there Postgres ODBC binary for OSX?
Previous Message Wen Yi 2022-09-30 08:42:46 [BeginnerQuestion]Why I compile lex.yy.c failed?