Converting a lex scanner to flex, help needed

arnold@skeeve.com (Aharon Robbins)
Wed, 29 Dec 2021 20:54:01 -0000 (UTC)

          From comp.compilers

Related articles
Converting a lex scanner to flex, help needed arnold@skeeve.com (2021-12-29)
Re: Converting a lex scanner to flex, help needed arnold@skeeve.com (2021-12-30)
| List of all articles for this month |

From: arnold@skeeve.com (Aharon Robbins)
Newsgroups: comp.compilers
Date: Wed, 29 Dec 2021 20:54:01 -0000 (UTC)
Organization: Aioe.org NNTP Server
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="89764"; mail-complaints-to="abuse@iecc.com"
Keywords: lex, question, comment
Posted-Date: 29 Dec 2021 17:36:46 EST
Originator: arnold@skeeve.com (Arnold Robbins)

Hi.


I am trying to convert a V7 Unix vintage lex scanner to flex.


The rule


#.* {fixval(); xxbp = -1; return(xxcom); }


seems to be consuming as much as it can instead of stopping at
the first newline. When I look at the collected buffer, it
has multiple lines in it:


(gdb) p xxbuf
$7 = "# ========== ratfor in fortran for bootstrap ==========\n#\n# block data - initialize global variables\n#\nblock data\ncommon /cchar/ extdig(10), intdig(10), extlet(26), intlet(26), extbig(26), intbig(26"...


The program I am trying to modernize is 'struct', which reads Fortran and
produces Ratfor. The lex scanner is in the 'beautify' part. The whole
thing is at https://github.com/arnoldrobbins/struct. If you clone the
repo, check out the 'modernize' branch, and fix the makefile to compile
with gcc -m32, you will get working binaries. (64 bit and cleaning up
the warnings is work in progress.)


What am I doing wrong?


Thanks,


Arnold
--
Aharon (Arnold) Robbins arnold AT skeeve DOT com
[In flex a . doesn't match a newline. What do you see when you look at yytext, which
is the token it matched? The input buffer doesn't tell you anything very useful about
individual matched tokens. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.