dcsimg
Error handling in ANTLR v3
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sebastien_Laigre
Posted On:   Tuesday, September 23, 2008 03:51 AM

Hello, I'm a beginner in ANTLR v3 and It's really hard for me. In fact, I try to manage parser errors, in a first time in killing the process when an error occurs. But the problem is that I did not find the syntax to do this when generating the parser.c parser.h. Lexer and parser are in the same file : Tags.g I tried something like that but : clause : IF expr @THEN clause : | A | B A exception [expr] catch[expr] { printf("exception !"); } But it tells me : error(100): Tags.g:88:5: syntax error: antlr: Tags.g:88:5: unexpected token: expr error(100): Tags.g:88:16: syntax error: antlr: Tags.g:88:16: unexpected token: clause    More>>

Hello,

I'm a beginner in ANTLR v3 and It's really hard for me. In fact, I try to manage parser errors, in a first time in killing the process when an error occurs. But the problem is that I did not find the syntax to do this when generating the parser.c parser.h.
Lexer and parser are in the same file : Tags.g

I tried something like that but :
clause :
IF expr @THEN clause :
| A
| B A
exception [expr]
catch[expr]
{
printf("exception !");
}
But it tells me :
error(100): Tags.g:88:5: syntax error: antlr: Tags.g:88:5: unexpected token: expr
error(100): Tags.g:88:16: syntax error: antlr: Tags.g:88:16: unexpected token: clause
error(100): Tags.g:99:2: syntax error: antlr: Tags.g:99:2: unexpected token: catch
warning(105): Tags.g:88:11: no lexer rule corresponding to token: THEN
warning(105): Tags.g:88:2: no lexer rule corresponding to token: IF
I do not know what is "expr" ? What is it ?

I also tried putting :
@rulecatch {
catch (RecognitionException e) {
throw e;
}
But in the parser.c, it only puts "catch(){...}" it does not put try{...} in the parser.c
}
Did I miss something ?
What is the real syntax to do that ?

Thank you in advance.

   <<Less

Error handling in ANTLR v3

Posted By:   sebastien_Laigre  
Posted On:   Tuesday, September 23, 2008 04:12 AM

Sorry for the indent :

Hello, I'm a beginner in ANTLR v3 and It's really hard for me. In fact, I try to manage parser errors, in a first time in killing the process when an error occurs. But the problem is that I did not find the syntax to do this when generating the parser.c parser.h. Lexer and parser are in the same file : Tags.g


I tried something like that but :

clause :

IF expr @THEN clause :

A

| B A

;

exception [expr]

catch[expr] { printf("exception !"); }




But it tells me :



error(100): Tags.g:88:5: syntax error: antlr: Tags.g:88:5: unexpected token: expr

error(100): Tags.g:88:16: syntax error: antlr: Tags.g:88:16: unexpected token: clause

error(100): Tags.g:99:2: syntax error: antlr: Tags.g:99:2: unexpected token: catch

warning(105): Tags.g:88:11: no lexer rule corresponding to token: THEN

warning(105): Tags.g:88:2: no lexer rule corresponding to token: IF




I do not know what is "expr" ? What is it ?



I also tried putting :

@rulecatch

{

catch (RecognitionException e)

{ throw e; }

}




But in the parser.c, it only puts "catch(){...}" it does not put try{...} in the parser.c } Did I miss something ? What is the real syntax to do that ?



Thank you in advance.
About | Sitemap | Contact