How to use the chevrotain.createSyntaxDiagramsCode function in chevrotain

To help you get started, we’ve selected a few chevrotain 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 RokuRoad / bright / test / diagram.spec.ts View on Github external
test('Generate AST Productions', () => {
    // extract the serialized parser.
    const serializedGrammar = parserInstance.getSerializedGastProductions()

    // create the HTML Text
    const htmlText = createSyntaxDiagramsCode(serializedGrammar)

    // Write the HTML file to disk
    const outPath = resolve(__dirname, '../diagram')

    writeFileSync(outPath + '/index.html', htmlText)
  })
})
github jhipster / prettier-java / packages / java-parser / scripts / gen-diagrams.js View on Github external
* - npm install in the parent directory (parser) to install dependencies
 * - Run this in file in node.js (node gen_diagrams.js)
 * - open the "generated_diagrams.html" that will be created in this folder using
 *   your favorite browser.
 */
const path = require("path");
const fs = require("fs");
const chevrotain = require("chevrotain");
const JavaParser = require("../src/parser");

// extract the serialized grammar.
const parserInstance = new JavaParser([]);
const serializedGrammar = parserInstance.getSerializedGastProductions();

// create the HTML Text
const htmlText = chevrotain.createSyntaxDiagramsCode(serializedGrammar);

// Write the HTML file to disk
const outPath = path.resolve(__dirname, "./");
fs.writeFileSync(outPath + "/../diagrams.html", htmlText);
github SAP / chevrotain / examples / parser / diagrams / gen_diagrams.js View on Github external
* - npm install in the parent directory (parser) to install dependencies
 * - Run this in file in node.js (node gen_diagrams.js)
 * - open the "generated_diagrams.html" that will be created in this folder using
 *   your favorite browser.
 */
const path = require("path")
const fs = require("fs")
const chevrotain = require("chevrotain")
const grammar = require("./grammar")

// extract the serialized grammar.
const parserInstance = grammar.parserInstance
const serializedGrammar = parserInstance.getSerializedGastProductions()

// create the HTML Text
const htmlText = chevrotain.createSyntaxDiagramsCode(serializedGrammar)

// Write the HTML file to disk
const outPath = path.resolve(__dirname, "./")
fs.writeFileSync(outPath + "/generated_diagrams.html", htmlText)