Bug #17611 [Com]: Regular expression tokens not recognised

From: Date: Fri, 03 Sep 2010 16:47:39 +0000
Subject: Bug #17611 [Com]: Regular expression tokens not recognised
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-4766@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=17611&edit=1 ID: 17611 Comment by: innovabit@gmail.com Reported By: innovabit at gmail dot com Summary: Regular expression tokens not recognised Status: No Feedback Type: Bug Package: PHP_CodeSniffer Operating System: Ubuntu Package Version: 1.3.0a1 PHP Version: 5.3.2 Assigned To: squiz Roadmap Versions: New Comment: In this example code it neither recognize the regular expression token: var test = { regularExpression: /[a-z]+/ }; Previous Comments: ------------------------------------------------------------------------ [2010-09-03 16:46:51] mcordoba In this example code it neither recognize the regular expression token: var test = { ------------------------------------------------------------------------ [2010-09-03 09:19:34] gurbani Hi, Actually the usage of typeof before a regular expression can be a valid expression. Here's an example where we are creating a helper function to see if something is a regular expression. isRegexp: (function() { var regexpType = typeof /a/; return function(obj) { return ( (obj !== null) && (typeof obj === regexpType) && (obj.constructor === RegExp) ); }; } We were having a look at your tokenizer, and could it be just that we need to specify that before a regular expression we can accept a typeof (it might be an oversimplified view of the problem, you are the expert with your tokenizer after all :) Thanks Prem - Framework Lead @ Tuenti ------------------------------------------------------------------------ [2010-08-11 06:00:29] squiz -Status: Feedback +Status: No Feedback Please re-open if you are able to post some code where this is required as it will give me something solid to work with. ------------------------------------------------------------------------ [2010-07-28 05:38:21] squiz -Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz Is there any reason you'd actually write "typeof /a/" in code? Or is this perhaps simplified from a larger piece of code where regexType will be variable? The reason I ask is that I'm trying to figure out if it is worth writing and testing this because it's quite hard to maintain that regular expression parsing. There is a lot you can do, but I'm only really interested in supporting the sort of things you will do due to the inability to figure out if a string is a regex statically. ------------------------------------------------------------------------ [2010-07-20 16:12:42] mcordoba I think the problem is the use of typeof before the regular expression. I think you have to include its token on the array beforeTokens that is in getRegexToken method. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://pear.php.net/bugs/bug.php?id=17611 -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=17611&edit=1

« previous php.pear.bugs (#4766) next »