PHP Classes

Too complex...

Recommend this page to a friend!

      Check Curly Braces  >  All threads  >  Too complex...  >  (Un) Subscribe thread alerts  
Subject:Too complex...
Summary:Read php docs
Messages:4
Author:Epsilon Alexey
Date:2009-01-21 09:51:06
Update:2009-02-01 22:35:29
 

  1. Too complex...   Reply   Report abuse  
Picture of Epsilon Alexey Epsilon Alexey - 2009-01-21 09:51:06
I think PHP has some simplier ways to detect and count braces. First, it is of course preg_match_all(), second is tokenize() if you try to parse php files.
Using this technics it is possible to fit all class to 6-10 lines only and increase speed much.

  2. Re: Too complex...   Reply   Report abuse  
Picture of andrea bernardi andrea bernardi - 2009-01-24 01:03:03 - In reply to message 1 from Epsilon Alexey
Where possible I don't use PCRE functions. Sometime when using the regexp engine, the execution time increases, not decreases. But I will do some benchmarking on my class using preg_* functions, I will let you know.

Then, you mean the Tokenizer, because tokenize() doesn't exist. Well I never tought about using tokens, thanks for your suggestion.


  3. Re: Too complex...   Reply   Report abuse  
Picture of Epsilon Alexey Epsilon Alexey - 2009-02-01 20:04:13 - In reply to message 2 from andrea bernardi
Yes, sorry, I meant token_get_all() function.

May be PCRE functions sometimes will more slowly, but I think it is not very important when it using just one time for ten or hundred files to convert it to intermediate form usable for fast and often processing.

  4. Re: Too complex...   Reply   Report abuse  
Picture of andrea bernardi andrea bernardi - 2009-02-01 22:35:29 - In reply to message 3 from Epsilon Alexey
You know, I can't found a way to catch the column number where braces are, this is the main reason why I decided not to use PCRE functions. I tried preg_match_all() with PREG_OFFSET_CAPTURE flag, but no way. Even if the execution time was about 0.1 seconds less, my proposal was not reached.

At the moment, my class can display correct values for lines and column positions with almost all files I tried, and to me is enough :-) So I see no reasons to change its methods.
This class is a thing that I needed, so I wrote it and I'm actually using it, because it just works.