[antlr-interest] Writing Delphi Target for Antlr3
service
service at sharpplus.com
Sat May 26 23:43:16 PDT 2007
I just change declare alt<decisionNumber> to access a global arrary _alt property. The alt array is declared in the base lexer class. for example
TCLexer=class(TAntlrLexer)
....
property _alt[Index:Integer]:Integer;
end;
then, generated source will like following code
procedure TCLexer.mIDENTIFIER();
var
_type:Integer;
begin
try
_type := IDENTIFIER;
// ruleBlockSingleAlt:C.g:12:4: ( LETTER ( LETTER | '0' .. '9' )* )
// C.g:12:4: LETTER ( LETTER | '0' .. '9' )*
begin
mLETTER();
// closureBlock:C.g:12:11: ( LETTER | '0' .. '9' )*
repeat
_alt[1]:=2;
_LA[1][0] := input.LA(1);
if ( ((_LA[1][0]='$') or ((_LA[1][0]>='0') and ( _LA[1][0]<='9')) or ((_LA[1][0]>='A') and ( _LA[1][0]<='Z')) or (_LA[1][0]='_') or ((_LA[1][0]>='a') and ( _LA[1][0]<='z'))) ) then begin
_alt[1]:=1;
end
;
case (_alt[1]) of
1 :
begin
// C.g:
begin
if ( (input.LA(1)='$') or ((input.LA(1)>='0') and (input.LA(1)<='9')) or ((input.LA(1)>='A') and (input.LA(1)<='Z')) or (input.LA(1)='_') or ((input.LA(1)>='a') and (input.LA(1)<='z')) ) then
begin
input.consume();
end
else
begin
recover(EMismatchedSetException.Create(nil, input), true);end;
end;
end;
else
break;
end;
until (false);
end;
self._type := _type;
finally
end;
end;
because decisionNumber always unique, so it seems the simplest solution.
best regards
chinshou
Sqlite Developer
SharpPlus Software Corp. Yokohama, Japan
> -------Original Message-------
> From: Micheal J <open.zone at virgin.net>
> Subject: Re: [antlr-interest] Writing Delphi Target for Antlr3
> Sent: 27 May '07 01:41
>
> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org
> > [mailto:antlr-interest-bounces at antlr.org] On Behalf Of service
> > Sent: 27 May 2007 01:59
> > To: Terence Parr
> > Cc: antlr-interest at antlr.org
> > Subject: Re: [antlr-interest] Writing Delphi Target for Antlr3
> >
> >
> >
> > I just found a method i to bypass the limitation of delphi
> > compiler, maybe it does not need all the nested blocks at all.
> >
> > best regards
> > Chin Shou
> >
>
> Would you like to share this method with the rest of us?. I'd always assumed
> you would eventually proceeed with nested procedure/functions since Delphi
> doesn't support block-scope variables.
>
>
> <aside>
> On a separate note, doesn't this thread (and others like it e.g. on Ada
> target) - that are about the development of the ANTLR V3 tool itself or one
> of it's targets/runtimes - belong on the [antlr-dev] list?. It is probably
> confusing/irrelevant to most ANTLR users (ANTLR/Delphi-tes excluded of
> course).
> </aside>
>
> Micheal
>
> -----------------------
> The best way to contact me is via the list/forum. My time is very limited.
>
>
More information about the antlr-interest
mailing list