CSharp parser performance

Roberto Raggi roberto at kdevelop.org
Mon Aug 7 10:53:37 UTC 2006


Hi Jakob!

On Sunday 06 August 2006 02:38, Jakob Petsovits wrote:
> > I've also determined that the C# parser suffers multi-threading problems.
> > When I run more than one parse at a time in multiple threads, I get
> > crashes. This probably has to do with the static variables.  Especially
> > the
> >
> > char *_G_contents;
> >
> > variable.
please, can you send the me an example?

>
> I'll move that one away, but it's not the problem here (rather a symptom).
> The real problem is Flex, which is storing its state between subsequent
> calls of yylex(). So this is maybe the right time for me to try out Flex'
> "experimental" C++ class mode.

global functions are pretty bad, so you're right we don't want to use a 
global "yylex()", but this isn't really a problem with flex :-) the trick is 
to use the YY_DECL macro. For example,



%{

// compile with flex -oscanner.cpp scanner.l && g++ scanner.cpp

#define YY_DECL int Scanner::yylex()

class Scanner
{
public:
  int yylex ();
};

%}

%option noyywrap

%%

"roberto" {
  return 1976;
}

. {
  return yytext [0];
}

%%

int main ()
{
  Scanner scanner;

  while (scanner.yylex ())
    ;

  return 0;
}


> Your favorite parser guy,
hehehe :-)

ciao robe

-- 
Roberto Raggi - roberto at kdevelop.org
KDevelop http://www.kdevelop.org




More information about the KDevelop-devel mailing list