[antlr-interest] Antlr3 C Target
Tobias Pape
Das.Linux at gmx.de
Tue Mar 20 05:01:11 PDT 2007
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
KeywordOrIdentifier
: ( 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
antlr3inputstream.c:antlr3AsciiRewind
-------8<------
state = (pANTLR3_LEX_STATE)input->markers->get(input->markers,
&key);
/* 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));
------->8------
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,
-Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: Signierter Teil der Nachricht
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070320/59596194/attachment.bin
More information about the antlr-interest
mailing list