|
Posted by elmosik on 11/10/02 12:00
On 17 Sty, 13:29, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> Regular expressions simply do not cut it. Consider the following comments
> which will not be caught by your regular expressions:
>
> define('SOME_CONFIG_OPTION', TRUE); # Here is a comment
> define('SOME_OTHER_OPTION', TRUE); // Here is a comment
Patterns used with preg_replace works fine. preg_replace($pattern,
''); - from pattern to empty string and I have clean code.
> But what about the following code which contains no comments, which will
> be treated as comments by your regexs:
>
> $comment = "/* Lala */
> // Lala
> ## Lala
> No comments here!";
> print $comment;
It's not problem for me because I don't need code from functions/
classes like variables etc. I need only to extract functions/classes
names. So example above isn't a problem, but I understand what you
wrote, but remember that it's not a php file parser, I'm not parsing
code from methods...
> Regular expressions are no good for any non-trivial parsing task. You need
> a stateful parser.
Any examples of stateful parser?
--
Thanks
Navigation:
[Reply to this message]
|