[antlr-interest] grammar question
Harsh Deshmane
hdeshmane at montalvosystems.com
Tue Sep 20 09:37:56 PDT 2005
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