[antlr-interest] unexpected end of subtree

Mr Torsten Curdt tcurdt at yahoo.com
Mon Jun 28 04:32:03 PDT 2004


> > Anyone a pointer?

Thanks for the pointer, Monty

> Use the -traceTreeParser option to antlr.Tool and
> watch what it is 
> doing.

Did that:

 > parse(ROOT)
  > instruction(INSTRUCTION)
   > literal(Format)
   < literal(PARAMETER)
   > literal(5.1)
   < literal(null)
   > literal(null)
<AST>:0:0: unexpected end of subtree
   < literal(<ASTNULL>)
  < instruction(INSTRUCTION)
  > instruction(INSTRUCTION)
   > literal(Application)
   < literal(PARAMETER)
   > literal(somepackage)
   < literal(null)
   > literal(null)
<AST>:0:0: unexpected end of subtree
   < literal(<ASTNULL>)
  < instruction(INSTRUCTION)
  > instruction(INSTRUCTION)
  ...

For the following grammar:

instruction
  : #(INSTRUCTION inst=literal
    (#(PARAMETER kn=literal kv=literal))+
   ...


literal returns [ String s ]
  : l:LITERAL { ... }
  | ql:QLITERAL { ... }
  ;

> Usually "unexpected end of subtree" means
> you forgot to make something a root in the
> parser.

Not totally sure what you mean by that. All
nodes are in the AST as expected (see below)
But please have a look at the above grammar.

> I don't think it is from your ()+  closure.

Hm.. but looking at the trace output
it seems like the treeparser is exspecting
literals, but gets nulls instead. ...which
is because of the ()+ closure. And unfortunately
it complains about it.

>  Another help is to print the tree using
> tree.toStringList() 
> to see what its structure is.

The structure looks exactly like I
would exspect it.

  ROOT
    INSTRUCTION
      "name"
      PARAMETER
         "key"
         "value"
      PARAMETER
         "key"
         "value"
    INSTRUCTION
      "name"
      PARAMETER
         "key"
         "value"

So what am I doing wrong?

cheers
--
Torsten


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list