[antlr-interest] c-target tree creation

Christian Hoffmann Sanus at gmx.de
Thu Jan 7 14:04:16 PST 2010


Hi,

I'm stumbling over a unhappy circumstance. Normaly a tree is built witch a
nil node and the children. But if the parser regognises just one line,
the nil node is not used (probably there are no children).

Example 1 - generated tree has just one node
  Source:
    int a;
  AST:
    <TOK_VAR_DEF(99) at line 2,
      <TOK_VAR_TYPE(100) at line 2, int(49) at line 2>,
      <TOK_VAR_DECL(101) at line 2, a(122) at line 2>
    >


Example 2 - generated tree has two nodes
  Source:
    int a;
    int b;
  AST:
    <nil(0) at line 2,
      <TOK_VAR_DEF(99) at line 2,
        <TOK_VAR_TYPE(100) at line 2, int(49) at line 2>,
        <TOK_VAR_DECL(101) at line 2, a(122) at line 2>
      >,
      <TOK_VAR_DEF(99) at line 3,
        <TOK_VAR_TYPE(100) at line 3, int(49) at line 3>,
        <TOK_VAR_DECL(101) at line 3, b(122) at line 3>
      >
    >


I think it would be easier for walking in a loop if the nil-node is
always created. Is this possible in future versions?

Regards,
Christian

-- 
Christian Hoffmann
Ützenkamp 4
38118 Braunschweig
Tel: 0171/7300609
Web: www.c-hoffmann.de
     www.logical-arts.de



More information about the antlr-interest mailing list