Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

for safe testing of pairing all the brackets deleted strings (double …

…or single quoted) at the time of scanning classes
  • Loading branch information...
commit 62e7a4d0671a7e21f19206df3788c9bcfd29678b 1 parent 97b4434
@myadzel authored
Showing with 15 additions and 14 deletions.
  1. +14 −11 classes/AS3Parser.php
  2. +1 −1  classes/AS3Replacer.php
  3. +0 −2  index.php
View
25 classes/AS3Parser.php
@@ -36,7 +36,7 @@ private static function pushToStack($sFunctionDefinition = "", $sClassName, $sPa
self::$aStack[$sPackageName][$sClassName] = array();
}
}
-
+
private static function callbackPackage($aMatches) {
$sPackageName = $aMatches[1];
$sPackageName = preg_replace("@^(.*)(package)\s*([_a-z0-9.$]+)(.*)$@smi", "$3", $sPackageName);
@@ -45,11 +45,16 @@ private static function callbackPackage($aMatches) {
//set package name
self::$sPackageName = $sPackageName;
+
+ //clear strings tokens temporary (for the safe testing of pairing brackets)
+ $sPackageContentTmp = $sPackageContent;
+ $sPackageContentTmp = preg_replace('@"([^\\\\"]|\\\\.)*"@', '__TOKEN_STRING_DOUBLE_QUOTED__', $sPackageContentTmp);
+ $sPackageContentTmp = preg_replace("@'([^\\\\']|\\\\.)*'@", '__TOKEN_STRING_SINGLE_QUOTED__', $sPackageContentTmp);
- $sPackageContent = preg_replace_callback(
+ preg_replace_callback(
"@([_a-z0-9$\s]*)({((?>[^{}]+)|(?R))*})+@smix",
create_function('$aMatch', 'return AS3Parser::callbackClassThru($aMatch, AS3Parser::$sPackageName);'),
- $sPackageContent
+ $sPackageContentTmp
);
//restore (reset) package name
@@ -83,17 +88,15 @@ private static function callbackClass($aMatches, $sPackageName) {
private static function parseClass($s, $sClassName, $sPackageName = "") {
$sResult = $s;
-
- /*
+
//scan function's body
- preg_match_all("@({((?>[^{}]+)|(?R))*})+@smi", $sResult, $aMatches);
- */
+ /*preg_match_all("@(?:{(?:(?>[^{}]+)|(?R))*})@smix", $sResult, $aMatchesBodies);*/
- //search for functions
- preg_match_all("@(((?:private|public|protected)\s+)?function[\s_a-z][\s_a-z0-9]+)(\([^)]*\))(\s*\:\s*(\*|[\s_a-z][\s_a-z0-9]+))?@smi", $s, $aMatches);
+ //scan function's all
+ preg_match_all("@\s*(private|public|protected|internal)?\s+function\s+([_a-z][\s_a-z0-9]+)(\([^)]*\))(?:\s*\:\s*(\*|[\s_a-z][\s_a-z0-9]+))?@smi", $s, $aMatches);
- for ($i = 0; $i < sizeof($aMatches[1]); $i++) {
- self::pushToStack($aMatches[1][$i], $sClassName, $sPackageName);
+ for ($i = 0; $i < sizeof($aMatches[2]); $i++) {
+ self::pushToStack($aMatches[2][$i], $sClassName, $sPackageName);
}
//TODO:
View
2  classes/AS3Replacer.php
@@ -61,7 +61,7 @@ private static function proceedDir($sSourceDir, $sDestinationDir) {
//read and clean (don't remove comments, etc.)
$sFileContents = FileReader::read("$sSourceDir/$sFileName");
$sFileContents = AS3Cleaner::cleanBOM($sFileContents);
-
+
$sNewFileContents = self::replace($sFileContents);
//get filename from replacement table
View
2  index.php
@@ -2,8 +2,6 @@
set_time_limit(0);
-//TODO: parsing bug in JSONDecoder::parseValue()
-
header("Content-Type: text/plain; charset=utf-8");
function __autoload($sClassName) {
Please sign in to comment.
Something went wrong with that request. Please try again.