pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[BeginnerQuestion]Why I compile lex.yy.c failed?
2+ messages / 2 participants
[nested] [flat]

* [BeginnerQuestion]Why I compile lex.yy.c failed?
@ 2022-09-30 08:42 Wen Yi <chuxuec@outlook.com>
  2022-09-30 13:43 ` Re: [BeginnerQuestion]Why I compile lex.yy.c failed? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Wen Yi @ 2022-09-30 08:42 UTC (permalink / raw)
  To: pgsql-general

Hi community,
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’
  619 | #ifndef YY_BREAK
      |                            ^
/home/beginnerc/work/temp/example.l:3:2: note: in expansion of macro ‘YY_BREAK’
    3 | %%
      |  ^
[beginnerc@bogon temp]$

Can some one give me some suggestion?
Thanks in advance!
Yours,
JingZhang.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [BeginnerQuestion]Why I compile lex.yy.c failed?
  2022-09-30 08:42 [BeginnerQuestion]Why I compile lex.yy.c failed? Wen Yi <chuxuec@outlook.com>
@ 2022-09-30 13:43 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2022-09-30 13:43 UTC (permalink / raw)
  To: Wen Yi <chuxuec@outlook.com>; +Cc: pgsql-general

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-09-30 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 08:42 [BeginnerQuestion]Why I compile lex.yy.c failed? Wen Yi <chuxuec@outlook.com>
2022-09-30 13:43 ` Tom Lane <tgl@sss.pgh.pa.us>

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