Loading ...
Sorry, an error occurred while loading the content.

7905Treewalking : non-determinism error

Expand Messages
  • Anthony Youngman
    Apr 1, 2003
      Treewalking : non-determinism error

      I think I know what the problem is, I just don't know how to fix it ...

      In my main parser, I have the following two rules:

      printst : (pr:"PRINT"^ expr (COLONPRINT)? {System.out.println(pr+" print ");} );
      expr : ( catexpr | logicexpr ) ;

      This seems to be fine - the traces are printing what I expect.

      In my treewalker I then have the rule:

      printst
              : #(PRINT expr COLONPRINT) {System.out.println("PRNT");}
              | #(PRINT expr) {System.out.println("OUTP");}
              ;

      which is giving me a non-determinism error. What I think is happening is that "expr" is being expanded, thus confusing the parser. What I think I need to do is to declare a token "EXPR", and make this the root of an "expr" AST in my main parser, so my two options in the treewalker become "PRINT EXPR COLONPRINT" and "PRINT EXPR".

      So. Am I right? And if so, what should my syntax for the "expr" rule in the main parser become? I've looked at the Tree Construction man page, and Ashley Mills tutorial, and I can't quite get to grips with it. I presume I need something like

      expr! : ( catexpr | logicexpr ) {#expr = #([EXPR], #expr); } ;

      Will this create a root of EXPR with a daughter of catexpr or logicexpr?

      Cheers,
      Wol


      This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

      Telephone numbers for ECA International offices are: Sydney +61 (0)2 9911 7799, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

    • Show all 7 messages in this topic