mirror of
https://github.com/metrico/qryn.git
synced 2025-03-14 10:07:18 +00:00
133 lines
4.0 KiB
Diff
133 lines
4.0 KiB
Diff
diff --git a/node_modules/bnf/BnfRules.js b/node_modules/bnf/BnfRules.js
|
|
index 1f949c1..098e140 100755
|
|
--- a/node_modules/bnf/BnfRules.js
|
|
+++ b/node_modules/bnf/BnfRules.js
|
|
@@ -19,6 +19,9 @@ exports.bnfRules = {
|
|
|
|
return false;
|
|
},
|
|
+ REALPHA(token){
|
|
+ return token.TryRe(/^\p{L}/u);
|
|
+ },
|
|
SYMBOL( token ){
|
|
if( token.CharIs( 33 )
|
|
|| token.CharCodeRange( 35, 38 )
|
|
@@ -35,7 +38,7 @@ exports.bnfRules = {
|
|
},
|
|
ANYCHAR( token ){
|
|
return token.Or( [
|
|
- token.Rule( "ALPHA" ),
|
|
+ token.Rule( "REALPHA" ),
|
|
token.Rule( "DIGIT" ),
|
|
token.Rule( "SYMBOL" ),
|
|
token.Rule( "ONEWSP" )
|
|
@@ -135,9 +138,13 @@ exports.bnfRules = {
|
|
ESCAQUOTE( token ){
|
|
return token.TryString( Buffer.from( [ 92, 96 ] ) );
|
|
},
|
|
+ ESCSLASH(token){
|
|
+ return token.TryString( Buffer.from( [ 92, 92 ] ) );
|
|
+ },
|
|
//DO BE REMOVED IN THIS MAJOR VERSION! DO NOT USE!
|
|
SQEANYCHAR( token ){
|
|
return token.Or( [
|
|
+ token.Rule( "ESCSLASH" ),
|
|
token.Rule( "ESCSQUOTE" ),
|
|
token.Rule( "ANYCHAR" ),
|
|
token.Rule( "QUOTE" ),
|
|
@@ -162,6 +169,7 @@ exports.bnfRules = {
|
|
//DO BE REMOVED IN THIS MAJOR VERSION! DO NOT USE!
|
|
QEANYCHAR( token ){
|
|
return token.Or( [
|
|
+ token.Rule( "ESCSLASH" ),
|
|
token.Rule( "ESCQUOTE" ),
|
|
token.Rule( "ANYCHAR" ),
|
|
token.Rule( "SQUOTE" ),
|
|
@@ -186,6 +194,7 @@ exports.bnfRules = {
|
|
//DO BE REMOVED IN THIS MAJOR VERSION! DO NOT USE!
|
|
AQEANYCHAR( token ){
|
|
return token.Or( [
|
|
+ token.Rule( "ESCSLASH" ),
|
|
token.Rule( "ESCAQUOTE" ),
|
|
token.Rule( "ANYCHAR" ),
|
|
token.Rule( "SQUOTE" ),
|
|
@@ -219,11 +228,12 @@ exports.bnfRules = {
|
|
*/
|
|
},
|
|
AQLITERAL( token ){
|
|
- return token.And( [
|
|
+ const res = token.And( [
|
|
token.Rule( "AQUOTE" ),
|
|
token.Rule( "AQLITERALCHARS" ),
|
|
token.Rule( "AQUOTE" )
|
|
]);
|
|
+ return res;
|
|
},
|
|
LITERAL( token ){
|
|
return token.Or( [
|
|
@@ -285,7 +295,7 @@ exports.parserRules = {
|
|
}
|
|
else{
|
|
//This can be optimized @LHF
|
|
- for( let i = 0; i < token._tokenTrees.length - 1; i++ ){
|
|
+ /*for( let i = 0; i < token._tokenTrees.length - 1; i++ ){
|
|
for( let t = 0; t < token._tokenTrees[i].length; t++ ){
|
|
for( let line in token._tokenTrees[i][t].expected ){
|
|
for( let char in token._tokenTrees[i][t].expected[line] ){
|
|
@@ -295,7 +305,7 @@ exports.parserRules = {
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
+ }*/
|
|
token._tokenTrees[0] = [];
|
|
|
|
return false;
|
|
diff --git a/node_modules/bnf/Script.js b/node_modules/bnf/Script.js
|
|
index e5eb5b7..56bd641 100755
|
|
--- a/node_modules/bnf/Script.js
|
|
+++ b/node_modules/bnf/Script.js
|
|
@@ -15,7 +15,7 @@ exports.Script = class Script{
|
|
}
|
|
|
|
GetString( length, token ){
|
|
- let str = this.rawScript.substring( token.point, token.point + length );
|
|
+ let str = Buffer.from(this.rawScript).subarray( token.point, token.point + length ).toString('utf8');
|
|
token.Seek( length );
|
|
return str;
|
|
}
|
|
diff --git a/node_modules/bnf/Token.js b/node_modules/bnf/Token.js
|
|
index f592ae5..c76e103 100755
|
|
--- a/node_modules/bnf/Token.js
|
|
+++ b/node_modules/bnf/Token.js
|
|
@@ -226,16 +226,27 @@ exports.Token = class Token{
|
|
|
|
TryString( charBuffer ){
|
|
let stringBuffer = Buffer.alloc( charBuffer.length );
|
|
- this.script.scriptBuffer.copy( stringBuffer, 0, this.point, charBuffer.length );
|
|
+ this.script.scriptBuffer.copy( stringBuffer, 0, this.point, this.point + charBuffer.length );
|
|
if( !stringBuffer.equals( charBuffer ) ){
|
|
return false;
|
|
}
|
|
|
|
this.SetValue( stringBuffer.toString() );
|
|
- this.point += charArray.length;
|
|
+ this.point += charBuffer.length;
|
|
return true;
|
|
}
|
|
|
|
+ TryRe(pattern) {
|
|
+ const mtch = this.script.scriptBuffer.subarray(this.point).toString('utf-8').match(pattern);
|
|
+ if (mtch && mtch[0]) {
|
|
+ const b = Buffer.from(mtch[0]);
|
|
+ this.SetValue(mtch[0]);
|
|
+ this.point+=b.length;
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
SetChar( char ){
|
|
this.SetValue( this.GetChar() );
|
|
this.point++;
|