[antlr-interest] Rewriting trees

Maassen, H.A.M. H.A.M.Maassen at student.tue.nl
Tue Nov 30 04:44:20 PST 2004


Alright, ignore that. It's still not working. I'm fresh out of ideas. Here's the whole grammar:

options {
 language = "CSharp";
}

// ______________________________________________________________________

class MyLexer extends Lexer;
options { k = 2; 
          caseSensitive = false;
          caseSensitiveLiterals = false;
          charVocabulary='\u0000'..'\uFFFE';
        }

ID: ('a'..'z')+;

WS
  : ( ' '
    | '\t'
    | '\f'
    
    // handle newlines
    | ( "\r\n"  // DOS
      | '\r'    // Macintosh
      | '\n'    // Unix
      )  
      { newline(); }
    )
    { $setType(Token.SKIP); }
  ;   

// ______________________________________________________________________
 
 
class MyParser extends Parser;
options
{ k = 1;
  buildAST = true;
}

program
     : "begin"^ (ID | program)* "end"!
     ;

// ______________________________________________________________________


class MyWalker extends TreeParser;
options
{ buildAST = true; }

tokens
{ V; }

program
     : #("begin" (program)*)
     |! ID
       { ## = #([V, "ID"]); }    // <--- generates Invalid AST Node Type error
     ;
     
HELP! ;)

Regards, Harald Maassen



 
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/
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 5078 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20041130/37656bbc/attachment.bin


More information about the antlr-interest mailing list