[antlr-interest] Some C target issues
Gavin Lambert
antlr at mirality.co.nz
Tue Apr 1 12:45:48 PDT 2008
At 07:02 2/04/2008, Chris Snyder wrote:
>2) Following the guidelines here:
><http://www.antlr.org/api/C/index.html>http://www.antlr.org/api/C/index.html,
>in my Tree grammar I tried changing
>
>@header {
>#include <string.h>
>#include <string.h>
>#include <iostream.h>
>}
>
>To this
>
>@parser::includes {
>#include <string.h>
>#include <iostream.h>
>}
>
>And I get this error:
>error(143): unknown or invalid action scope for tree grammar:
>parser
The parser:: scope only works in combined grammars and parser
grammars, of course. Just leave out the scope and use @includes
instead. (Don't know if the tree grammar template actually
supports that tag or not, but it probably does if the others do.)
>4) I tried using the @declarations section in my tree grammar and
>although no warnings were generated none of the code in the
>@declarations section was added to either the generated C or h
>files.
No warnings are ever generated for any action blocks; you can
actually specify anything at all and ANTLR won't mind. It's up to
the generator template to either use it or not, though. However,
in this case: I think @declarations only works within a rule, not
globally. For a global equivalent, use @members.
More information about the antlr-interest
mailing list