Converting a lex scanner to flex, help needed (Aharon Robbins)
Wed, 29 Dec 2021 20:54:01 -0000 (UTC)

          From comp.compilers

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

From: (Aharon Robbins)
Newsgroups: comp.compilers
Date: Wed, 29 Dec 2021 20:54:01 -0000 (UTC)
Organization: NNTP Server
Injection-Info:; posting-host=""; logging-data="89764"; mail-complaints-to=""
Keywords: lex, question, comment
Posted-Date: 29 Dec 2021 17:36:46 EST
Originator: (Arnold Robbins)


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 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?


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.