|
From: | Nicolas Peyrussie |
Subject: | Re: how to recognize a multiple line comment ? |
Date: | Thu, 07 Apr 2005 09:24:20 +0200 |
User-agent: | Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) |
Hi, I recognize and avoid html comments on multiple lines like this : <INITIAL>"<!--" {yy_push_state(COMMENT);} <COMMENT>"-->" {yy_pop_state();} <COMMENT>"\n" {} <COMMENT>. {} So you have to do something like this; yy_push_state() adds COMMENT state on top of the stack, it is declared as exclusive (%x), and then you pop it at the end of the comment detection with yy_pop_state(), if you want to keep all I think you have to add yymore() on <COMMENT>"\n" {yymore();} and <COMMENT>. {yymore();}. So something like this <INITIAL>"/*" {yy_push_state(COMMENT);} <COMMENT>"*/" { /* add the action here*/ yy_pop_state(); } <COMMENT>"\n" {yymore();} <COMMENT>. {yymore();} Let me know if it works. Regards, Nicolas ps: I think you have to add %option stack option for yy_push_state() and yy_pop_state() to work. James Yu wrote: Dear all, |
[Prev in Thread] | Current Thread | [Next in Thread] |