Compare commits
No commits in common. "master" and "v1.5.0" have entirely different histories.
29
jsm.inc.php
29
jsm.inc.php
|
@ -31,12 +31,12 @@ class JSM
|
||||||
$this->args_parser = new JSM_ArgsParser();
|
$this->args_parser = new JSM_ArgsParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRootFile() : string
|
function getRootFile()
|
||||||
{
|
{
|
||||||
return $this->file;
|
return $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getModule($file) : JSM_Module
|
function getModule($file)
|
||||||
{
|
{
|
||||||
if(isset(self::$modules[$file]))
|
if(isset(self::$modules[$file]))
|
||||||
return self::$modules[$file];
|
return self::$modules[$file];
|
||||||
|
@ -254,8 +254,9 @@ class JSM
|
||||||
{
|
{
|
||||||
if(strpos($txt, '/*') === false)
|
if(strpos($txt, '/*') === false)
|
||||||
return $txt;
|
return $txt;
|
||||||
|
$regex = '~/\*.*?\*/~s';
|
||||||
$txt = preg_replace_callback(
|
$txt = preg_replace_callback(
|
||||||
'~/\*.*?\*/~s',
|
$regex,
|
||||||
//preserve the new lines for better error reporting
|
//preserve the new lines for better error reporting
|
||||||
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
||||||
$txt);
|
$txt);
|
||||||
|
@ -265,11 +266,7 @@ class JSM
|
||||||
private static function _removeLineComments(string $txt) : string
|
private static function _removeLineComments(string $txt) : string
|
||||||
{
|
{
|
||||||
//TODO: it's not robust enough, note a hack for URL addresses
|
//TODO: it's not robust enough, note a hack for URL addresses
|
||||||
$txt = preg_replace_callback(
|
$txt = preg_replace("~\s*(?<!:)//.*~", "\n", $txt);
|
||||||
'~\s*(?<!:)//.*~',
|
|
||||||
//preserve the new lines for better error reporting
|
|
||||||
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
|
||||||
$txt);
|
|
||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,12 +520,7 @@ class JSM
|
||||||
|
|
||||||
private function _extractScriptDefs(string $file, string $txt) : string
|
private function _extractScriptDefs(string $file, string $txt) : string
|
||||||
{
|
{
|
||||||
$strpos = strpos($txt, 'def');
|
if(strpos($txt, 'def') === false)
|
||||||
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"))
|
|
||||||
return $txt;
|
return $txt;
|
||||||
|
|
||||||
//NOTE: make it more robust
|
//NOTE: make it more robust
|
||||||
|
@ -683,23 +675,22 @@ class JSM
|
||||||
|
|
||||||
class JSM_Module
|
class JSM_Module
|
||||||
{
|
{
|
||||||
var string $file = '';
|
var $file = '';
|
||||||
var $defs = array();
|
var $defs = array();
|
||||||
//NOTE: all includes (even those included from other modules)
|
|
||||||
var $includes = array();
|
var $includes = array();
|
||||||
var $node = null;
|
var $node = null;
|
||||||
|
|
||||||
function __construct(string $file)
|
function __construct($file)
|
||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIncludes() : array
|
function getIncludes()
|
||||||
{
|
{
|
||||||
return $this->includes;
|
return $this->includes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFile() : string
|
function getFile()
|
||||||
{
|
{
|
||||||
return $this->file;
|
return $this->file;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue