Closed Floffah closed 4 years ago
for some reason every time i test my grammar it runs out of memory.
i tracked it down to the comment part of my grammar causing the issue.
grammar
@builtin "whitespace.ne" main -> _ main | comment main comment -> "//" (_ | [a-z] | [A-Z]):* {% function(data) { return { type: "comment", message: data.join(""), } } %}
test js file
const nearley = require("nearley"); const grammar = require("../parse/grammar.js"); const parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); parser.feed("// test "); console.log(parser.results);
Having a _ option inside a * leads to ambiguity. Try changing it to (_ [a-zA-Z]:+):*, that should make things better.
_
*
(_ [a-zA-Z]:+):*
for some reason every time i test my grammar it runs out of memory.
i tracked it down to the comment part of my grammar causing the issue.
grammar
test js file