UNPKG

univac

Version:

Generate AST of lots of common programming languages using antlr4. JavaScript API and CLI tool.

30 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var parserImpl_1 = require("../parserImpl"); function getAbnfImpl() { return { Lexer: require('../grammar/abnf/AbnfLexer').AbnfLexer, Parser: require('../grammar/abnf/AbnfParser').AbnfParser, mainRule: 'rulelist', redundantTypes: function (node, parent) { return parserImpl_1.preventRedundantTypeNames(node, parent, function (node) { return ['repetition', 'element', 'option', 'alternation', 'concatenation', 'elements'].includes(node.type); }); }, mutate: mutate }; } exports.getAbnfImpl = getAbnfImpl; function mutate(ast, impl) { function f(n, p) { if (n.start === undefined) { delete n.start; } if (n.stop === undefined) { delete n.stop; } if (n.type === 'rule_') { n.type = 'rule'; } n.children.forEach(function (c) { return f(c, n); }); return n; } return f(ast); } //# sourceMappingURL=abnf.js.map