[antlr-interest] How to make the lexer thread-safe (C target)?
Jim Idle
jimi at temporal-wave.com
Tue Jul 26 11:09:43 PDT 2011
@lexer::context
{
ANTLR3_BOOLEAN double_quoted; // blah
}
@lexer::apifuncs
{
lexCtx-> double_quoted = ANTLR3_FALSE; // Init
}
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mu Qiao
> Sent: Tuesday, July 26, 2011 5:08 AM
> To: antlr-interest Interest
> Subject: [antlr-interest] How to make the lexer thread-safe (C target)?
>
> Hello,
>
> My lexer has to rely on some internal status like the following:
>
> DQUOTE : '"' { if(LA(-1) != '\\') double_quoted = !double_quoted;
> };
> SQUOTE : { double_quoted }? => '\'';
> SINGLE_QUOTED_STRING_TOKEN : { !double_quoted }? => '\'' .* '\'';
>
> "double_quoted" is a bool variable declared in @member section. The
> generated code will declare it in global scope, which is not thread
> safe. I wonder if there is any way to make the lexer thread-safe? For
> example declare the variable in xxxLexer_Ctx_struct.
>
> --
> Best wishes,
> Mu Qiao
> GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5 3ACC 30B3 0DE4 17B1 57E9
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address
More information about the antlr-interest
mailing list