[antlr-interest] Lexer States, HTML and <SCRIPT> tag

Terence Parr parrt at jguru.com
Mon Jun 17 17:46:59 PDT 2002


[I can't send to hotmail anymore...it consistently refuses connection 
now...be advised any hotmailers that email me directly....]

On Sunday, June 16, 2002, at 12:42  PM, johnclarke72 wrote:

> I have a lexer that starts in a state where it only identifies text.
> When is sees a < it changes state so that it processes Tags.  This is
> OK until you reach the SCRIPT tag.  This tag can have attributes and
> code between the begin and end tags.  eg :
>
> <script>
>    var cimage;
>    cImage = new Image;
> </script>
>
> Basically I need it to keep the text between the begin and end script
> tags.
>
> How can I do this ?  I would be grateful for all advice offered.

I think an easier way to solve your problem is to have one lexer that 
looks for <script> .* </script> with a nongreedy k=9 loop.  Switching 
makes thing more complicated.  If you think you have a bug though (per 
your direct mail to me) I'd be interested in seeing a very small example 
still.

Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


 

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



More information about the antlr-interest mailing list