UNPKG

plantuml-parser

Version:

Parse PlantUML with JavaScript or TypeScript

1,199 lines (1,198 loc) 624 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = exports.SyntaxError = void 0; // import types var types = require("./types"); // tslint:disable:only-arrow-functions // tslint:disable:object-literal-shorthand // tslint:disable:trailing-comma // tslint:disable:object-literal-sort-keys // tslint:disable:one-variable-per-declaration // tslint:disable:max-line-length // tslint:disable:no-consecutive-blank-lines // tslint:disable:align // Generated by PEG.js v. 0.10.0 (ts-pegjs plugin v. 0.2.7 ) // // https://pegjs.org/ https://github.com/metadevpro/ts-pegjs "use strict"; var SyntaxError = /** @class */ (function (_super) { __extends(SyntaxError, _super); function SyntaxError(message, expected, found, location) { var _this = _super.call(this) || this; _this.message = message; _this.expected = expected; _this.found = found; _this.location = location; _this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(_this, SyntaxError); } return _this; } SyntaxError.buildMessage = function (expected, found) { function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, "\\\\") .replace(/"/g, "\\\"") .replace(/\0/g, "\\0") .replace(/\t/g, "\\t") .replace(/\n/g, "\\n") .replace(/\r/g, "\\r") .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, "\\\\") .replace(/\]/g, "\\]") .replace(/\^/g, "\\^") .replace(/-/g, "\\-") .replace(/\0/g, "\\0") .replace(/\t/g, "\\t") .replace(/\n/g, "\\n") .replace(/\r/g, "\\r") .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); }); } function describeExpectation(expectation) { switch (expectation.type) { case "literal": return "\"" + literalEscape(expectation.text) + "\""; case "class": var escapedParts = expectation.parts.map(function (part) { return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part); }); return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; case "any": return "any character"; case "end": return "end of input"; case "other": return expectation.description; } } function describeExpected(expected1) { var descriptions = expected1.map(describeExpectation); var i; var j; descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found1) { return found1 ? "\"" + literalEscape(found1) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; return SyntaxError; }(Error)); exports.SyntaxError = SyntaxError; function peg$parse(input, options) { options = options !== undefined ? options : {}; var peg$FAILED = {}; var peg$startRuleFunctions = { PlantUMLFile: peg$parsePlantUMLFile }; var peg$startRuleFunction = peg$parsePlantUMLFile; var peg$c0 = function (diagrams) { return diagrams; }; var peg$c1 = "@startuml"; var peg$c2 = peg$literalExpectation("@startuml", false); var peg$c3 = peg$anyExpectation(); var peg$c4 = function () { return []; }; var peg$c5 = " "; var peg$c6 = peg$literalExpectation(" ", false); var peg$c7 = "@enduml"; var peg$c8 = peg$literalExpectation("@enduml", false); var peg$c9 = function (uml) { return uml; }; var peg$c10 = "("; var peg$c11 = peg$literalExpectation("(", false); var peg$c12 = "id"; var peg$c13 = peg$literalExpectation("id", false); var peg$c14 = "="; var peg$c15 = peg$literalExpectation("=", false); var peg$c16 = ")"; var peg$c17 = peg$literalExpectation(")", false); var peg$c18 = function (elements) { return new types.UML(removeUndefined(elements)); }; var peg$c19 = "}"; var peg$c20 = peg$literalExpectation("}", false); var peg$c21 = "end note"; var peg$c22 = peg$literalExpectation("end note", false); var peg$c23 = function () { }; var peg$c24 = "'"; var peg$c25 = peg$literalExpectation("'", false); var peg$c26 = function (comment) { return new types.Comment(extractText(comment)); }; var peg$c27 = "/'"; var peg$c28 = peg$literalExpectation("/'", false); var peg$c29 = "'/"; var peg$c30 = peg$literalExpectation("'/", false); var peg$c31 = "skinparam "; var peg$c32 = peg$literalExpectation("skinparam ", true); var peg$c33 = "{"; var peg$c34 = peg$literalExpectation("{", false); var peg$c35 = function (name) { }; var peg$c36 = function () { }; var peg$c37 = "together "; var peg$c38 = peg$literalExpectation("together ", true); var peg$c39 = function (elements) { return removeUndefined(elements); }; var peg$c40 = function (type, name, elements) { return new types.Group((name === null || name === void 0 ? void 0 : name.name) || "", (name === null || name === void 0 ? void 0 : name.title) || "", type, removeUndefined(elements)); }; var peg$c41 = "package"; var peg$c42 = peg$literalExpectation("package", true); var peg$c43 = "namespace"; var peg$c44 = peg$literalExpectation("namespace", true); var peg$c45 = "node"; var peg$c46 = peg$literalExpectation("node", true); var peg$c47 = "folder"; var peg$c48 = peg$literalExpectation("folder", true); var peg$c49 = "frame"; var peg$c50 = peg$literalExpectation("frame", true); var peg$c51 = "cloud"; var peg$c52 = peg$literalExpectation("cloud", true); var peg$c53 = "database"; var peg$c54 = peg$literalExpectation("database", true); var peg$c55 = "rectangle"; var peg$c56 = peg$literalExpectation("rectangle", true); var peg$c57 = "note "; var peg$c58 = peg$literalExpectation("note ", true); var peg$c59 = ":"; var peg$c60 = peg$literalExpectation(":", false); var peg$c61 = function (of, text) { return new types.Note(extractText(text), of); }; var peg$c62 = "as "; var peg$c63 = peg$literalExpectation("as ", false); var peg$c64 = function (text) { return new types.Note(text); }; var peg$c65 = "of "; var peg$c66 = peg$literalExpectation("of ", true); var peg$c67 = "::"; var peg$c68 = peg$literalExpectation("::", true); var peg$c69 = function (elementName, memberName) { return elementName.name + "::" + memberName.name; }; var peg$c70 = function (elementName) { return elementName.name; }; var peg$c71 = "abstract "; var peg$c72 = peg$literalExpectation("abstract ", true); var peg$c73 = "class "; var peg$c74 = peg$literalExpectation("class ", false); var peg$c75 = function (isAbstract, name, generics, extends_, implements_, stereotypes, members) { return new types.Class(name.name, name.title, !!isAbstract, removeUndefined(members), extends_, implements_, generics, stereotypes); }; var peg$c76 = function (isAbstract, name, generics, extends_, implements_, stereotypes) { return new types.Class(name.name, name.title, !!isAbstract, [], extends_, implements_, generics, stereotypes); }; var peg$c77 = "--"; var peg$c78 = peg$literalExpectation("--", false); var peg$c79 = "-"; var peg$c80 = peg$literalExpectation("-", false); var peg$c81 = ".."; var peg$c82 = peg$literalExpectation("..", false); var peg$c83 = "."; var peg$c84 = peg$literalExpectation(".", false); var peg$c85 = "=="; var peg$c86 = peg$literalExpectation("==", false); var peg$c87 = "__"; var peg$c88 = peg$literalExpectation("__", false); var peg$c89 = "_"; var peg$c90 = peg$literalExpectation("_", false); var peg$c91 = "static "; var peg$c92 = peg$literalExpectation("static ", true); var peg$c93 = function (isStatic, accessor, type, name, _arguments) { return new types.Method(name, !!isStatic, accessor, type, extractText(_arguments)); }; var peg$c94 = function (isStatic, accessor, name, _arguments) { return new types.Method(name, !!isStatic, accessor, undefined, extractText(_arguments)); }; var peg$c95 = function (isStatic, accessor, type, name) { return new types.MemberVariable(name, !!isStatic, accessor, type); }; var peg$c96 = peg$literalExpectation(":", true); var peg$c97 = function (isStatic, accessor, name, type) { return new types.MemberVariable(name, !!isStatic, accessor, type); }; var peg$c98 = function (isStatic, accessor, name) { return new types.MemberVariable(name, !!isStatic, accessor); }; var peg$c99 = "interface "; var peg$c100 = peg$literalExpectation("interface ", true); var peg$c101 = function (name, generics, extends_, implements_, stereotypes, members) { return new types.Interface(name.name, name.title, removeUndefined(members), extends_, implements_, generics, stereotypes); }; var peg$c102 = function (name, generics, extends_, implements_, stereotypes) { return new types.Interface(name.name, name.title, [], extends_, implements_, generics, stereotypes); }; var peg$c103 = "enum "; var peg$c104 = peg$literalExpectation("enum ", true); var peg$c105 = function (name, generics, extends_, implements_, stereotypes, members) { return new types.Enum(name.name, name.title, removeUndefined(members), extends_, implements_, generics, stereotypes); }; var peg$c106 = function (name, generics, extends_, implements_, stereotypes) { return new types.Enum(name.name, name.title, [], extends_, implements_, generics, stereotypes); }; var peg$c107 = "component "; var peg$c108 = peg$literalExpectation("component ", true); var peg$c109 = function (name) { return new types.Component(name.name, name.title); }; var peg$c110 = "["; var peg$c111 = peg$literalExpectation("[", false); var peg$c112 = "]"; var peg$c113 = peg$literalExpectation("]", false); var peg$c114 = "as"; var peg$c115 = peg$literalExpectation("as", false); var peg$c116 = function (title, name) { return { name: name, title: extractText(title), }; }; var peg$c117 = function (name) { name = extractText(name); return { name: name, title: name, }; }; var peg$c118 = "usecase "; var peg$c119 = peg$literalExpectation("usecase ", true); var peg$c120 = function (name) { return new types.UseCase(name.name, name.title); }; var peg$c121 = function (left, leftCardinality, leftArrowHead, leftArrowBody, hidden, rightArrowBody, rightArrowHead, rightCardinality, right, label) { return new types.Relationship(left.name, right.name, left.type, right.type, leftArrowHead, rightArrowHead, leftArrowBody, rightArrowBody, leftCardinality, rightCardinality, label, !!hidden); }; var peg$c122 = function (left, leftCardinality, leftArrowHead, arrowBody, rightArrowHead, rightCardinality, right, label) { return new types.Relationship(left.name, right.name, left.type, right.type, leftArrowHead, rightArrowHead, arrowBody, arrowBody, leftCardinality, rightCardinality, label, false); }; var peg$c123 = "<|"; var peg$c124 = peg$literalExpectation("<|", false); var peg$c125 = "|>"; var peg$c126 = peg$literalExpectation("|>", false); var peg$c127 = "*"; var peg$c128 = peg$literalExpectation("*", false); var peg$c129 = "o"; var peg$c130 = peg$literalExpectation("o", false); var peg$c131 = "<"; var peg$c132 = peg$literalExpectation("<", false); var peg$c133 = ">"; var peg$c134 = peg$literalExpectation(">", false); var peg$c135 = "#"; var peg$c136 = peg$literalExpectation("#", false); var peg$c137 = "x"; var peg$c138 = peg$literalExpectation("x", false); var peg$c139 = "+"; var peg$c140 = peg$literalExpectation("+", false); var peg$c141 = "^"; var peg$c142 = peg$literalExpectation("^", false); var peg$c143 = "()"; var peg$c144 = peg$literalExpectation("()", false); var peg$c145 = /^[\-]/; var peg$c146 = peg$classExpectation(["-"], false, false); var peg$c147 = function () { return '-'; }; var peg$c148 = /^[.]/; var peg$c149 = peg$classExpectation(["."], false, false); var peg$c150 = function () { return '.'; }; var peg$c151 = function (label) { return extractText(label); }; var peg$c152 = "[hidden]"; var peg$c153 = peg$literalExpectation("[hidden]", false); var peg$c154 = function (generics) { return removeUndefined(generics.map(function (generic) { return generic[0]; })); }; var peg$c155 = "<<"; var peg$c156 = peg$literalExpectation("<<", false); var peg$c157 = function (generic) { return extractText(generic); }; var peg$c158 = function (stereotypes) { return removeUndefined(stereotypes.map(function (stereotype) { return stereotype[0]; })); }; var peg$c159 = ">>"; var peg$c160 = peg$literalExpectation(">>", false); var peg$c161 = function (stereotype) { return extractText(stereotype); }; var peg$c162 = "extends "; var peg$c163 = peg$literalExpectation("extends ", true); var peg$c164 = function (parents) { return parents; }; var peg$c165 = "implements "; var peg$c166 = peg$literalExpectation("implements ", true); var peg$c167 = "digraph"; var peg$c168 = peg$literalExpectation("digraph", true); var peg$c169 = "state"; var peg$c170 = peg$literalExpectation("state", true); var peg$c171 = function (element) { return { name: element.name, type: 'Component', }; }; var peg$c172 = function (element) { return { name: element.name, type: 'UseCase', }; }; var peg$c173 = function (name) { return { name: name, type: 'Unknown', }; }; var peg$c174 = peg$literalExpectation("as ", true); var peg$c175 = function (title, name) { return { name: name, title: title, }; }; var peg$c176 = function (name, title) { return { name: name, title: title, }; }; var peg$c177 = function (name) { return { name: name, title: name, }; }; var peg$c178 = function (name) { return { name: name.name, title: name.title, }; }; var peg$c179 = "\""; var peg$c180 = peg$literalExpectation("\"", false); var peg$c181 = function (string) { return extractText(string); }; var peg$c182 = /^[A-Za-z0-9._]/; var peg$c183 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], ".", "_"], false, false); var peg$c184 = function (name) { return name.join(''); }; var peg$c185 = function (nameListItems, lastNameListItem) { return removeUndefined(nameListItems.concat(lastNameListItem)); }; var peg$c186 = ","; var peg$c187 = peg$literalExpectation(",", false); var peg$c188 = function (name) { return name; }; var peg$c189 = /^[\-#~+]/; var peg$c190 = peg$classExpectation(["-", "#", "~", "+"], false, false); var peg$c191 = /^[#A-Za-z0-9]/; var peg$c192 = peg$classExpectation(["#", ["A", "Z"], ["a", "z"], ["0", "9"]], false, false); var peg$c193 = function (color) { return color.join(''); }; var peg$c194 = "left"; var peg$c195 = peg$literalExpectation("left", true); var peg$c196 = "right"; var peg$c197 = peg$literalExpectation("right", true); var peg$c198 = "up"; var peg$c199 = peg$literalExpectation("up", true); var peg$c200 = "down"; var peg$c201 = peg$literalExpectation("down", true); var peg$c202 = "top"; var peg$c203 = peg$literalExpectation("top", true); var peg$c204 = "bottom"; var peg$c205 = peg$literalExpectation("bottom", true); var peg$c206 = /^[ \t]/; var peg$c207 = peg$classExpectation([" ", "\t"], false, false); var peg$c208 = "\n"; var peg$c209 = peg$literalExpectation("\n", false); var peg$c210 = "\r\n"; var peg$c211 = peg$literalExpectation("\r\n", false); var peg$c212 = function (type, alias, label, descr, sprite, tags, link) { return new types.Stdlib_C4_Context({ source: 'Stdlib_C4', name: type }, alias.name, label.name, descr ? descr.name : '', sprite ? sprite.name : '', tags ? tags.name : '', link ? link.name : ''); }; var peg$c213 = "person_ext"; var peg$c214 = peg$literalExpectation("Person_Ext", true); var peg$c215 = "systemdb_ext"; var peg$c216 = peg$literalExpectation("SystemDb_Ext", true); var peg$c217 = "systemqueue_ext"; var peg$c218 = peg$literalExpectation("SystemQueue_Ext", true); var peg$c219 = "person"; var peg$c220 = peg$literalExpectation("Person", true); var peg$c221 = "system_ext"; var peg$c222 = peg$literalExpectation("System_Ext", true); var peg$c223 = "systemdb"; var peg$c224 = peg$literalExpectation("SystemDb", true); var peg$c225 = "systemqueue"; var peg$c226 = peg$literalExpectation("SystemQueue", true); var peg$c227 = "system"; var peg$c228 = peg$literalExpectation("System", true); var peg$c229 = function (type, alias, label, techn, descr, sprite, tags, link) { return new types.Stdlib_C4_Container_Component({ source: 'Stdlib_C4', name: type }, alias.name, label.name, techn ? techn.name : '', descr ? descr.name : '', sprite ? sprite.name : '', tags ? tags.name : '', link ? link.name : ''); }; var peg$c230 = "containerqueue_ext"; var peg$c231 = peg$literalExpectation("ContainerQueue_Ext", true); var peg$c232 = "containerqueue"; var peg$c233 = peg$literalExpectation("ContainerQueue", true); var peg$c234 = "containerdb_ext"; var peg$c235 = peg$literalExpectation("ContainerDb_Ext", true); var peg$c236 = "containerdb"; var peg$c237 = peg$literalExpectation("ContainerDb", true); var peg$c238 = "container_ext"; var peg$c239 = peg$literalExpectation("Container_Ext", true); var peg$c240 = "container"; var peg$c241 = peg$literalExpectation("Container", true); var peg$c242 = "componentqueue_ext"; var peg$c243 = peg$literalExpectation("ComponentQueue_Ext", true); var peg$c244 = "componentqueue"; var peg$c245 = peg$literalExpectation("ComponentQueue", true); var peg$c246 = "componentdb_ext"; var peg$c247 = peg$literalExpectation("ComponentDb_Ext", true); var peg$c248 = "componentdb"; var peg$c249 = peg$literalExpectation("ComponentDb", true); var peg$c250 = "component_ext"; var peg$c251 = peg$literalExpectation("Component_Ext", true); var peg$c252 = "component"; var peg$c253 = peg$literalExpectation("Component", true); var peg$c254 = "Boundary"; var peg$c255 = peg$literalExpectation("Boundary", false); var peg$c256 = function (alias, label, type, tags, link, elements) { return new types.Stdlib_C4_Boundary({ source: 'Stdlib_C4', name: type ? type.name : 'Boundary' }, alias.name, label.name, tags ? tags.name : '', link ? link.name : '', removeUndefined(elements)); }; var peg$c257 = function (type, alias, label, tags, link, elements) { return new types.Stdlib_C4_Boundary({ source: 'Stdlib_C4', name: type }, alias.name, label.name, tags ? tags.name : '', link ? link.name : '', removeUndefined(elements)); }; var peg$c258 = "enterprise_boundary"; var peg$c259 = peg$literalExpectation("Enterprise_Boundary", true); var peg$c260 = "system_boundary"; var peg$c261 = peg$literalExpectation("System_Boundary", true); var peg$c262 = "container_boundary"; var peg$c263 = peg$literalExpectation("Container_Boundary", true); var peg$c264 = function (type, from, to, label, techn, descr, sprite, tags, link) { return new types.Stdlib_C4_Dynamic_Rel({ source: 'Stdlib_C4', name: type }, from.name, to.name, label.name, techn ? techn.name : '', descr ? descr.name : '', sprite ? sprite.name : '', tags ? tags.name : '', link ? link.name : ''); }; var peg$c265 = "rel_neighbor"; var peg$c266 = peg$literalExpectation("Rel_Neighbor", true); var peg$c267 = "rel_back_neighbor"; var peg$c268 = peg$literalExpectation("Rel_Back_Neighbor", true); var peg$c269 = "rel_back"; var peg$c270 = peg$literalExpectation("Rel_Back", true); var peg$c271 = "rel_down"; var peg$c272 = peg$literalExpectation("Rel_Down", true); var peg$c273 = "rel_d"; var peg$c274 = peg$literalExpectation("Rel_D", true); var peg$c275 = "rel_up"; var peg$c276 = peg$literalExpectation("Rel_Up", true); var peg$c277 = "rel_u"; var peg$c278 = peg$literalExpectation("Rel_U", true); var peg$c279 = "rel_left"; var peg$c280 = peg$literalExpectation("Rel_Left", true); var peg$c281 = "rel_l"; var peg$c282 = peg$literalExpectation("Rel_L", true); var peg$c283 = "rel_right"; var peg$c284 = peg$literalExpectation("Rel_Right", true); var peg$c285 = "rel_r"; var peg$c286 = peg$literalExpectation("Rel_R", true); var peg$c287 = "rel"; var peg$c288 = peg$literalExpectation("Rel", true); var peg$c289 = "birel_neighbor"; var peg$c290 = peg$literalExpectation("BiRel_Neighbor", true); var peg$c291 = "birel_down"; var peg$c292 = peg$literalExpectation("BiRel_Down", true); var peg$c293 = "birel_d"; var peg$c294 = peg$literalExpectation("BiRel_D", true); var peg$c295 = "birel_up"; var peg$c296 = peg$literalExpectation("BiRel_Up", true); var peg$c297 = "birel_u"; var peg$c298 = peg$literalExpectation("BiRel_U", true); var peg$c299 = "birel_left"; var peg$c300 = peg$literalExpectation("BiRel_Left", true); var peg$c301 = "birel_l"; var peg$c302 = peg$literalExpectation("BiRel_L", true); var peg$c303 = "birel_right"; var peg$c304 = peg$literalExpectation("BiRel_Right", true); var peg$c305 = "birel_r"; var peg$c306 = peg$literalExpectation("BiRel_R", true); var peg$c307 = "birel"; var peg$c308 = peg$literalExpectation("BiRel", true); var peg$c309 = function (type_, alias, label, type, descr, sprite, tags, link) { return new types.Stdlib_C4_Deployment({ source: 'Stdlib_C4', name: type_ }, alias.name, label.name, type ? type.name : '', descr ? descr.name : '', sprite ? sprite.name : '', tags ? tags.name : '', link ? link.name : ''); }; var peg$c310 = "deployment_node_l"; var peg$c311 = peg$literalExpectation("Deployment_Node_L", true); var peg$c312 = "deployment_node_r"; var peg$c313 = peg$literalExpectation("Deployment_Node_R", true); var peg$c314 = "deployment_node"; var peg$c315 = peg$literalExpectation("Deployment_Node", true); var peg$c316 = "Node_L"; var peg$c317 = peg$literalExpectation("Node_L", false); var peg$c318 = "Node_R"; var peg$c319 = peg$literalExpectation("Node_R", false); var peg$c320 = "Node"; var peg$c321 = peg$literalExpectation("Node", false); var peg$c322 = "Rel_"; var peg$c323 = peg$literalExpectation("Rel_", false); var peg$c324 = function (alias1, alias2, label, direction) { return new types.Stdlib_C4_Rel({ source: 'Stdlib_C4', name: 'Rel_' }, alias1.name, alias2.name, label.name, direction.name, undefined); }; var peg$c325 = function (alias1, alias2, label, techn, direction) { return new types.Stdlib_C4_Rel({ source: 'Stdlib_C4', name: 'Rel_' }, alias1.name, alias2.name, label.name, direction.name, techn.name); }; var peg$currPos = 0; var peg$savedPos = 0; var peg$posDetailsCache = [{ line: 1, column: 1 }]; var peg$maxFailPos = 0; var peg$maxFailExpected = []; var peg$silentFails = 0; var peg$result; if (options.startRule !== undefined) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location1) { location1 = location1 !== undefined ? location1 : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location1); } function error(message, location1) { location1 = location1 !== undefined ? location1 : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location1); } function peg$literalExpectation(text1, ignoreCase) { return { type: "literal", text: text1, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos]; var p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos); var endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected1) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected1); } function peg$buildSimpleError(message, location1) { return new SyntaxError(message, [], "", location1); } function peg$buildStructuredError(expected1, found, location1) { return new SyntaxError(SyntaxError.buildMessage(expected1, found), expected1, found, location1); } function peg$parsePlantUMLFile() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseDiagrams(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = []; s2 = peg$currPos; s3 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s4 = peg$c1; peg$currPos += 9; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s4 === peg$FAILED) { s3 = undefined; } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { if (input.length > peg$currPos) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$currPos; s3 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s4 = peg$c1; peg$currPos += 9; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s4 === peg$FAILED) { s3 = undefined; } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { if (input.length > peg$currPos) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c4(); } s0 = s1; } return s0; } function peg$parseDiagrams() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; s0 = []; s1 = peg$currPos; s2 = []; s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s5 = peg$c1; peg$currPos += 9; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s5 === peg$FAILED) { s4 = undefined; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s5 = peg$c1; peg$currPos += 9; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s5 === peg$FAILED) { s4 = undefined; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } if (s2 !== peg$FAILED) { if (input.substr(peg$currPos, 9) === peg$c1) { s3 = peg$c1; peg$currPos += 9; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s3 !== peg$FAILED) { s4 = peg$parseDiagramId(); if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 32) { s6 = peg$c5; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { s8 = peg$parseDiagramName(); if (s8 !== peg$FAILED) { s6 = [s6, s7, s8]; s5 = s6; } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } if (s5 === peg$FAILED) { s5 = null; } if (s5 !== peg$FAILED) { s6 = peg$parse_(); if (s6 !== peg$FAILED) { s7 = peg$parseNewLine(); if (s7 !== peg$FAILED) { s8 = peg$parseUML(); if (s8 !== peg$FAILED) { if (input.substr(peg$currPos, 7) === peg$c7) { s9 = peg$c7; peg$currPos += 7; } else { s9 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } if (s9 !== peg$FAILED) { s10 = peg$parse_(); if (s10 !== peg$FAILED) { s11 = peg$parseNewLine(); if (s11 === peg$FAILED) { s11 = null; } if (s11 !== peg$FAILED) { s12 = []; s13 = peg$currPos; s14 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s15 = peg$c1; peg$currPos += 9; } else { s15 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s15 === peg$FAILED) { s14 = undefined; } else { peg$currPos = s14; s14 = peg$FAILED; } if (s14 !== peg$FAILED) { if (input.length > peg$currPos) { s15 = input.charAt(peg$currPos); peg$currPos++; } else { s15 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s15 !== peg$FAILED) { s14 = [s14, s15]; s13 = s14; } else { peg$currPos = s13; s13 = peg$FAILED; } } else { peg$currPos = s13; s13 = peg$FAILED; } while (s13 !== peg$FAILED) { s12.push(s13); s13 = peg$currPos; s14 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s15 = peg$c1; peg$currPos += 9; } else { s15 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s15 === peg$FAILED) { s14 = undefined; } else { peg$currPos = s14; s14 = peg$FAILED; } if (s14 !== peg$FAILED) { if (input.length > peg$currPos) { s15 = input.charAt(peg$currPos); peg$currPos++; } else { s15 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s15 !== peg$FAILED) { s14 = [s14, s15]; s13 = s14; } else { peg$currPos = s13; s13 = peg$FAILED; } } else { peg$currPos = s13; s13 = peg$FAILED; } } if (s12 !== peg$FAILED) { peg$savedPos = s1; s2 = peg$c9(s8); s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); s1 = peg$currPos; s2 = []; s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 9) === peg$c1) { s5 = peg$c1; peg$currPos += 9; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } peg$silentFails--; if (s5 === peg$FAILED) { s4 = undefined; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } while (s3 !== peg$FAILED) {