On Mon, 2008-09-01 at 17:55 +0200, Jean-Claude Durand wrote:
> I use antlr v3.1 with the C language target to compose grammars. I
> send you an archive to show
>
> you the problem:
> - first, in the different generated .h files, the variable 'tree' has
> no type in the typedef definition of the
> "return" when building ASTs (you should have the type
> 'pANTLR3_BASE_TREE'):
As has been postedquite a number of times now ;-), you need to have:
options
{
ASTLabelType=pANTLR3_BASE_TREE;
}
In your grammar.
>
> - second, error reporting does not work very well even with very
> simple grammars as in my example
> below. Sometimes it is ok, sometimes not (the same message for 2
> different errors or no message at all):
>
>
> I compose the 2 grammars:
>
>
> parser grammar Int;
> options
> {
> language=C;
> output=AST;
> }
> ent:
> INT Id SEMICOL
> -> ^(INT Id)
> ;
>
>
> and:
>
>
> parser grammar Float;
> options
> {
> language=C;
> output=AST;
> }
> reel :
> FLOAT Id SEMICOL
> -> ^(FLOAT Id)
> ;
>
>
> in the composed grammar:
>
>
> parser grammar Composed;
> options
> {
> language=C;
> tokenVocab=Lex;
> output=AST;
> }
> import Int, Float;
> decls
> :
> e=ent
> r=reel
> -> ^(DECL $e $r)
> ;
>
>
>
> - example 4: NOT ok, I get the same message twice for the first error
> but nothing on the second.
>
>
> int a b;
> float x y;
>
>
> the result is:
>
>
> main:
> err.notOk(1) : error 9 : Extraneous token, at offset 5
> near [Index: 2 (Start: 5243798-Stop: 5243798) ='b', type<8> Line:
> 1 LinePos:5]
> : Extraneous input - expected SEMICOL ...
> err.notOk(1) : error 9 : Extraneous token, at offset 5
> near [Index: 2 (Start: 5243798-Stop: 5243798) ='b', type<8> Line:
> 1 LinePos:5]
> : Extraneous input - expected SEMICOL ...
> main: ast: 249856
> main: (DECL (int a) (float x))
> main.
I'll look into it, maybe it is something to do with not resetting the
error flag perhaps.
JIm
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address