New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bnf-parser

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bnf-parser - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

.eslintrc.json

2

bnf.json

@@ -1,1 +0,1 @@

{"terms":{"program":{"type":"sequence","match":[{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"#t0","count":"+"}]},"#t0":{"type":"sequence","match":[{"type":"ref","val":"stmt","count":"1"},{"type":"ref","val":"w","count":"1"}]},"stmt":{"type":"select","match":[{"type":"ref","val":"def"},{"type":"ref","val":"comment"}]},"comment":{"type":"sequence","match":[{"type":"literal","val":"#","count":"1"},{"type":"ref","val":"#t1","count":"1"},{"type":"literal","val":"\n","count":"1"}]},"#t1":{"type":"not","match":"#t2","count":"*"},"#t2":{"type":"sequence","match":[{"type":"literal","val":"\n","count":"1"}]},"whitespace":{"type":"select","match":[{"type":"literal","val":" "},{"type":"literal","val":"\t"},{"type":"literal","val":"\n"},{"type":"literal","val":"\r"},{"type":"literal","val":"\n"}]},"w":{"type":"sequence","match":[{"type":"ref","val":"whitespace","count":"*"}]},"letter":{"type":"select","match":[{"type":"literal","val":"a"},{"type":"literal","val":"b"},{"type":"literal","val":"c"},{"type":"literal","val":"d"},{"type":"literal","val":"e"},{"type":"literal","val":"f"},{"type":"literal","val":"g"},{"type":"literal","val":"h"},{"type":"literal","val":"i"},{"type":"literal","val":"j"},{"type":"literal","val":"k"},{"type":"literal","val":"l"},{"type":"literal","val":"m"},{"type":"literal","val":"n"},{"type":"literal","val":"o"},{"type":"literal","val":"p"},{"type":"literal","val":"q"},{"type":"literal","val":"r"},{"type":"literal","val":"s"},{"type":"literal","val":"t"},{"type":"literal","val":"u"},{"type":"literal","val":"v"},{"type":"literal","val":"w"},{"type":"literal","val":"x"},{"type":"literal","val":"y"},{"type":"literal","val":"z"},{"type":"literal","val":"A"},{"type":"literal","val":"B"},{"type":"literal","val":"C"},{"type":"literal","val":"D"},{"type":"literal","val":"E"},{"type":"literal","val":"F"},{"type":"literal","val":"G"},{"type":"literal","val":"H"},{"type":"literal","val":"I"},{"type":"literal","val":"J"},{"type":"literal","val":"K"},{"type":"literal","val":"L"},{"type":"literal","val":"M"},{"type":"literal","val":"N"},{"type":"literal","val":"O"},{"type":"literal","val":"P"},{"type":"literal","val":"Q"},{"type":"literal","val":"R"},{"type":"literal","val":"S"},{"type":"literal","val":"T"},{"type":"literal","val":"U"},{"type":"literal","val":"V"},{"type":"literal","val":"W"},{"type":"literal","val":"X"},{"type":"literal","val":"Y"},{"type":"literal","val":"Z"}]},"digit":{"type":"select","match":[{"type":"literal","val":"0"},{"type":"literal","val":"1"},{"type":"literal","val":"2"},{"type":"literal","val":"3"},{"type":"literal","val":"4"},{"type":"literal","val":"5"},{"type":"literal","val":"6"},{"type":"literal","val":"7"},{"type":"literal","val":"8"},{"type":"literal","val":"9"}]},"name":{"type":"sequence","match":[{"type":"ref","val":"#t3","count":"1"},{"type":"ref","val":"#t4","count":"*"}]},"#t3":{"type":"select","match":[{"type":"ref","val":"letter"},{"type":"literal","val":"_"}]},"#t4":{"type":"select","match":[{"type":"ref","val":"letter"},{"type":"ref","val":"digit"},{"type":"literal","val":"_"}]},"constant":{"type":"sequence","match":[{"type":"literal","val":"\"","count":"1"},{"type":"ref","val":"#t5","count":"+"},{"type":"literal","val":"\"","count":"1"}]},"#t5":{"type":"select","match":[{"type":"literal","val":"\\\""},{"type":"literal","val":"\\t"},{"type":"literal","val":"\\n"},{"type":"literal","val":"\\r"},{"type":"literal","val":"\\\\"},{"type":"ref","val":"#t6","count":"1"}]},"#t6":{"type":"not","match":"#t7","count":"+"},"#t7":{"type":"select","match":[{"type":"literal","val":"\""},{"type":"literal","val":"\\"}]},"def":{"type":"sequence","match":[{"type":"ref","val":"name","count":"1"},{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"literal","val":"::= ","count":"1"},{"type":"ref","val":"expr","count":"1"}]},"expr":{"type":"sequence","match":[{"type":"ref","val":"expr_p2","count":"1"},{"type":"ref","val":"#t8","count":"*"}]},"#t8":{"type":"sequence","match":[{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"expr_p2","count":"1"}]},"expr_brackets":{"type":"sequence","match":[{"type":"literal","val":"( ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"expr","count":"1"},{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"literal","val":")","count":"1"}]},"expr_opperand":{"type":"select","match":[{"type":"ref","val":"name"},{"type":"ref","val":"constant"},{"type":"ref","val":"expr_brackets"}]},"expr_p1":{"type":"select","match":[{"type":"ref","val":"expr_p1_not"},{"type":"ref","val":"expr_p1_opt"},{"type":"ref","val":"expr_p1_orm"},{"type":"ref","val":"expr_p1_zrm"},{"type":"ref","val":"expr_opperand"}]},"expr_p1_not":{"type":"sequence","match":[{"type":"literal","val":"!","count":"1"},{"type":"ref","val":"#t9","count":"1"}]},"#t9":{"type":"select","match":[{"type":"ref","val":"expr_p1_opt"},{"type":"ref","val":"expr_p1_zrm"},{"type":"ref","val":"expr_p1_orm"},{"type":"ref","val":"expr_brackets"}]},"expr_p1_opt":{"type":"sequence","match":[{"type":"ref","val":"expr_opperand","count":"1"},{"type":"literal","val":"?","count":"1"}]},"expr_p1_zrm":{"type":"sequence","match":[{"type":"ref","val":"expr_opperand","count":"1"},{"type":"literal","val":"*","count":"1"}]},"expr_p1_orm":{"type":"sequence","match":[{"type":"ref","val":"expr_opperand","count":"1"},{"type":"literal","val":"+","count":"1"}]},"expr_p2":{"type":"select","match":[{"type":"ref","val":"expr_p2_or"},{"type":"ref","val":"expr_p1"}]},"expr_p2_or":{"type":"sequence","match":[{"type":"ref","val":"expr_p1","count":"1"},{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"literal","val":"| ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"expr_p2","count":"1"}]}}}
{"terms":{"program":{"type":"sequence","term":"program","match":[{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"#t0","count":"+"}]},"#t0":{"type":"sequence","term":"#t0","match":[{"type":"ref","val":"stmt","count":"1"},{"type":"ref","val":"w","count":"1"}]},"stmt":{"term":"stmt","type":"select","match":[{"type":"ref","val":"def"},{"type":"ref","val":"comment"}]},"comment":{"type":"sequence","term":"comment","match":[{"type":"literal","val":"#","count":"1"},{"type":"ref","val":"#t1","count":"1"},{"type":"literal","val":"\n","count":"1"}]},"#t1":{"type":"not","match":"#t2","count":"*"},"#t2":{"type":"sequence","term":"#t2","match":[{"type":"literal","val":"\n","count":"1"}]},"whitespace":{"term":"whitespace","type":"select","match":[{"type":"literal","val":" "},{"type":"literal","val":"\t"},{"type":"literal","val":"\n"},{"type":"literal","val":"\r"},{"type":"literal","val":"\n"}]},"nl":{"term":"nl","type":"select","match":[{"type":"literal","val":"\r\n"},{"type":"literal","val":"\n"}]},"w":{"type":"sequence","term":"w","match":[{"type":"ref","val":"whitespace","count":"*"}]},"letter":{"term":"letter","type":"select","match":[{"type":"literal","val":"a"},{"type":"literal","val":"b"},{"type":"literal","val":"c"},{"type":"literal","val":"d"},{"type":"literal","val":"e"},{"type":"literal","val":"f"},{"type":"literal","val":"g"},{"type":"literal","val":"h"},{"type":"literal","val":"i"},{"type":"literal","val":"j"},{"type":"literal","val":"k"},{"type":"literal","val":"l"},{"type":"literal","val":"m"},{"type":"literal","val":"n"},{"type":"literal","val":"o"},{"type":"literal","val":"p"},{"type":"literal","val":"q"},{"type":"literal","val":"r"},{"type":"literal","val":"s"},{"type":"literal","val":"t"},{"type":"literal","val":"u"},{"type":"literal","val":"v"},{"type":"literal","val":"w"},{"type":"literal","val":"x"},{"type":"literal","val":"y"},{"type":"literal","val":"z"},{"type":"literal","val":"A"},{"type":"literal","val":"B"},{"type":"literal","val":"C"},{"type":"literal","val":"D"},{"type":"literal","val":"E"},{"type":"literal","val":"F"},{"type":"literal","val":"G"},{"type":"literal","val":"H"},{"type":"literal","val":"I"},{"type":"literal","val":"J"},{"type":"literal","val":"K"},{"type":"literal","val":"L"},{"type":"literal","val":"M"},{"type":"literal","val":"N"},{"type":"literal","val":"O"},{"type":"literal","val":"P"},{"type":"literal","val":"Q"},{"type":"literal","val":"R"},{"type":"literal","val":"S"},{"type":"literal","val":"T"},{"type":"literal","val":"U"},{"type":"literal","val":"V"},{"type":"literal","val":"W"},{"type":"literal","val":"X"},{"type":"literal","val":"Y"},{"type":"literal","val":"Z"}]},"digit":{"term":"digit","type":"select","match":[{"type":"literal","val":"0"},{"type":"literal","val":"1"},{"type":"literal","val":"2"},{"type":"literal","val":"3"},{"type":"literal","val":"4"},{"type":"literal","val":"5"},{"type":"literal","val":"6"},{"type":"literal","val":"7"},{"type":"literal","val":"8"},{"type":"literal","val":"9"}]},"name":{"type":"sequence","term":"name","match":[{"type":"ref","val":"#t3","count":"1"},{"type":"ref","val":"#t4","count":"*"}]},"#t3":{"term":"#t3","type":"select","match":[{"type":"ref","val":"letter"},{"type":"literal","val":"_"}]},"#t4":{"term":"#t4","type":"select","match":[{"type":"ref","val":"letter"},{"type":"ref","val":"digit"},{"type":"literal","val":"_"}]},"constant":{"type":"sequence","term":"constant","match":[{"type":"literal","val":"\"","count":"1"},{"type":"ref","val":"#t5","count":"+"},{"type":"literal","val":"\"","count":"1"}]},"#t5":{"term":"#t5","type":"select","match":[{"type":"literal","val":"\\\""},{"type":"literal","val":"\\t"},{"type":"literal","val":"\\n"},{"type":"literal","val":"\\r"},{"type":"literal","val":"\\\\"},{"type":"ref","val":"#t6","count":"1"}]},"#t6":{"type":"not","match":"#t7","count":"+"},"#t7":{"term":"#t7","type":"select","match":[{"type":"literal","val":"\""},{"type":"literal","val":"\\"}]},"def":{"type":"sequence","term":"def","match":[{"type":"ref","val":"name","count":"1"},{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"literal","val":"::= ","count":"1"},{"type":"ref","val":"expr","count":"1"}]},"expr":{"type":"sequence","term":"expr","match":[{"type":"ref","val":"expr_p2","count":"1"},{"type":"ref","val":"#t8","count":"*"}]},"#t8":{"type":"sequence","term":"#t8","match":[{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"expr_p2","count":"1"}]},"expr_brackets":{"type":"sequence","term":"expr_brackets","match":[{"type":"literal","val":"( ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"expr","count":"1"},{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"literal","val":")","count":"1"}]},"expr_opperand":{"term":"expr_opperand","type":"select","match":[{"type":"ref","val":"name"},{"type":"ref","val":"constant"},{"type":"ref","val":"expr_brackets"}]},"expr_p1":{"term":"expr_p1","type":"select","match":[{"type":"ref","val":"expr_p1_not"},{"type":"ref","val":"expr_p1_opt"},{"type":"ref","val":"expr_p1_orm"},{"type":"ref","val":"expr_p1_zrm"},{"type":"ref","val":"expr_opperand"}]},"expr_p1_not":{"type":"sequence","term":"expr_p1_not","match":[{"type":"literal","val":"!","count":"1"},{"type":"ref","val":"#t9","count":"1"}]},"#t9":{"term":"#t9","type":"select","match":[{"type":"ref","val":"expr_p1_opt"},{"type":"ref","val":"expr_p1_zrm"},{"type":"ref","val":"expr_p1_orm"},{"type":"ref","val":"expr_brackets"}]},"expr_p1_opt":{"type":"sequence","term":"expr_p1_opt","match":[{"type":"ref","val":"expr_opperand","count":"1"},{"type":"literal","val":"?","count":"1"}]},"expr_p1_zrm":{"type":"sequence","term":"expr_p1_zrm","match":[{"type":"ref","val":"expr_opperand","count":"1"},{"type":"literal","val":"*","count":"1"}]},"expr_p1_orm":{"type":"sequence","term":"expr_p1_orm","match":[{"type":"ref","val":"expr_opperand","count":"1"},{"type":"literal","val":"+","count":"1"}]},"expr_p2":{"term":"expr_p2","type":"select","match":[{"type":"ref","val":"expr_p2_or"},{"type":"ref","val":"expr_p1"}]},"expr_p2_or":{"type":"sequence","term":"expr_p2_or","match":[{"type":"ref","val":"expr_p1","count":"1"},{"type":"literal","val":" ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"literal","val":"| ","count":"1"},{"type":"ref","val":"w","count":"1"},{"type":"ref","val":"expr_p2","count":"1"}]}}}

@@ -14,3 +14,3 @@ let BNF = require('./index.js');

console.error(e);
process.exit();
process.exit(1);
} finally {

@@ -21,3 +21,2 @@ fs.writeFileSync('bnf.json', JSON.stringify(syntax));

console.log('BNF syntax building completed');
process.exit(0);
}

@@ -1,5 +0,6 @@

let Compile = require('./src/compiler.js');
let Parse = require('./src/parser.js');
let Message = require('./src/message.js');
let types = require('./src/types.js');
const GenerateTM = require('./src/tm-gen.js');
const Compile = require('./src/compiler.js');
const Message = require('./src/message.js');
const Parse = require('./src/parser.js');
const types = require('./src/types.js');

@@ -52,2 +53,2 @@ const path = require('path');

module.exports = {Compile, Parse, Build, types, BNF_SYNTAX, Message};
module.exports = { Compile, Parse, Build, types, BNF_SYNTAX, Message, GenerateTM };
{
"name": "bnf-parser",
"version": "2.2.2",
"version": "2.2.3",
"description": "Deterministic BNF compiler/parser",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -177,2 +177,3 @@ const {BNF_SyntaxNode, BNF_SyntaxError, BNF_Reference, BNF_Tree, BNF_Parse} = require('./types.js');

out[name] = {
term: name,
type: "select",

@@ -227,3 +228,4 @@ match: []

out[name] = {
"type": "not",
type: "not",
term: name,
match: inner.tokens[0].tokens,

@@ -245,2 +247,3 @@ count: count

type: "sequence",
term: name,
match: []

@@ -292,3 +295,6 @@ };

return new BNF_Tree(out);
let out_tree = new BNF_Tree(out);
out_tree.check();
return out_tree;
};

@@ -295,0 +301,0 @@

@@ -221,4 +221,2 @@ const {BNF_SyntaxNode, BNF_SyntaxError, BNF_Reference, BNF_Tree, BNF_Parse} = require('./types.js');

branch.term = term;
// Infinite loop detection

@@ -225,0 +223,0 @@ let i = stack.indexOf(term);

@@ -172,3 +172,2 @@

};
this.reached = reached;
}

@@ -191,2 +190,23 @@

check() {
let risk = 0;
for (let name in this.terms) {
let valid = false;
for (let match of this.terms[name].match) {
if (match.count !== "*") {
valid = true;
break;
}
}
if (!valid) {
risk++;
console.warn(`Attempting to compile tree where branch ${name} are all zero to many`);
}
}
return risk;
}
/**

@@ -193,0 +213,0 @@ * Creates a BNF_Tree based off a JSON input

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc