Compare commits

..

No commits in common. "master" and "v1.5.0" have entirely different histories.

1 changed files with 10 additions and 19 deletions

View File

@ -31,12 +31,12 @@ class JSM
$this->args_parser = new JSM_ArgsParser();
}
function getRootFile() : string
function getRootFile()
{
return $this->file;
}
static function getModule($file) : JSM_Module
function getModule($file)
{
if(isset(self::$modules[$file]))
return self::$modules[$file];
@ -254,8 +254,9 @@ class JSM
{
if(strpos($txt, '/*') === false)
return $txt;
$regex = '~/\*.*?\*/~s';
$txt = preg_replace_callback(
'~/\*.*?\*/~s',
$regex,
//preserve the new lines for better error reporting
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
$txt);
@ -265,11 +266,7 @@ class JSM
private static function _removeLineComments(string $txt) : string
{
//TODO: it's not robust enough, note a hack for URL addresses
$txt = preg_replace_callback(
'~\s*(?<!:)//.*~',
//preserve the new lines for better error reporting
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
$txt);
$txt = preg_replace("~\s*(?<!:)//.*~", "\n", $txt);
return $txt;
}
@ -523,12 +520,7 @@ class JSM
private function _extractScriptDefs(string $file, string $txt) : string
{
$strpos = strpos($txt, 'def');
if($strpos === false)
return $txt;
//let's extra check if newline symbols preceed 'def'
if($strpos > 0 && !($txt[$strpos-1] === "\n" || $txt[$strpos-1] === "\r"))
if(strpos($txt, 'def') === false)
return $txt;
//NOTE: make it more robust
@ -683,23 +675,22 @@ class JSM
class JSM_Module
{
var string $file = '';
var $file = '';
var $defs = array();
//NOTE: all includes (even those included from other modules)
var $includes = array();
var $node = null;
function __construct(string $file)
function __construct($file)
{
$this->file = $file;
}
function getIncludes() : array
function getIncludes()
{
return $this->includes;
}
function getFile() : string
function getFile()
{
return $this->file;
}