- Hi,

How do I throw an exception for a rule with my own message? I have

defaultErrorHandler = false in my parser.

The rule I have is:

declarator

{

int limit_3 = 1;

} :

({ limit_3 <= 3 }? limit_3 = dimension[limit_3] )+ SEMI!

{

if (limit_3 > 3)

{

throw antlr::RecognitionException ("My error message");

}

}

;

dimension[int i] returns [int limit]:

LEFT_BRACKET! logical_or_expr RIGHT_BRACKET!

{ limit = i + 1; }

;

But the exception isn't thrown.

Thanks,

Anna - Thursday, August 31, 2000, Anna Winkler hath spoken:

> How do I throw an exception for a rule with my own message? I have

Then that java code is not being executed.

> defaultErrorHandler = false in my parser.

> The rule I have is:

> declarator

> {

> int limit_3 = 1;

> } :

> ({ limit_3 <= 3 }? limit_3 = dimension[limit_3] )+ SEMI!

> {

> if (limit_3 > 3)

> {

> throw antlr::RecognitionException ("My error message");

> }

> }

> ;

> dimension[int i] returns [int limit]:

> LEFT_BRACKET! logical_or_expr RIGHT_BRACKET!

> { limit = i + 1; }

> ;

> But the exception isn't thrown.

Ter

--

Chief Scientist & Co-founder, http://www.jguru.com

Co-founder, http://www.NoWebPatents.org -- Stop Patent Stupidity

parrt@...