How to use the nearley/lib/generate.javascript function in nearley

To help you get started, we’ve selected a few nearley examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ballercat / walt / generator.js View on Github external
module.exports = function customGenerator(parser) {
  let output = `// Custom Walt Grammar Generator
function id(x) { return x[0]; }

module.exports = function() {
  ${parser.body.join('\n')}

  return {
    Lexer: ${parser.config.lexer},
    ParserRules: ${serializeRules(
      parser.rules,
      generate.javascript.builtinPostprocessors
    )},
    ParserStart: ${JSON.stringify(parser.start)}
  };
}
`;

  return output;
};
github ballercat / walt / packages / rollup-plugin-walt-grammar / index.js View on Github external
function customGenerator(parser) {
  let output = `// Custom Walt Grammar Generator
function id(x) { return x[0]; }

export default function grammar() {
  ${parser.body.join('\n')}

  return {
    Lexer: ${parser.config.lexer},
    ParserRules: ${serializeRules(
      parser.rules,
      generate.javascript.builtinPostprocessors
    )},
    ParserStart: ${JSON.stringify(parser.start)}
  };
}
`;

  return output;
}