[antlr-interest] Beginner problem

Ayende Rahien Ayende at ayende.com
Sun Sep 4 16:56:18 PDT 2005


First, I’m a complete beginner in both antlr and parsing.

Second, I want to build a pre processor that would recognize the following:

 

Code block: anything inside a <% %>

Text block: anything else.

 

The idea is to transform the input to so the <% %> would be gone and the
text would be properly set in:

output “text” 

 

My (naïve) start is:

 

CODE_BLOCK

            :           CODE_START TEXT_BLOCK CODE_END

            ;

            

CODE_START

            :           "<%"

            ;

 

CODE_END

            :           "%>"

            ;

 

TEXT_BLOCK

            :           ~("<%")

            ;

 

This fails, but I’m not sure how I can fix this. I read some of the
documentation on the site, and I’m afraid I can’t see a solution.

(I know that it’s very easy to do this with custom code, but the idea is
that the moment I’ve code block and text blocks, I can start transforming
them by more complex rules.)

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


More information about the antlr-interest mailing list