X-Git-Url: https://git.auder.net/?p=erdiag.git;a=blobdiff_plain;f=parser.js;h=6caf0a9f5a3f0dfdc4f153a5d8e4ffd54dba02df;hp=51a05e0815f2b9d60c29b2f104f610d2bab86f9d;hb=006d95a3942660083d2c957afea5338c2de8642d;hpb=eabe4071112a744a7be577263013a9bb0e4eb524 diff --git a/parser.js b/parser.js index 51a05e0..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 + ' |