[antlr-interest] matchSetTrack.st

Craig Main craig at palantir.co.za
Fri Jul 28 01:54:56 PDT 2006


Hi Terrence,

You are correct.

 operator=(PLUS|MINUS) // Produces a rather nasty exception message!
 (operator=PLUS|operator=MINUS) // works fine.

Is it something that should be fixed?

Also, I have this niggling feeling that I am approaching the grammar below
in the 'old' way and not in the 'new' way.

Are you going to provide a simple expression parser that uses all the
version 3.0 features for us to work from (and admire). If not, you could
possibly give me a few pointers. I am sure there are lots of people in the
list, who would benefit from the help. My little example is quite indicative
of parsing.

Cheers
Regards
Craig

Changing it to 

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Craig Main
Sent: 27 July 2006 15:41
To: 'Antlr Interest'
Subject: [antlr-interest] matchSetTrack.st

Hi,

I have started working on migrating my 2.7.6 grammar to version 3.0.
I am using the 11 ea version of studio.

I get an IllegalArgumentException, cannot find template matchSetTrack.st
org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate.

My grammar, WIP

grammar RuleParser;
options {
	output = AST;
	ASTLabelType = CommonTree;
}

start		: statement+
		;
statement	: assign
		;
assign	: ID ASSIGN expression
		;
expression	: lvalue=term (operator=(PLUS|MINUS) rvalue=term)* ->
^($operator $lvalue $rvalue)
		;
term		: factor ((MULTIPLY|DIVIDE) factor)*
		;
factor	: literal
		;
literal	: ID
		| FLOAT
		;
/* tokens */
ID 		: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
		;
ASSIGN     	: '=' ;
MULTIPLY        : '*' ;
DIVIDE          : '/' ;
PLUS            : '+' ;
MINUS           : '-' ;
DIGIT		: '0'..'9' ;
FLOAT		: (DIGIT)+ ('.' (DIGIT)*)?

Regards
Craig







More information about the antlr-interest mailing list