[antlr-interest] grammar question
Prashant Deva
prashant.deva at gmail.com
Tue Sep 20 10:52:01 PDT 2005
Try using a syntactic proedicate.
Something like -
MID : ("M" STRING) => M (STRING)+
;
PRASHANT
On 9/20/05, Harsh Deshmane <hdeshmane at montalvosystems.com> wrote:
>
> Hi,
>
> I have a simple grammar question-
>
> for spice syntax, a transistor is defined as
>
> Mname term1 term2 term3 term4
>
> name can be
>
>
> NAME_IDENTIFIER
> options {testLiterals=true; }
> :
> ('0'..'9'|'a'..'z'|'_'| '$' |'#'|'[' |']'|'%'|'+'|'-'|'/'|'<'|'>')+
> ;
>
> (LT(1)->getColumn() == 1) "M" gives me token at the first column ?
> However, if I try to specify
>
> M<name> by
>
> "M"(NAME_IDENTIFIER)+
> or
> "M"(STRING)+
> or
> (M(STRING)+)
>
> or any such construct, I get the parser expecting M to be the first token
> and then followed by the STRING or IDENTIFIER as the second token.
>
> How can I define "M<anything>" ?
>
> For my case,
> syntax like
> M term1 term2 term3 term4
>
> passes, but I need
> Mname term1 ..
> to pass.
>
> thanks,
> -harsh
>
>
More information about the antlr-interest
mailing list