[antlr-interest] Matching Dollar quoted strings
Gokulakannan Somasundaram
gokul007 at gmail.com
Wed Jul 27 21:15:47 PDT 2011
May be the question was not clear. Anyways, i have found the solution, so
thought of updating it.
fragment DOLQ_CONT : ALPH_CAP | ALPH_SMALL | ( '\u0200' .. '\u0377' ) | '_'
| DIGIT;
fragment DOLQ_START : ALPH_CAP | ALPH_SMALL | ( '\u0200' .. '\u0377' ) | '_'
;
fragment DOLQ_DELIM_F1[ string& delim ]
@init{
ANTLR3_MARKER start = GETCHARINDEX();
} : '$' (DOLQ_START) (DOLQ_CONT)* '$'
{
ANTLR3_MARKER stop = GETCHARINDEX();
delim.assign( (char*) start, stop - start );
};
fragment DOLQ_DELIM_F2 : '$' (DOLQ_START) (DOLQ_CONT)* '$' ;
fragment DOLQ_INSIDE: (~'$')+ | '$'
;
DOLQDELIM
@init{
string delim;
}: DOLQ_DELIM_F1[delim]
DOLQ_INSIDE*
{ check_string_delim( delim, GETCHARINDEX() ) }? DOLQ_DELIM_F2
;
Thanks,
Gokul.
On Wed, Jul 27, 2011 at 9:52 PM, Gokulakannan Somasundaram <
gokul007 at gmail.com> wrote:
> Hi,
> I want to match patterns like
>
> $123$..anything here..$123$
>
> Basically it is a way to mention strings between a delimiter. The
> delimiter is not fixed. Can someone help me on how to match these type of
> dollar quoted identifiers?
>
> Thanks,
> Gokul.
>
More information about the antlr-interest
mailing list