bare-script 3.5.3 → 3.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser.js +1 -1
- package/lib/value.js +39 -2
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -459,7 +459,7 @@ const rScriptFunctionArgSplit = /\s*,\s*/;
|
|
|
459
459
|
const rScriptFunctionEnd = new RegExp(`^\\s*endfunction${rPartComment}`);
|
|
460
460
|
const rScriptLabel = new RegExp(`^\\s*(?<name>[A-Za-z_]\\w*)\\s*:${rPartComment}`);
|
|
461
461
|
const rScriptJump = new RegExp(`^(?<jump>\\s*(?:jump|jumpif\\s*\\((?<expr>.+)\\)))\\s+(?<name>[A-Za-z_]\\w*)${rPartComment}`);
|
|
462
|
-
const rScriptReturn = new RegExp(`^(?<return>\\s*return(?:\\s+(?<expr
|
|
462
|
+
const rScriptReturn = new RegExp(`^(?<return>\\s*return(?:\\s+(?<expr>[^#\\s].*))?)${rPartComment}`);
|
|
463
463
|
const rScriptInclude = new RegExp(`^\\s*include\\s+(?<delim>')(?<url>(?:\\'|[^'])*)'${rPartComment}`);
|
|
464
464
|
const rScriptIncludeSystem = new RegExp(`^\\s*include\\s+(?<delim><)(?<url>[^>]*)>${rPartComment}`);
|
|
465
465
|
const rScriptIfBegin = new RegExp(`^\\s*if\\s+(?<expr>.+)\\s*:${rPartComment}`);
|
package/lib/value.js
CHANGED
|
@@ -488,14 +488,51 @@ const rNumber = /^\s*[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?\s*$/;
|
|
|
488
488
|
* @ignore
|
|
489
489
|
*/
|
|
490
490
|
export function valueParseInteger(text, radix = 10) {
|
|
491
|
-
if (
|
|
491
|
+
if (valueType(radix) !== 'number' || Math.floor(radix) !== radix || radix < 2 || radix > 36 ||
|
|
492
|
+
!valueParseIntegerRegexMap[String(radix)].test(text)) {
|
|
492
493
|
return null;
|
|
493
494
|
}
|
|
494
495
|
return Number.parseInt(text, radix);
|
|
495
496
|
}
|
|
496
497
|
|
|
497
498
|
|
|
498
|
-
const
|
|
499
|
+
const valueParseIntegerRegexMap = {
|
|
500
|
+
'2': /^\s*[-+]?[0-1]+\s*$/,
|
|
501
|
+
'3': /^\s*[-+]?[0-2]+\s*$/,
|
|
502
|
+
'4': /^\s*[-+]?[0-3]+\s*$/,
|
|
503
|
+
'5': /^\s*[-+]?[0-4]+\s*$/,
|
|
504
|
+
'6': /^\s*[-+]?[0-5]+\s*$/,
|
|
505
|
+
'7': /^\s*[-+]?[0-6]+\s*$/,
|
|
506
|
+
'8': /^\s*[-+]?[0-7]+\s*$/,
|
|
507
|
+
'9': /^\s*[-+]?[0-8]+\s*$/,
|
|
508
|
+
'10': /^\s*[-+]?[0-9]+\s*$/,
|
|
509
|
+
'11': /^\s*[-+]?[0-9Aa]+\s*$/,
|
|
510
|
+
'12': /^\s*[-+]?[0-9A-Ba-b]+\s*$/,
|
|
511
|
+
'13': /^\s*[-+]?[0-9A-Ca-c]+\s*$/,
|
|
512
|
+
'14': /^\s*[-+]?[0-9A-Da-d]+\s*$/,
|
|
513
|
+
'15': /^\s*[-+]?[0-9A-Ea-e]+\s*$/,
|
|
514
|
+
'16': /^\s*[-+]?[0-9A-Fa-f]+\s*$/,
|
|
515
|
+
'17': /^\s*[-+]?[0-9A-Ga-g]+\s*$/,
|
|
516
|
+
'18': /^\s*[-+]?[0-9A-Ha-h]+\s*$/,
|
|
517
|
+
'19': /^\s*[-+]?[0-9A-Ia-i]+\s*$/,
|
|
518
|
+
'20': /^\s*[-+]?[0-9A-Ja-j]+\s*$/,
|
|
519
|
+
'21': /^\s*[-+]?[0-9A-Ka-k]+\s*$/,
|
|
520
|
+
'22': /^\s*[-+]?[0-9A-La-l]+\s*$/,
|
|
521
|
+
'23': /^\s*[-+]?[0-9A-Ma-m]+\s*$/,
|
|
522
|
+
'24': /^\s*[-+]?[0-9A-Na-n]+\s*$/,
|
|
523
|
+
'25': /^\s*[-+]?[0-9A-Oa-o]+\s*$/,
|
|
524
|
+
'26': /^\s*[-+]?[0-9A-Pa-p]+\s*$/,
|
|
525
|
+
'27': /^\s*[-+]?[0-9A-Qa-q]+\s*$/,
|
|
526
|
+
'28': /^\s*[-+]?[0-9A-Ra-r]+\s*$/,
|
|
527
|
+
'29': /^\s*[-+]?[0-9A-Sa-s]+\s*$/,
|
|
528
|
+
'30': /^\s*[-+]?[0-9A-Ta-t]+\s*$/,
|
|
529
|
+
'31': /^\s*[-+]?[0-9A-Ua-u]+\s*$/,
|
|
530
|
+
'32': /^\s*[-+]?[0-9A-Va-v]+\s*$/,
|
|
531
|
+
'33': /^\s*[-+]?[0-9A-Wa-w]+\s*$/,
|
|
532
|
+
'34': /^\s*[-+]?[0-9A-Xa-x]+\s*$/,
|
|
533
|
+
'35': /^\s*[-+]?[0-9A-Ya-y]+\s*$/,
|
|
534
|
+
'36': /^\s*[-+]?[0-9A-Za-z]+\s*$/
|
|
535
|
+
};
|
|
499
536
|
|
|
500
537
|
|
|
501
538
|
//
|