BecomeBetter
BecomeBetter

Reputation: 433

How to use flex option -o (--output=FILE)

I met a problem when trying to flex abcd.l. I wanted to redirect the output to a new file instead of the default one lex.yy.c I looked up it in manual finding an option -o(--output=FILE) so I changed my command to flex xx.l -o lex.yy.1.c but error occurs.

flex: can't open --outfile=lex.yy.1.c
/usr/bin/m4:stdin:2621: ERROR: end of file in string

My working environment is cygwin and windows 7

Upvotes: 6

Views: 5190

Answers (1)

rici
rici

Reputation: 241811

You need to put command line options before positional arguments:

flex -o lex.yy.1.c xx.l

Once a positional (filename) argument is recognized, flex assumes that all following arguments are also filenames. This is the normal form of argument processing for command-line utilities, although some (gcc, for example) allow options to follow the filenames.

(Personally, I'd suggest using a filename like xx.lex.c, but the principle is the same.)

Upvotes: 12

Related Questions