[antlr-interest] Antlr3 C Target

Jim Idle jimi at temporal-wave.com
Tue Mar 20 09:18:13 PDT 2007

Actually, I am just working on the examples for the C output, along with
a "How to do X in C" bit too.

I will try to look at your suspected bug - I have not seen anything like
that myself (or I would have fixed it ;-).


-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Tobias Pape
Sent: Tuesday, March 20, 2007 5:01 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Antlr3 C Target

Hello everyone,

can anyone here provide an example using the C-Target?
There is simply _no_ documentation, sadly.

Currently I try to simply "match" an inputfile against an lexer/parser.

I'm stuck with the following:

Input is:

  Hello = ( blabla

Now I've got an rule (grammar transformed from an antlr2 java project):

// $ANTLR src "SOMclean.g" 320
   : ( Keyword Keyword) => KeywordSelector { $type=KeywordSelector; }
   | ( Keyword )        => Keyword         { $type=Keyword;    }
   | ( Primitive )      => Primitive       { $type=Primitive;  }
   | ( Identifier )     => Identifier      { $type=Identifier; }

So, it uses an DFA to match it. It does, in fact, match.
but when (found out by tracing the libantlr3c-source) trying to rewind
(aparently this can be interesting to Jim Idle,
  it seems to me, that there's a glitch in


    state   = (pANTLR3_LEX_STATE)input->markers->get(input->markers,  

     /* Seek input pointer to the requested point (note we supply the
void *pointer
      * to whatever is implementing the int stream to seek).
     is->seek(is, ANTLR3_UINT64_CAST(state->nextChar));


that is, if theres no marker in the bucket for the key (that was, as it
turned out,
bucket->entries == NULL))
state->nextChar is an invalid reference)

Sorry for the C in here, but I'm a bit confused with all that...

so long,

More information about the antlr-interest mailing list