I have successfully build a small sample program using Flex. But I'm having
trouble with Bison.
I created a test grammar file (cut and paste from the documentation). When
I run bison, it complains about not finding bison.simple in C:\bin. After I
downloaded a copy of bison.simple from the net and stuck it in C:\bin, it
generated a file with large blocks of text (looks like some copyright
notice), with no comment markers (/* */) around them. Of course, it was not
able compile it. Can someone give me some info on how to use bison.
Examples and makefiles or batch files will be great!
Also, does the parse generated by bison require some proprietary library
routines?
Many thanks,
Xiaofeng Pan
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 05:15 AM 1/29/99 -0800, you wrote:
>Hello,
>
>This question is not very pertinent to Flex and Yacc on Windows. All
>the same, this is a problem I have been facing for quite some time.
>
>
>See the following code:
>
>#include<stdio.h>
>
>struct node
>{
> int i;
>};
>
>
>typedef void (*node)();
>
>void f1()
>{
> printf("Inside f1\n");
>}
>
>void main()
>{
> node i;
> int bool = 5;
> int node = 1;
>
> i = f1;
> (*i)();
>
> while(node < bool)
> {
> node++;
> }
>}
>
>In the above code we have a new type "node" and variable "node" of type
>int. This code is compilable in an ANSI C compiler. But ANSI C grammer
>gives a syntax error in "while" statement, since it has encountered a
>type
>name.
Well, the methodology that I use in order to insure that there aren't name
space problems is to define typedefs with a leading 'T', structure names
with all CAPS, and variables with lower case as appropriate.
I haven't tried that with the code above, but that would be the first step.
Why take a chance that the compiler might misinterpret your intentions?
>This is because of the way I implement check_type(). Whenever I come
>across a user defined type, I add it to a list. check_type() just
>checks whether the string passed to it exists in the list. If so it
>returns TYPE_NAME to the parser. Since something like
> int node = l;
>reduces to type_specifier type_specifier '=' CONSTANT , this method
>bombs. Could you suggest some means by which I can overcome this ?
enumerated lists..
>Also, are there any good references for handling syntax errors in Yacc ?
The Lex and YACC book from O'Reilly has some information on syntax
recovery. I'd also check the comp.compilers archives.
http://www.iecc.com/compilers/
Since that's a popular topic.
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
Hello,
This question is not very pertinent to Flex and Yacc on Windows. All
the same, this is a problem I have been facing for quite some time.
See the following code:
#include<stdio.h>
struct node
{
int i;
};
typedef void (*node)();
void f1()
{
printf("Inside f1\n");
}
void main()
{
node i;
int bool = 5;
int node = 1;
i = f1;
(*i)();
while(node < bool)
{
node++;
}
}
In the above code we have a new type "node" and variable "node" of type
int. This code is compilable in an ANSI C compiler. But ANSI C grammer
gives a syntax error in "while" statement, since it has encountered a
type
name.
This is because of the way I implement check_type(). Whenever I come
across a user defined type, I add it to a list. check_type() just
checks whether the string passed to it exists in the list. If so it
returns TYPE_NAME to the parser. Since something like
int node = l;
reduces to type_specifier type_specifier '=' CONSTANT , this method
bombs. Could you suggest some means by which I can overcome this ?
Also, are there any good references for handling syntax errors in Yacc ?
Regards Ghins
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 10:40 PM 1/27/99 +0100, you wrote:
>I found a solution by myself, but it's not perfect yet .. I'm using a
>lexical analyzer lex.yy.c, which I am compiling as standard C code. The
>grammar analyzer analyzer.tab.cpp is produced by bison, as well as his
>analyze.tab.cpp.h associated header. analyzer.tab.cpp is compiled as a
>C++ file because I need to include some generic C++ headers there. Now
>the trouble shows up at link time :
>lex.yy.c refers to 'extern YYSTYPE yylval;' through the
>analyze.tab.cpp.h header, and because of Naming Conventions, it looks
>for _yylval and cannot find it.
>The obvious solution is to edit analyze.tab.cpp, look for 'YYSTYPE
>yylval;' declaration, and change it to 'extern "C" { YYSTYPE yylval; }'
>.. I checked and it works. HOW CAN I GET BISON TO DO THAT BY HIMSELF ?
Well, I don't know about the specifics of what your doing, but in the
general case, when I have functions or variables that are going to be used
in both C and C++ I use the following code
#ifdef __cplusplus
extern "C" {
#endif
int SomeCFunction(void);
extern SomeCVariable;
#ifdef __cplusplus
}
#endif
To resolve the C/C++ name mangling issues. But I avoid using C++ whenever
possible.
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 06:11 PM 1/27/99 +0100, you wrote:
>I'm rather new to this list, so I have a few questions / suggestions
>first :
>
>1) I'm using flex and bison provided with stuff I downloaded from cygnus
>at http://www.cygnus.com (cygwin-b20) .. are we speaking of the same
>software here ?
No. The Flex is a custom port from the original source from Vern Paxson
downloaded from ftp.ee.lbl.gov version 2.5.2. The BISON is a custom port
from the GNU uploaded version of May 1995.
>2) I remember coming to this list from a main page somewhere (your page
>Wilbur) .. but I can't find a link to it from the egroups flexbisonwin32
>homepage. I'm dumb or we miss a link ?
We are missing a link in the global egroups index. I've tried to get them
to pay attention to that, but so far no luck.
http://www.egroups.com/list/flexbisonwin32
is the address to the list on the web.
>Now for the real stuff :
>I ran some tests with mixed lexical analysis (flex) and grammar (bison)
>.. it compiles fine with the GNU C compiler for windows. Now for a real
>project I need to use VC++ .. I can't compile my files with ANSI C
>(using __STDC__ define) because I need to include a global header which
>is a C/C++ mix. So I have files with .cpp extension, and __cplusplus
>defined. The compiler goes crazy when compiling lex.yy.cpp .. what's
>going wrong ?
Depends on the compiler errors. I don't know the GNU C compiler.
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
I found a solution by myself, but it's not perfect yet .. I'm using a
lexical analyzer lex.yy.c, which I am compiling as standard C code. The
grammar analyzer analyzer.tab.cpp is produced by bison, as well as his
analyze.tab.cpp.h associated header. analyzer.tab.cpp is compiled as a
C++ file because I need to include some generic C++ headers there. Now
the trouble shows up at link time :
lex.yy.c refers to 'extern YYSTYPE yylval;' through the
analyze.tab.cpp.h header, and because of Naming Conventions, it looks
for _yylval and cannot find it.
The obvious solution is to edit analyze.tab.cpp, look for 'YYSTYPE
yylval;' declaration, and change it to 'extern "C" { YYSTYPE yylval; }'
.. I checked and it works. HOW CAN I GET BISON TO DO THAT BY HIMSELF ?
Seems I'm stuck here .. :-)
Timothee Besset wrote:
>
> I'm rather new to this list, so I have a few questions / suggestions
> first :
>
> 1) I'm using flex and bison provided with stuff I downloaded from cygnus
> at http://www.cygnus.com (cygwin-b20) .. are we speaking of the same
> software here ?
> 2) I remember coming to this list from a main page somewhere (your page
> Wilbur) .. but I can't find a link to it from the egroups flexbisonwin32
> homepage. I'm dumb or we miss a link ?
>
> Now for the real stuff :
> I ran some tests with mixed lexical analysis (flex) and grammar (bison)
> .. it compiles fine with the GNU C compiler for windows. Now for a real
> project I need to use VC++ .. I can't compile my files with ANSI C
> (using __STDC__ define) because I need to include a global header which
> is a C/C++ mix. So I have files with .cpp extension, and __cplusplus
> defined. The compiler goes crazy when compiling lex.yy.cpp .. what's
> going wrong ?
>
> note : I'm not trying to use the C++ scanner feature, because the parser
> will have to deal with C only stuff. I could write alternate headers and
> remove the C++ parts, but that would be the dirty way.
>
> Thanx
>
> --
> Timothee Besset
> ECL - Promo 99
> http://www.mygale.org/01/besset
> MGS http://www.planetquake.com/mgs
>
> ------------------------------------------------------------------------
> eGroup home: http://www.eGroups.com/list/flexbisonwin32
> Free Web-based e-mail groups by eGroups.com
--
Timothee Besset
ECL - Promo 99
http://www.mygale.org/01/besset
MGS http://www.planetquake.com/mgs
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
I'm rather new to this list, so I have a few questions / suggestions
first :
1) I'm using flex and bison provided with stuff I downloaded from cygnus
at http://www.cygnus.com (cygwin-b20) .. are we speaking of the same
software here ?
2) I remember coming to this list from a main page somewhere (your page
Wilbur) .. but I can't find a link to it from the egroups flexbisonwin32
homepage. I'm dumb or we miss a link ?
Now for the real stuff :
I ran some tests with mixed lexical analysis (flex) and grammar (bison)
.. it compiles fine with the GNU C compiler for windows. Now for a real
project I need to use VC++ .. I can't compile my files with ANSI C
(using __STDC__ define) because I need to include a global header which
is a C/C++ mix. So I have files with .cpp extension, and __cplusplus
defined. The compiler goes crazy when compiling lex.yy.cpp .. what's
going wrong ?
note : I'm not trying to use the C++ scanner feature, because the parser
will have to deal with C only stuff. I could write alternate headers and
remove the C++ parts, but that would be the dirty way.
Thanx
--
Timothee Besset
ECL - Promo 99
http://www.mygale.org/01/besset
MGS http://www.planetquake.com/mgs
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 11:05 PM 1/20/99 -0000, you wrote:
>Okay, I have a (stupid?) question about how yacc allocates and deallocates
>memory for action values as it works its way through a grammar. Hopefully,
>I can phrase this sensibly.
Well, FLEX does the allocation based on the way that I believe that it
works. The token structure is allocated by Flex and then passed off to
BISON. (checking the generated code to be sure..) Well, not actually, the
YYSTYPE structure, which is generated from the %union tag is used as the
basis for creating a stack of structures which are manipulated by the
reduction parts of the YACC grammer.
The yylval variable, a YYSTYPE structure ( defined with the structure
defined by the %union YACC construct), is passed available as an extern
variable through the included ????_tab.h file which is generated by BISON.
So what happens is that YACC starts with an empty stack, and as tokens are
parsed in Flex, they are passed back to BISON as items on the stack. The
top of the stack is then checked to see if it matches any particular
patterns, and if there is no pattern match, Flex is called again for
another token. (This behaviour is a general description..
So in effect, what happens is that tokens that are parsed by Flex are
pushed onto the BISON stack, and as the stack grows, the top of the stack
is checked for matching rules.
Now, in the case that a rule is matched, the matching tokens are popped off
the stack, (the right side of the rule), and the left side of the rule, $$,
is left on the top of the stack.. then the stack is once again checked for
matching rules..
>If I am trying to build, say, a linked list of items which contain some of
the
>string values returned by flex, do I need to allocate memory for an action's
>return value ($$) immediately or will the stack keep these string pointers
>valid so that higher-level rules may operate on them? If I simply assign
$$ to
>the yytext string returned from flex, how long is that pointer valid and
>pointing to the original string?
The yytext string is fixed, and only guarenteed to last as long as you are
in the body of the matched Flex rule. I immediately duplicate the string
value and point a structure member that is a part of the %union definition
into the to the allocated string. That YYSTYPE element will only last as
long as the value is not matched on the right side of a YACC/BISON rule, so
if I want the string to persist, I pass the address over in the YACC rule,
or I free up the memory.
>Hope this makes sense.
I hope what I wrote makes sense. Anyway, if you want to do a linked list,
then I suggest that you set up the linkage yourself and are very specific
about the memory management.
>Also, a REALLY dumb question, since I am new to this list: How can I get my
>little Post window in which I'm typing this message to wrap when I'm typing
>the text of my message?
Use an email program? You can send email messages to
"flexbisonwin32@egroups.com"
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
Okay, I have a (stupid?) question about how yacc allocates and deallocates
memory for action values as it works its way through a grammar. Hopefully,
I can phrase this sensibly.
If I am trying to build, say, a linked list of items which contain some of the
string values returned by flex, do I need to allocate memory for an action's
return value ($$) immediately or will the stack keep these string pointers
valid so that higher-level rules may operate on them? If I simply assign $$ to
the yytext string returned from flex, how long is that pointer valid and
pointing to the original string?
Hope this makes sense.
Also, a REALLY dumb question, since I am new to this list: How can I get my
little Post window in which I'm typing this message to wrap when I'm typing
the text of my message?
Thanks in advance.
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
>
> Like Imran said, it sounds to me like the token values are different in the
> two programs. But it could be writing it to a file.
That's what it was but not how I expected it..
It turned out that Visual C++ was not properly rebuilding all the files
everytime, so lex and yacc were out of sync..
Thanks for trying to help!!
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 09:06 AM 1/18/99 +0100, you wrote:
>anything sensible. (to test it, I run yylex the normal way on the whole
>input file first, generating the lex output to a file, then I parse the
>input file with yyparse.)
Hmm.. maybe file read problems?
>What I get is a string of tokens that have nothing to do with the input
>file and I don't know what is happening.
>
>Why could this be happening?
Like Imran said, it sounds to me like the token values are different in the
two programs. But it could be writing it to a file.
Specifically print out the values of the tokens as they are generated in
Flex and as they are read in in BISON, if the numeric values are constant,
then it's the #defines, if the numeric values differ, I'd look at the I/O
routines.
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
#defined values for tokens should be insync between flex and bison.
there are two ways to do it,
either you define token in grammer specs and #define values your self for both
of your
lexer and parser
or you generate your parser with the option to generate y_tab.h then these
tokens are #defined
by the Bison. in this case you should discard your version of #defined values.
As far as i understand your problem, you are mixing both of these approaches and
certian token are twice
defined in your project once by you and once in y_tab.h. now what will be
happening that your lexer will be returning
your version of values where as bison will be expecting its version of values
which woulb be resulting in the strange behaviour.
Regards,
Imran Zafar
<36a2eb70.fd9a440-@...> wrote:
Original Article: http://www.egroups.com/list/flexbisonwin32/?start=18
>
>
> Wilbur Streett wrote:
> >
> > At 03:54 PM 1/17/99 -0000, you wrote:
> > >Has anyone else encountered the problem of Flex messing up entirely
> > >when using the y_tab.h include instead of a self-defined header file, in
> > >Visual C++?
> > >It lexes fine when I use my own file, but it generates the strangest random
> > >sequence of tokens when I let Bison do it.
> >
> > I don't follow what you're saying.. the lex is done by Flex. Bison does
> > the token manipulation and stack management..
> >
> > Yes, there is a file with token values that is generated from BISON, which
> > is typically included in the generated C file from Flex.. But I'm not
> > following what you're saying. Can you be more concrete?
>
>
> Ok I'll give it a shot (I'm crap at explaining things).
> I've used flex and bison before (well Lex and Yacc on a Unix and a Linux
> system), so I know what to do under normal circumstances.
> Now I wanted to use it for a Win95 project, so I downloaded the Win32
> ports of Flex and Bison, and wrote my lexical specification and my
> grammar.
>
> Now, when I'm only doing the lexing, using only the lexical
> specification and a header-file full of #defines of the tokens starting
> at 257 (which I believe is the correct way, no?) it does everything
> fine, I generate a nice output file with all the correct tokens.
> Now when I try the same thing using the y_tab.h header file generated by
> my grammar, with the same tokens defined, the lexer no longer generates
> anything sensible. (to test it, I run yylex the normal way on the whole
> input file first, generating the lex output to a file, then I parse the
> input file with yyparse.)
> What I get is a string of tokens that have nothing to do with the input
> file and I don't know what is happening.
>
> Why could this be happening?
>
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
Wilbur Streett wrote:
>
> At 03:54 PM 1/17/99 -0000, you wrote:
> >Has anyone else encountered the problem of Flex messing up entirely
> >when using the y_tab.h include instead of a self-defined header file, in
> >Visual C++?
> >It lexes fine when I use my own file, but it generates the strangest random
> >sequence of tokens when I let Bison do it.
>
> I don't follow what you're saying.. the lex is done by Flex. Bison does
> the token manipulation and stack management..
>
> Yes, there is a file with token values that is generated from BISON, which
> is typically included in the generated C file from Flex.. But I'm not
> following what you're saying. Can you be more concrete?
Ok I'll give it a shot (I'm crap at explaining things).
I've used flex and bison before (well Lex and Yacc on a Unix and a Linux
system), so I know what to do under normal circumstances.
Now I wanted to use it for a Win95 project, so I downloaded the Win32
ports of Flex and Bison, and wrote my lexical specification and my
grammar.
Now, when I'm only doing the lexing, using only the lexical
specification and a header-file full of #defines of the tokens starting
at 257 (which I believe is the correct way, no?) it does everything
fine, I generate a nice output file with all the correct tokens.
Now when I try the same thing using the y_tab.h header file generated by
my grammar, with the same tokens defined, the lexer no longer generates
anything sensible. (to test it, I run yylex the normal way on the whole
input file first, generating the lex output to a file, then I parse the
input file with yyparse.)
What I get is a string of tokens that have nothing to do with the input
file and I don't know what is happening.
Why could this be happening?
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 03:54 PM 1/17/99 -0000, you wrote:
>Has anyone else encountered the problem of Flex messing up entirely
>when using the y_tab.h include instead of a self-defined header file, in
>Visual C++?
>It lexes fine when I use my own file, but it generates the strangest random
>sequence of tokens when I let Bison do it.
I don't follow what you're saying.. the lex is done by Flex. Bison does
the token manipulation and stack management..
Yes, there is a file with token values that is generated from BISON, which
is typically included in the generated C file from Flex.. But I'm not
following what you're saying. Can you be more concrete?
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
Has anyone else encountered the problem of Flex messing up entirely
when using the y_tab.h include instead of a self-defined header file, in
Visual C++?
It lexes fine when I use my own file, but it generates the strangest random
sequence of tokens when I let Bison do it.
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 04:07 PM 1/13/99 -0000, you wrote:
>I was wondering if I compiled my parser into a Windows DLL and called it
from
>another program, if it was possible to have yyparse return a user-specified
>data structure. I suppose I could have my rule actions build my data
structure
>in a global and then write a support function which I publish in the DLL and
>whose purpose is to return the global data structure.
>
>Thoughts?
I see YYPARSE_PARAM being passed in as a define to yyparse.. I don't
recall it being documented in the documentation, but it's in the generated
C source from BISON.
It's a void * structure..
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
I was wondering if I compiled my parser into a Windows DLL and called it from
another program, if it was possible to have yyparse return a user-specified
data structure. I suppose I could have my rule actions build my data structure
in a global and then write a support function which I publish in the DLL and
whose purpose is to return the global data structure.
Thoughts?
-kirk
------------------------------------------------------------------------
eGroup home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
How do I use flex and bison with C++Builder.?
(I only get error msg. under comp.)
------------------------------------------------------------------------
E-group home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
Hi,
I am defining the YYERROR_VERBOSE macro to get meaningfull syntax error
messages.
If I define the YYERROR_VERBOSE macro in my bison specs then the genertaed code
does not compile, it give errors relating to a variable 'yytname' which is not
defined but is used in this macro.
If any body has used this feature and has a clue to this problem please let me
know.
Regards,
Imran Zara
izafar@...
------------------------------------------------------------------------
E-group home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
I successfully generate the c scanner with Flex but when i used c++ option, the
generated code does not compile.
i used the following command to generate the code
Flex -+ -oMyOutPutFile.CPP MyLexSpecs.L
on compiling MyOutPutFile.CPP in VC5 i got 19 compilation errors relating to
method
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
the errors are like yy_flex_debug is set to 0 but that is not a member variable
of the class.
Please reply if any body has a clue to this.
Regards,
Imran Zafar
------------------------------------------------------------------------
E-group home: http://www.eGroups.com/list/flexbisonwin32
Free Web-based e-mail groups by eGroups.com
At 07:14 PM 12/13/98 -0800, you wrote:
>Hi,
>
>This is what I found in my version of MSVC++ 5.0 as far as _MSC_VER,
>it is a direct copy and paste from the help.
>
>start extract ----------------
>_MSC_VER
> Defines the compiler version. Defined as 1100 for Microsoft Visual C++™
>5.0. Always defined.
>
>_MT
> end extract-----------------
>Hope that is helpful.
Good enough for my purposes.. Anyone got the information for Version 6?
>What version is the version of the flex that you have? 2.54?
The WIN32 port is of version 2.5.2
I just read the NEWS file for 2.5.4 today, and I didn't see that much in
the way of issues that are likely to cause problems in people using the
2.5.2 version..
Vern Paxson, (the Flex author), and I talked about the update a while ago.
I never checked out the changes that I did to make sure that they didn't
affect other platform's compiles, so I haven't released the source to the
port that I did. To be honest, I don't remember much of the porting work.
I may run a diff against the 2.5.2 version and then make the same
modifications to the 2.5.4 version, but I haven't seen much need..
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
At 07:06 PM 12/13/98 -0800, you wrote:
<snip>
>The FlexLexer.h header file includes <iostream.h>. When using the STL you
>must use their version of the
>iostream library. So in my program I am including <iostream> <-- the
>iostream library when using the STL.
>
>But this is not compatible with <iostream.h>, you get all kinds of ambiguous
>errors when you include <iostream>
>with <iostream.h>... I tried to change the flexlexer.h file so that instead
>of including <iostream.h> it includes <iostream>, but unfortunetly it was
>not that simple. I get other errors in FlexLexer.h.
>
>So now I am stuck, I do not know what to do because flexlexer.h is not
>compatible with the STL. I wrote the same
>program on unix, SunOs, linux, and HPUX. It works fine when I using the
>standard template library with Lexyy.cpp and FlexLexer.h. But when trying
>to compile my program with the windows version of flex, it is just not
>working.
>
>I am using MSVC++ 5.0 and using there implementation of the STL.
>
>My program needs to be portable to unix and windows95, winnt. That is why I
>am trying so hard to get things to work.
>
>If you can, could you please help me. There are incompatibilites with flex
>when it comes to generating a c++ scanner. It should not be generating a
>file that includes unistd.h and it should allow for the STL. The reason I
>say this is because the flex SunOs, HPUX, Linux Unix works fine.
Well, it sounds like the windows iostream routines aren't quite compatible
with the rest of the world. (What a shock! ;-P )
While I've read a lot of books on C++, I decided to avoid using it, so this
suggestion is based on conceptual but not actual "hands on" experience. I
believe that you can override the input routines in FLEX by overriding the
input and other macro's which are defined in the FLEX runtime. This option
is documented in the flex man pages, which are up on the web site. At
least that would be my first approach..
The second thought is that I recall some discussion where the STL
implementation from Microsoft just isn't compatible, and someone suggested
using publically available versions instead. (I don't have a clue where to
find them other than an Internet search..)
Anyone else got any ideas?
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
Hi,
This is what I found in my version of MSVC++ 5.0 as far as _MSC_VER,
it is a direct copy and paste from the help.
start extract ----------------
_MSC_VER
Defines the compiler version. Defined as 1100 for Microsoft Visual C++™
5.0. Always defined.
_MT
end extract-----------------
Hope that is helpful.
What version is the version of the flex that you have? 2.54?
Thanks,
Hinry Joseph Jr.
-----Original Message-----
From: Wilbur Streett <WStreett@...>
To: flexbisonwin32@egroups.com <flexbisonwin32@egroups.com>
Date: Sunday, December 13, 1998 12:02 PM
Subject: [flexbisonwin32] unistd.h file not found in CPP generated files
from Flex..
|I've recieved a note that the #include for <unistd.h> apparently doesn't
|work in the output file of Flex targeted at C++ when it's compiled with
|MSVC.
|
|As a temporary work around, rather than having to delete those lines after
|every build, I've suggested putting an empty unistd.h file in the project
|directory, (you may have to also add "." to the standard include
|directories in the project properties).
|
|At the present time, it appears that the best way to fix this problem is to
|wrap all of the #include <unistd.h> lines in the Flex.skl file with a
|#ifndef _MSC_VER like below:
|
|#ifndef _MSC_VER
|#include <unistd.h>
|#endif
|
|The flex.skl file is processed by the mkskel.sh to generate the skel.c file
|which as part of of the Flex executable contains the skel[] character array
|with the default C skeleton used as the basis for the Flex generated
parser.
|
|In the MSVC 4.2 documentation "standard defines" and "preprocessor defines"
| documentation it appears that _MSC_VER is the best variable to use to
|determine that the compile is Microsoft Visual C. I'd appreciate some
|feedback before I make the change the flex.skl file, since the version on
|the web page has been stable for several years.. I crashed my hard disk
|about 5 months ago and despite having 2 licenses for MSVC version 5.0,
|don't have the CD, so I'm back to running 4.2 and can't check the validity
|of my assumption. I'd appreciate it if someone checks out MSVC 5.0 and 6.0
|documentation so that I'm sure that this change is appropriate for those
|versions as well.
|
|Wilbur
|
|
|
| --------------------------------------------
| Putting A Human Face On Technology ;-)
| --------------------------------------------
|------------------------------------------------------------------------
|Great gifts for the Holidays or birthdays or anyday for that matter
|Bugs Life action game, Thanksgiving Pooh, Disney videos, toys and CD-ROMs
|http://ads.egroups.com/click/145/1
|
|Free Web-based e-mail groups -- http://www.eGroups.com
|
|
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
Hi I emailed you before about the problem that I have with unistd.h but now
I have encountered another problem.
I resolved the problem with unistd.h, i just created the dummy unistd.h and
it worked fine.
The problems are as follows,
When I tried to use the Standard Template
Library I have a problem.
The FlexLexer.h header file includes <iostream.h>. When using the STL you
must use their version of the
iostream library. So in my program I am including <iostream> <-- the
iostream library when using the STL.
But this is not compatible with <iostream.h>, you get all kinds of ambiguous
errors when you include <iostream>
with <iostream.h>... I tried to change the flexlexer.h file so that instead
of including <iostream.h> it includes <iostream>, but unfortunetly it was
not that simple. I get other errors in FlexLexer.h.
So now I am stuck, I do not know what to do because flexlexer.h is not
compatible with the STL. I wrote the same
program on unix, SunOs, linux, and HPUX. It works fine when I using the
standard template library with Lexyy.cpp and FlexLexer.h. But when trying
to compile my program with the windows version of flex, it is just not
working.
I am using MSVC++ 5.0 and using there implementation of the STL.
My program needs to be portable to unix and windows95, winnt. That is why I
am trying so hard to get things to work.
If you can, could you please help me. There are incompatibilites with flex
when it comes to generating a c++ scanner. It should not be generating a
file that includes unistd.h and it should allow for the STL. The reason I
say this is because the flex SunOs, HPUX, Linux Unix works fine.
Please Help.
Thank You
regards,
Hinry Joseph Jr.
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
I've recieved a note that the #include for <unistd.h> apparently doesn't
work in the output file of Flex targeted at C++ when it's compiled with
MSVC.
As a temporary work around, rather than having to delete those lines after
every build, I've suggested putting an empty unistd.h file in the project
directory, (you may have to also add "." to the standard include
directories in the project properties).
At the present time, it appears that the best way to fix this problem is to
wrap all of the #include <unistd.h> lines in the Flex.skl file with a
#ifndef _MSC_VER like below:
#ifndef _MSC_VER
#include <unistd.h>
#endif
The flex.skl file is processed by the mkskel.sh to generate the skel.c file
which as part of of the Flex executable contains the skel[] character array
with the default C skeleton used as the basis for the Flex generated parser.
In the MSVC 4.2 documentation "standard defines" and "preprocessor defines"
documentation it appears that _MSC_VER is the best variable to use to
determine that the compile is Microsoft Visual C. I'd appreciate some
feedback before I make the change the flex.skl file, since the version on
the web page has been stable for several years.. I crashed my hard disk
about 5 months ago and despite having 2 licenses for MSVC version 5.0,
don't have the CD, so I'm back to running 4.2 and can't check the validity
of my assumption. I'd appreciate it if someone checks out MSVC 5.0 and 6.0
documentation so that I'm sure that this change is appropriate for those
versions as well.
Wilbur
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
At 10:51 AM 12/13/98 -0000, you wrote:
>Can anybody explain how I should configure Flex/Bison for compilation with
MSVC 6? I do not have a Unix/Linux system, so the shell scripts are no use
to me.
Well, I typically configure the Lex and Yacc files so that they are
included as files in the project file. (I'm speaking from the MSVC 5.0
perspective.. I haven't seen 6.0 yet.. but I assume it got the same
mechanism). I make the file extensions .lex and .y and then set up a
custom compile event for the files, with the appropriate flex and bison
options.
The "Custom Build" settings can be access from the Project Settings window
by selecting the particular file in the particular build configuration.
Assuming a file called "obj.lex" the flex command that I use is
flex -i -f -oobjl.c obj.lex
the -oobjl.c tell flex that the output to generate should be named objl.c
and the BISON command for obj.y would be
bison -t -d -v obj.y
which by default generates obj_tab.c and obj_tab.h
You have to specify the output file names in the "Custom Build" output
files section.
I then apply the changes to the project, select OK to return to the normal
build, and then either build the entire project or right click on the .lex
and .y files to trigger a compile. This causes the MSVC IDE to run Flex
and BISON generates the output files. I then add the resulting .c files to
the project and run a total build to make sure that the project builds OK.
What this allows you to do is directly edit the Lex and YACC source files,
and when you press "F7" the IDE will automatically save the files, and
trigger the flex and BISON exeuctions and do the rest of the compilation
for the project.
As a cautionary note, there is a horrible file buffering problem in the
MVSC 4.0 and 4.1 IDE that causes the builds to exhibit erratic behaviour.
I wasted 3 days finding it. So don't use this technique with those
versions. (I hope the bug didn't come back in 6.0..)
Wilbur
Because of a number of issues, I typically have to copy Flex.exe and it's
supporting files and BISON.exe and it's supporting files into the project
directory so that the commands work properly. I then run the build once to
create the
--------------------------------------------
Putting A Human Face On Technology ;-)
--------------------------------------------
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
Hello everyone,
Can anybody explain how I should configure Flex/Bison for compilation with MSVC
6? I do not have a Unix/Linux system, so the shell scripts are no use to me.
Thanks!
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
Hello,
Could anybody tell me if I can get flexbisonwin32 by HTTP and from which server
?
I have only HTTP, not FTP.
If it is not possible, could anybody send it to me by mail (at
eric.buleon@...) ?
Thanks.
Eric
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com
For some reason that I do not understand when
I generate a c++ scanner with the -+ option the
lexyy.cc file tries to include unistd.h? This
makes it imposible for me to compile things with
msvc++. How can I fix this? And why would
flex for win32 even attempt to include this file?
Is there anyway that I can compile a generated c++ scanner with MSVC++ 5.0?
Please Help
Please Respond to hinryj@...
Thank You.
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com