Comparing version 2.7.8 to 2.7.9
@@ -72,4 +72,5 @@ (function () { | ||
if (!(this.data === Parser.fail)) { | ||
var findLeo; | ||
// LEO THE LION SAYS GER | ||
function findLeo(idx, rulename, finalData) { | ||
findLeo = function findLeo(idx, rulename, finalData) { | ||
// performance optimization, avoid high order functions(map/filter) in hotspot code. | ||
@@ -101,3 +102,3 @@ var items = []; | ||
} | ||
} | ||
}; | ||
@@ -104,0 +105,0 @@ var leo = findLeo(this.reference, this.rule.name, this.data); |
{ | ||
"name": "nearley", | ||
"version": "2.7.8", | ||
"version": "2.7.9", | ||
"description": "Simple, fast, powerful parser toolkit for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "lib/nearley.js", |
window.addEventListener("load", function() { | ||
var grammarInput = document.getElementById("grammar-input"); | ||
var testInput = document.getElementById("test-input"); | ||
var compileInput = document.getElementById("compile-grammar"); | ||
@@ -10,69 +9,7 @@ compileInput.addEventListener("click", function() { | ||
var result = parser.results[0]; | ||
visualizeAST(result); | ||
var compiled = Compile(result); | ||
var compiled = Compile(result, {}); | ||
var js = generate(compiled); | ||
window.open("data:text/javascript;charset=utf-8,"+encodeURIComponent(js)); | ||
console.log(js); | ||
}, false); | ||
function uniquegen() { | ||
return "$" + uniquegen.$++; | ||
} | ||
uniquegen.$ = 0; | ||
function buildAST(cy, obj) { | ||
var id = uniquegen(); | ||
cy.add({ | ||
group: 'nodes', | ||
data: {id: id, val: typeof(obj) === 'object' ? '' : JSON.stringify(obj)} | ||
}); | ||
if (typeof(obj) === 'object') { | ||
for (var i in obj) { | ||
if (obj.hasOwnProperty(i)) { | ||
var o = obj[i]; | ||
var n = buildAST(cy, o); | ||
cy.add({ | ||
group: 'edges', | ||
data: {source: id, target: n, val: i} | ||
}); | ||
} | ||
} | ||
} | ||
return id; | ||
} | ||
var oldcy = null; | ||
function visualizeAST(AST) { | ||
if (oldcy) { | ||
oldcy.destroy(); | ||
} | ||
var container = document.createElement("div"); | ||
container.style.height = "700px"; | ||
document.getElementById("cy-viz").appendChild(container); | ||
oldcy = cytoscape({ | ||
container: container, | ||
elements: { | ||
nodes: [ | ||
], | ||
edges: [ | ||
] | ||
}, | ||
layout: { | ||
name: 'breadthfirst' | ||
}, | ||
style: [{ | ||
selector: 'node', | ||
css: { | ||
'content': 'data(val)' | ||
} | ||
}, { | ||
selector: 'edge', | ||
css: { | ||
'target-arrow-shape': 'triangle', | ||
'content': 'data(val)' | ||
} | ||
}] | ||
}); | ||
buildAST(oldcy, AST); | ||
} | ||
}, false); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
1
10
306617
3542