• Advertisement

Archived

This topic is now archived and is closed to further replies.

using flex files with VC++.net

This topic is 5561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been messing around with the idea of writing a scripting system for my engine and I was reading about flex as a lexical analyzer instead of making my own. I understand how everything is working but I was wondering if anybody else has tried to compile the lex.yy.c files created by flex with a vc++.net project. I had one problem which I seemed to fix by creating an artificial function but I also get a linking 2019 error. Any help on how I can fix this would be appreciated. I''ve been stewing over this for the past day now. Thanks. Mat

Share this post


Link to post
Share on other sites
Advertisement
Last time I wrote a lexical analyzer, I made a program to spew the state table out to a file... it might be easier if you do it by hand, since Lexs don't get terribly complicated for typical scripting languages (programming languages are really simple for Lexs)


Also, on the parser side of things...

If you're really hard-core, you can use the .v (verbose) file output from yacc and hand-craft your parser .cpp file. I used ParGen once when I was writing a C parser, and I decided that the output .c file from yacc was a bunch of crap, so I wrote another parser that just took the .v intermediate file and wrote a .cpp file (NICE class based, unlike the name-collision-happy stuff that yacc used to spew)

This requires intimate knowledge of LALR or SLR parser logic... but can generate WAY more compact C++ parse tables than yacc does (or even a parse table in a data file to avoid code bloat).

You'll have to write all the code to do shift/reducing (my C parser had 218 reduce cases) manually instead of in the .y file, but you'll have WAY more control over the C++ code and linking issue.

If you want to get that far "under-the-hood", I've got a help-doc I wrote during my Compilers class at college.

[edited by - Nypyren on December 4, 2002 10:36:15 PM]

Share this post


Link to post
Share on other sites
Nypyren,

I would like to see that help doc before I decide if I will go through with writing everything myself. You can send it to my e-mail at doodah2001@hotmail.com. Thanks.

Mat

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The whole idea behing lex/yacc (flex/bison) is to *save* you time.

But I remember when I was "hardcore" and would do hand-tuning stuff like that. Turns out life is too short.

Perhaps if the original poster would share the exact error message, we could offer some concrete help. I am using flex/bison with VC++ 6 with no problems...

Share this post


Link to post
Share on other sites
Here is the exact error:

LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup.

I have a friend whos been using flex and bison and he said that he didn''t have a problem when he used it with VC++6 either. It has to be something specific with .net but I can''t figure it out. Any help would be appreciated.

Share this post


Link to post
Share on other sites

  • Advertisement