Jump to content

  • Log In with Google      Sign In   
  • Create Account


windows flex/bison parser freeze


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 assainator   Members   -  Reputation: 681

Like
0Likes
Like

Posted 23 April 2013 - 02:45 PM

Hello all,

 

I've been trying to build a compiler for learning purposes. I'm creating the lexer with gnu flex and a parser with bison. I've been using these tools on Linux but my main development platform is windows (Visual Studio). But last week I ran into a problem: When I run the parser, the application freezes. If I pause the application (using VS' debugger pause) it always stops at the same location in the C library.

 

The callstack:

stackb.jpg

 

The line of code at which the application pauses:

        else if ( !ReadFile( (HANDLE)_osfhnd(fh), buffer, cnt, (LPDWORD)&os_read,
                    NULL ) || os_read < 0 || (size_t)os_read > cnt)

 

I validated that the stream is valid and is the correct file.

 

I'm using the gnuwin32 version of flex on windows to generate the lexer.

 

I've reduced the flex file to:

%{
#include <iostream>
using namespace std;

#include "muse.tab.h"

#define YY_DECL extern "C" int yylex()
%}

%option yylineno

%%
.* { std::cout << "hello"; return T_USING; }		;
%%


  

Is there anyone who has encountered this issue before?


"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me


Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 13189

Like
1Likes
Like

Posted 23 April 2013 - 06:16 PM

Is there anyone who has encountered this issue before?

Not on Earth, but then again no one has ever made a parser that seeks .*.
Firstly, don’t do this. It matches 0 or more of any character, which means at the end of the file it can still keep matching things.
If you want to test it, just use ..


Even if that does not fix the problem, you should be able to fix it by loading the file manually and sending it as a byte stream. This is really better practice anyway for parsers and certainly a habit into which you will want to get for loading all types of things in the future.


L. Spiro


Edited by L. Spiro, 23 April 2013 - 06:16 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 assainator   Members   -  Reputation: 681

Like
0Likes
Like

Posted 24 April 2013 - 09:55 AM

Switching to parsing a byte stream fixed my issue. Thanks for the advice.


"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS