X-Git-Url: https://git.auder.net/images/pieces/Cwda/wl.svg?a=blobdiff_plain;f=parser.js;h=6caf0a9f5a3f0dfdc4f153a5d8e4ffd54dba02df;hb=006d95a3942660083d2c957afea5338c2de8642d;hp=ba113e57329a10afdb4c2bcefdd4d5dec2944eea;hpb=48a55161a22d169781fa3e0805ed2da7dac952cf;p=erdiag.git diff --git a/parser.js b/parser.js index ba113e5..6caf0a9 100644 --- a/parser.js +++ b/parser.js @@ -67,7 +67,7 @@ class ErDiags { case '[': // Entity = { name: { attributes, [weak] } } - let name = lines[start].match(/[^\[\]\s]+/)[0]; + let name = lines[start].match(/[^\[\]"\s]+/)[0]; let entity = { attributes: this.parseAttributes(lines, start+1, end) }; if (lines[start].charAt(1) == '[') entity.weak = true; @@ -79,7 +79,7 @@ class ErDiags case '{': //association // Association = { [name], [attributes], [weak], entities: ArrayOf entity indices } let relationship = { }; - let nameRes = lines[start].match(/[^{}\s]+/); + let nameRes = lines[start].match(/[^{}"\s]+/); if (nameRes !== null) relationship.name = nameRes[0]; if (lines[start].charAt(1) == '{') @@ -102,7 +102,7 @@ class ErDiags field.isKey = true; line = line.slice(1); } - field.name = line.match(/[^()\s]+/)[0]; + field.name = line.match(/[^()"\s]+/)[0]; let parenthesis = line.match(/\((.+)\)/); if (parenthesis !== null) { @@ -196,7 +196,7 @@ class ErDiags _.shuffle(Object.keys(this.entities)).forEach( name => { if (mcdStyle == "bubble") { - mcdDot += name + '[shape=rectangle, label="' + name + '"'; + mcdDot += '"' + name + '" [shape=rectangle, label="' + name + '"'; if (this.entities[name].weak) mcdDot += ', peripheries=2'; mcdDot += '];\n'; @@ -205,17 +205,17 @@ class ErDiags _.shuffle(this.entities[name].attributes).forEach( a => { let label = (a.isKey ? '#' : '') + a.name; let attrName = name + '_' + a.name; - mcdDot += attrName + '[shape=ellipse, label="' + label + '"];\n'; + mcdDot += '"' + attrName + '" [shape=ellipse, label="' + label + '"];\n'; if (Math.random() < 0.5) - mcdDot += attrName + ' -- ' + name + ';\n'; + mcdDot += '"' + attrName + '" -- "' + name + '";\n'; else - mcdDot += name + ' -- ' + attrName + ';\n'; + mcdDot += '"' + name + '" -- "' + attrName + '";\n'; }); } } else { - mcdDot += name + '[label=<'; + mcdDot += '"' + name + '" [label=<'; if (this.entities[name].weak) { mcdDot += '
' + name + ' |
' + label + ' |