[antlr-interest] How to make the lexer thread-safe (C target)?

Gokulakannan Somasundaram gokul007 at gmail.com
Tue Jul 26 06:51:15 PDT 2011


I had a similar requirement. I maintained a class LexerContext in a Thread
local variable and accessed it and modified it. There might be better
solutions.

Thanks,
Gokul.

On Tue, Jul 26, 2011 at 8:07 PM, Mu Qiao <qiaomuf at gmail.com> wrote:

> 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