[antlr-interest] change a portion of a tree (trying)

Davin McCall davmac at deakin.edu.au
Sun May 29 22:22:32 PDT 2005


Looks like you need to change the bluish part to:

           // or just a category
           cat:( LPAREN! tCat:ID RPAREN! )
           {
                ## = #( #[ObjcCATEGORY, "categorie"], #tCat );
           }

What you had:

                #cat = #( #[ObjcCATEGORY, "categorie"], #tCat );
                ##.addChild(#cat);

... first sets #cat to
    ObjCATEGORY
    + ID
... but ## is still ID, so "##.addChild(#cat)" then gives you:
    ID
    + ObjCATEGORY
       + ID

Hope this helps,

Davin



Lloyd Dupont wrote:

> objcClassDefinition
>  : AT_INTERFACE! tName:ID
>   (
>            // 1st declaration
>           (COLON! ID)? /* super class */
>           (objcProtocolList)? /* protocols */
>            // instance variable
>           (
>                 LCURLY
>                 ( declaration ) *
>                 RCURLY
>            )?
>       |!
>            // or just a category
>            cat:( LPAREN! tCat:ID RPAREN! )
>            {
>                 #cat = #( #[ObjcCATEGORY, "categorie"], #tCat );
>                 ##.addChild(#cat);
>            }
>   )
>   ( objcMethodName SEMI!  ) *
>   AT_END!
>   { ## = #( #[ObjcCLASS_DEF, "@interface"], ##); }
>  ;
> but doesn't work exactly as intended...
> I have a tree like
> ObjcCLASS_DECLARATION
>     + ID /* tName */
>     + ID /* my cat name */
>         + ObjcCategory
>             + ID /* my cat name */
>  
> instead of
> ObjcCLASS_DECLARATION
>     + ID /* tName */
>     + ObjcCategory
>         + ID /* my cat name */
>  
>  
> ?? quite puzzling ...
>  
> ----- Original Message -----
>
>     *From:* Lloyd Dupont <mailto:lloyd at nova-mind.com>
>     *To:* antlr-interest at antlr.org <mailto:antlr-interest at antlr.org>
>     *Sent:* Monday, May 30, 2005 2:08 PM
>     *Subject:* [antlr-interest] change a portion of a tree
>
>     here (in red) I tried to edit a portion of my tree, but that
>     didn't work.. any idea?
>      
>     objcClassDefinition
>      : AT_INTERFACE! tName:ID
>       (
>                // 1st declaration
>               (COLON! ID)? /* super class */
>               (objcProtocolList)? /* protocols */
>                // instance variable
>               (
>                     LCURLY
>                     ( declaration ) *
>                     RCURLY
>                )?
>           |
>                // or just a category
>                LPAREN! tCat:ID RPAREN!
>                { #tCat = #( #[ObjcCATEGORY, "categorie"], #tCat); }
>       )
>       ( objcMethodName SEMI!  ) *
>       AT_END!
>       { ## = #( #[ObjcCLASS_DEF, "@interface"], ##); }
>      ;
>     protected objcProtocolList
>      : LT! ID (COMMA! ID) * GT!
>       { ## = #( #[ObjcPROTOCOL, "@protocol"], ##); }
>      ;
>      
>


-- 
Davin McCall, Research Programmer
Deakin University, Burwood, Australia.
Phone: 03 9251 7045 International: +61 3 9251 7045
Email: Davin.McCall at deakin.edu.au
Website: http://www.deakin.edu.au
Deakin University CRICOS Provider Code 00113B (Vic)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050530/fbfe6baf/attachment.html


More information about the antlr-interest mailing list