[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problems with bison-flex
From: |
Jim Michaels |
Subject: |
Re: problems with bison-flex |
Date: |
Mon, 13 Oct 2008 15:32:28 -0700 (PDT) |
fgets & fgetc stops when it reaches a ^z character (eof character) ^d on unix.
the batch mode flex does not I think do this, because it uses fread. however,
it might if you open the file in text mode instead of binary.
If you happen to want to lex a ^z or ^d this can be a problem!
will I need to redefine YY_INPUT in the case of a C++ lexer and parser?
The C++ lexer uses <iostream> (hence fstream) rather than <stdio.h>. this is
what I gathered from bison & flex 2.1 generated code.
how do I keep this on the mailing list? by forwarding it to address@hidden
Jim Michaels
address@hidden
http://JesusnJim.com
----- Original Message ----
From: Laurence Finston <address@hidden>
To: Jim Michaels <address@hidden>
Sent: Monday, October 13, 2008 3:30:23 AM
Subject: Re: problems with bison-flex
Another thing is that I had to redefine `YY_INPUT' as explained in the
Flex manual:
#define YY_INPUT(buf,result,max_size) \
{ \
signed char c = (signed char) fgetc(yyin); \
result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
}
This way, one character is read at a time. I'm assuming that `fgetc' uses
block reads --- I certainly hope so.
By the way, I'd appreciate it if you kept any further discussion on the
mailing list, so other people with the same questions can benefit from it.
Thanks.
The help-bison archives can be found here:
http://lists.gnu.org/archive/html/help-bison/
Laurence Finston