|
CCS.Parser = (function() { |
|
/* |
|
* Generated by PEG.js 0.8.0. |
|
* |
|
* http://pegjs.majda.cz/ |
|
*/ |
|
|
|
function peg$subclass(child, parent) { |
|
function ctor() { this.constructor = child; } |
|
ctor.prototype = parent.prototype; |
|
child.prototype = new ctor(); |
|
} |
|
|
|
function SyntaxError(message, expected, found, offset, line, column) { |
|
this.message = message; |
|
this.expected = expected; |
|
this.found = found; |
|
this.offset = offset; |
|
this.line = line; |
|
this.column = column; |
|
|
|
this.name = "SyntaxError"; |
|
} |
|
|
|
peg$subclass(SyntaxError, Error); |
|
|
|
function parse(input) { |
|
var options = arguments.length > 1 ? arguments[1] : {}, |
|
|
|
peg$FAILED = {}, |
|
|
|
peg$startRuleFunctions = { System: peg$parseSystem }, |
|
peg$startRuleFunction = peg$parseSystem, |
|
|
|
peg$c0 = function() { |
|
return system; |
|
}, |
|
peg$c1 = peg$FAILED, |
|
peg$c2 = "=", |
|
peg$c3 = { type: "literal", value: "=", description: "\"=\"" }, |
|
peg$c4 = ";", |
|
peg$c5 = { type: "literal", value: ";", description: "\";\"" }, |
|
peg$c6 = null, |
|
peg$c7 = function(id, P) { |
|
try{ |
|
system.defineNamedProcess(id.text, P); |
|
} |
|
catch (e) { |
|
throw new CCS.ContextError( |
|
"Named process \"" + id.text + "\" is already defined!", |
|
id.line, id.column |
|
); |
|
} |
|
}, |
|
peg$c8 = "+", |
|
peg$c9 = { type: "literal", value: "+", description: "\"+\"" }, |
|
peg$c10 = function(P, Q) { |
|
return system.createChoiceProcess(P, Q); |
|
}, |
|
peg$c11 = [], |
|
peg$c12 = function(P, processes) { |
|
var Q; |
|
processes.unshift(P); |
|
while(processes.length > 1){ |
|
P = processes.shift(); |
|
Q = processes.shift(); |
|
processes.push(system.createParallelProcess(P, Q)); |
|
} |
|
return processes[0]; |
|
}, |
|
peg$c13 = "|", |
|
peg$c14 = { type: "literal", value: "|", description: "\"|\"" }, |
|
peg$c15 = function(P) { return P; }, |
|
peg$c16 = ".", |
|
peg$c17 = { type: "literal", value: ".", description: "\".\"" }, |
|
peg$c18 = function(action, P) { |
|
return system.createActionProcess(action, P); |
|
}, |
|
peg$c19 = function(P, modifiers) { |
|
modifiers.forEach(function(modifier){ |
|
if(modifier.isRestrict) |
|
P = system.createRestrictionProcess(P, modifier.actions); |
|
else |
|
P = system.createRenamingProcess(P, modifier.mappings); |
|
}); |
|
return P; |
|
}, |
|
peg$c20 = "\\", |
|
peg$c21 = { type: "literal", value: "\\", description: "\"\\\\\"" }, |
|
peg$c22 = "{", |
|
peg$c23 = { type: "literal", value: "{", description: "\"{\"" }, |
|
peg$c24 = "}", |
|
peg$c25 = { type: "literal", value: "}", description: "\"}\"" }, |
|
peg$c26 = function(actions) { |
|
return { |
|
isRestrict: true, |
|
actions: actions |
|
}; |
|
}, |
|
peg$c27 = "[", |
|
peg$c28 = { type: "literal", value: "[", description: "\"[\"" }, |
|
peg$c29 = "]", |
|
peg$c30 = { type: "literal", value: "]", description: "\"]\"" }, |
|
peg$c31 = function(mappings) { |
|
return { |
|
isRestrict: false, |
|
mappings: mappings |
|
}; |
|
}, |
|
peg$c32 = function(action, actions) { |
|
actions.unshift(action); |
|
return actions; |
|
}, |
|
peg$c33 = function() { return []; }, |
|
peg$c34 = ",", |
|
peg$c35 = { type: "literal", value: ",", description: "\",\"" }, |
|
peg$c36 = function(action) { return action; }, |
|
peg$c37 = function(mapping, mappings) { |
|
mappings.unshift(mapping); |
|
return mappings; |
|
}, |
|
peg$c38 = function(mapping) { return mapping; }, |
|
peg$c39 = "->", |
|
peg$c40 = { type: "literal", value: "->", description: "\"->\"" }, |
|
peg$c41 = function(from, to) { return {from: from, to: to}; }, |
|
peg$c42 = "(", |
|
peg$c43 = { type: "literal", value: "(", description: "\"(\"" }, |
|
peg$c44 = ")", |
|
peg$c45 = { type: "literal", value: ")", description: "\")\"" }, |
|
peg$c46 = "0", |
|
peg$c47 = { type: "literal", value: "0", description: "\"0\"" }, |
|
peg$c48 = function() { return system.createNullProcess(); }, |
|
peg$c49 = function(id) { |
|
var P = system.createNamedProcess(id.text); |
|
if(P.__line === undefined){ |
|
P.__line = id.line; |
|
P.__column = id.column; |
|
} |
|
return P; |
|
}, |
|
peg$c50 = { type: "other", description: "identifier" }, |
|
peg$c51 = /^[A-Za-z]/, |
|
peg$c52 = { type: "class", value: "[A-Za-z]", description: "[A-Za-z]" }, |
|
peg$c53 = /^[A-Za-z0-9_]/, |
|
peg$c54 = { type: "class", value: "[A-Za-z0-9_]", description: "[A-Za-z0-9_]" }, |
|
peg$c55 = function(first, rest) { |
|
return { |
|
text: first + rest.join(''), |
|
line: line(), |
|
column: column() |
|
}; |
|
}, |
|
peg$c56 = { type: "other", description: "action" }, |
|
peg$c57 = /^[A-Za-z']/, |
|
peg$c58 = { type: "class", value: "[A-Za-z']", description: "[A-Za-z']" }, |
|
peg$c59 = function(first, rest) { |
|
return system.declareAction(first + rest.join('')); |
|
}, |
|
peg$c60 = { type: "other", description: "whitespace" }, |
|
peg$c61 = /^[' '\n\r\t]/, |
|
peg$c62 = { type: "class", value: "[' '\\n\\r\\t]", description: "[' '\\n\\r\\t]" }, |
|
peg$c63 = function() {}, |
|
peg$c64 = "#", |
|
peg$c65 = { type: "literal", value: "#", description: "\"#\"" }, |
|
peg$c66 = /^[^\n]/, |
|
peg$c67 = { type: "class", value: "[^\\n]", description: "[^\\n]" }, |
|
peg$c68 = "\n", |
|
peg$c69 = { type: "literal", value: "\n", description: "\"\\n\"" }, |
|
peg$c70 = void 0, |
|
peg$c71 = /^[\S\s]/, |
|
peg$c72 = { type: "class", value: "[^]", description: "[^]" }, |
|
|
|
peg$currPos = 0, |
|
peg$reportedPos = 0, |
|
peg$cachedPos = 0, |
|
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, |
|
peg$maxFailPos = 0, |
|
peg$maxFailExpected = [], |
|
peg$silentFails = 0, |
|
|
|
peg$result; |
|
|
|
if ("startRule" in options) { |
|
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$reportedPos, peg$currPos); |
|
} |
|
|
|
function offset() { |
|
return peg$reportedPos; |
|
} |
|
|
|
function line() { |
|
return peg$computePosDetails(peg$reportedPos).line; |
|
} |
|
|
|
function column() { |
|
return peg$computePosDetails(peg$reportedPos).column; |
|
} |
|
|
|
function expected(description) { |
|
throw peg$buildException( |
|
null, |
|
[{ type: "other", description: description }], |
|
peg$reportedPos |
|
); |
|
} |
|
|
|
function error(message) { |
|
throw peg$buildException(message, null, peg$reportedPos); |
|
} |
|
|
|
function peg$computePosDetails(pos) { |
|
function advance(details, startPos, endPos) { |
|
var p, ch; |
|
|
|
for (p = startPos; p < endPos; p++) { |
|
ch = input.charAt(p); |
|
if (ch === "\n") { |
|
if (!details.seenCR) { details.line++; } |
|
details.column = 1; |
|
details.seenCR = false; |
|
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { |
|
details.line++; |
|
details.column = 1; |
|
details.seenCR = true; |
|
} else { |
|
details.column++; |
|
details.seenCR = false; |
|
} |
|
} |
|
} |
|
|
|
if (peg$cachedPos !== pos) { |
|
if (peg$cachedPos > pos) { |
|
peg$cachedPos = 0; |
|
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; |
|
} |
|
advance(peg$cachedPosDetails, peg$cachedPos, pos); |
|
peg$cachedPos = pos; |
|
} |
|
|
|
return peg$cachedPosDetails; |
|
} |
|
|
|
function peg$fail(expected) { |
|
if (peg$currPos < peg$maxFailPos) { return; } |
|
|
|
if (peg$currPos > peg$maxFailPos) { |
|
peg$maxFailPos = peg$currPos; |
|
peg$maxFailExpected = []; |
|
} |
|
|
|
peg$maxFailExpected.push(expected); |
|
} |
|
|
|
function peg$buildException(message, expected, pos) { |
|
function cleanupExpected(expected) { |
|
var i = 1; |
|
|
|
expected.sort(function(a, b) { |
|
if (a.description < b.description) { |
|
return -1; |
|
} else if (a.description > b.description) { |
|
return 1; |
|
} else { |
|
return 0; |
|
} |
|
}); |
|
|
|
while (i < expected.length) { |
|
if (expected[i - 1] === expected[i]) { |
|
expected.splice(i, 1); |
|
} else { |
|
i++; |
|
} |
|
} |
|
} |
|
|
|
function buildMessage(expected, found) { |
|
function stringEscape(s) { |
|
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } |
|
|
|
return s |
|
.replace(/\\/g, '\\\\') |
|
.replace(/"/g, '\\"') |
|
.replace(/\x08/g, '\\b') |
|
.replace(/\t/g, '\\t') |
|
.replace(/\n/g, '\\n') |
|
.replace(/\f/g, '\\f') |
|
.replace(/\r/g, '\\r') |
|
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) |
|
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) |
|
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) |
|
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); |
|
} |
|
|
|
var expectedDescs = new Array(expected.length), |
|
expectedDesc, foundDesc, i; |
|
|
|
for (i = 0; i < expected.length; i++) { |
|
expectedDescs[i] = expected[i].description; |
|
} |
|
|
|
expectedDesc = expected.length > 1 |
|
? expectedDescs.slice(0, -1).join(", ") |
|
+ " or " |
|
+ expectedDescs[expected.length - 1] |
|
: expectedDescs[0]; |
|
|
|
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; |
|
|
|
return "Expected " + expectedDesc + " but " + foundDesc + " found."; |
|
} |
|
|
|
var posDetails = peg$computePosDetails(pos), |
|
found = pos < input.length ? input.charAt(pos) : null; |
|
|
|
if (expected !== null) { |
|
cleanupExpected(expected); |
|
} |
|
|
|
return new SyntaxError( |
|
message !== null ? message : buildMessage(expected, found), |
|
expected, |
|
found, |
|
pos, |
|
posDetails.line, |
|
posDetails.column |
|
); |
|
} |
|
|
|
function peg$parseSystem() { |
|
var s0, s1; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseCCS(); |
|
if (s1 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c0(); |
|
} |
|
s0 = s1; |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseCCS() { |
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parse_(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = peg$parseIdentifier(); |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parse_(); |
|
if (s3 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 61) { |
|
s4 = peg$c2; |
|
peg$currPos++; |
|
} else { |
|
s4 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c3); } |
|
} |
|
if (s4 !== peg$FAILED) { |
|
s5 = peg$parse_(); |
|
if (s5 !== peg$FAILED) { |
|
s6 = peg$parseChoice(); |
|
if (s6 !== peg$FAILED) { |
|
s7 = peg$parse_(); |
|
if (s7 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 59) { |
|
s8 = peg$c4; |
|
peg$currPos++; |
|
} else { |
|
s8 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c5); } |
|
} |
|
if (s8 !== peg$FAILED) { |
|
s9 = peg$parse_(); |
|
if (s9 !== peg$FAILED) { |
|
s10 = peg$parseCCS(); |
|
if (s10 === peg$FAILED) { |
|
s10 = peg$c6; |
|
} |
|
if (s10 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c7(s2, s6); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseChoice() { |
|
var s0, s1, s2, s3, s4, s5; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseParallel(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = peg$parse_(); |
|
if (s2 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 43) { |
|
s3 = peg$c8; |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c9); } |
|
} |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parse_(); |
|
if (s4 !== peg$FAILED) { |
|
s5 = peg$parseChoice(); |
|
if (s5 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c10(s1, s5); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$parseParallel(); |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseParallel() { |
|
var s0, s1, s2, s3; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parsePrefix(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
s3 = peg$parseParallelPrefix(); |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
s3 = peg$parseParallelPrefix(); |
|
} |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c12(s1, s2); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseParallelPrefix() { |
|
var s0, s1, s2, s3, s4; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parse_(); |
|
if (s1 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 124) { |
|
s2 = peg$c13; |
|
peg$currPos++; |
|
} else { |
|
s2 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c14); } |
|
} |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parse_(); |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parsePrefix(); |
|
if (s4 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c15(s4); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parsePrefix() { |
|
var s0, s1, s2, s3, s4, s5; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseAction(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = peg$parse_(); |
|
if (s2 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 46) { |
|
s3 = peg$c16; |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c17); } |
|
} |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parse_(); |
|
if (s4 !== peg$FAILED) { |
|
s5 = peg$parsePrefix(); |
|
if (s5 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c18(s1, s5); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$parsePostfix(); |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parsePostfix() { |
|
var s0, s1, s2, s3; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseAtomic(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
s3 = peg$parseModifier(); |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
s3 = peg$parseModifier(); |
|
} |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c19(s1, s2); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$parseAtomic(); |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseModifier() { |
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parse_(); |
|
if (s1 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 92) { |
|
s2 = peg$c20; |
|
peg$currPos++; |
|
} else { |
|
s2 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c21); } |
|
} |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parse_(); |
|
if (s3 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 123) { |
|
s4 = peg$c22; |
|
peg$currPos++; |
|
} else { |
|
s4 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c23); } |
|
} |
|
if (s4 !== peg$FAILED) { |
|
s5 = peg$parse_(); |
|
if (s5 !== peg$FAILED) { |
|
s6 = peg$parseActions(); |
|
if (s6 !== peg$FAILED) { |
|
s7 = peg$parse_(); |
|
if (s7 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 125) { |
|
s8 = peg$c24; |
|
peg$currPos++; |
|
} else { |
|
s8 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c25); } |
|
} |
|
if (s8 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c26(s6); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
s1 = peg$parse_(); |
|
if (s1 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 91) { |
|
s2 = peg$c27; |
|
peg$currPos++; |
|
} else { |
|
s2 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c28); } |
|
} |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parse_(); |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parseMappings(); |
|
if (s4 !== peg$FAILED) { |
|
s5 = peg$parse_(); |
|
if (s5 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 93) { |
|
s6 = peg$c29; |
|
peg$currPos++; |
|
} else { |
|
s6 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c30); } |
|
} |
|
if (s6 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c31(s4); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseActions() { |
|
var s0, s1, s2, s3; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseAction(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
s3 = peg$parseCommaAction(); |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
s3 = peg$parseCommaAction(); |
|
} |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c32(s1, s2); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
s1 = []; |
|
if (s1 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c33(); |
|
} |
|
s0 = s1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseCommaAction() { |
|
var s0, s1, s2, s3, s4; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parse_(); |
|
if (s1 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 44) { |
|
s2 = peg$c34; |
|
peg$currPos++; |
|
} else { |
|
s2 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c35); } |
|
} |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parse_(); |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parseAction(); |
|
if (s4 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c36(s4); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseMappings() { |
|
var s0, s1, s2, s3; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseMap(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
s3 = peg$parseCommaMapping(); |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
s3 = peg$parseCommaMapping(); |
|
} |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c37(s1, s2); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
s1 = []; |
|
if (s1 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c33(); |
|
} |
|
s0 = s1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseCommaMapping() { |
|
var s0, s1, s2, s3, s4; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parse_(); |
|
if (s1 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 44) { |
|
s2 = peg$c34; |
|
peg$currPos++; |
|
} else { |
|
s2 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c35); } |
|
} |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parse_(); |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parseMap(); |
|
if (s4 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c38(s4); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseMap() { |
|
var s0, s1, s2, s3, s4, s5; |
|
|
|
s0 = peg$currPos; |
|
s1 = peg$parseAction(); |
|
if (s1 !== peg$FAILED) { |
|
s2 = peg$parse_(); |
|
if (s2 !== peg$FAILED) { |
|
if (input.substr(peg$currPos, 2) === peg$c39) { |
|
s3 = peg$c39; |
|
peg$currPos += 2; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c40); } |
|
} |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parse_(); |
|
if (s4 !== peg$FAILED) { |
|
s5 = peg$parseAction(); |
|
if (s5 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c41(s1, s5); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseAtomic() { |
|
var s0, s1, s2, s3, s4, s5; |
|
|
|
s0 = peg$currPos; |
|
if (input.charCodeAt(peg$currPos) === 40) { |
|
s1 = peg$c42; |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c43); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
s2 = peg$parse_(); |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$parseChoice(); |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parse_(); |
|
if (s4 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 41) { |
|
s5 = peg$c44; |
|
peg$currPos++; |
|
} else { |
|
s5 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c45); } |
|
} |
|
if (s5 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c15(s3); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
if (input.charCodeAt(peg$currPos) === 48) { |
|
s1 = peg$c46; |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c47); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c48(); |
|
} |
|
s0 = s1; |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
s1 = peg$parseIdentifier(); |
|
if (s1 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c49(s1); |
|
} |
|
s0 = s1; |
|
} |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseIdentifier() { |
|
var s0, s1, s2, s3; |
|
|
|
peg$silentFails++; |
|
s0 = peg$currPos; |
|
if (peg$c51.test(input.charAt(peg$currPos))) { |
|
s1 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c52); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
if (peg$c53.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c54); } |
|
} |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
if (peg$c53.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c54); } |
|
} |
|
} |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c55(s1, s2); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
peg$silentFails--; |
|
if (s0 === peg$FAILED) { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c50); } |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parseAction() { |
|
var s0, s1, s2, s3; |
|
|
|
peg$silentFails++; |
|
s0 = peg$currPos; |
|
if (peg$c57.test(input.charAt(peg$currPos))) { |
|
s1 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c58); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
if (peg$c53.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c54); } |
|
} |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
if (peg$c53.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c54); } |
|
} |
|
} |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c59(s1, s2); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
peg$silentFails--; |
|
if (s0 === peg$FAILED) { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c56); } |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
function peg$parse_() { |
|
var s0, s1, s2, s3, s4; |
|
|
|
peg$silentFails++; |
|
s0 = peg$currPos; |
|
if (peg$c61.test(input.charAt(peg$currPos))) { |
|
s1 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c62); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
s2 = peg$parse_(); |
|
if (s2 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c63(); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
if (input.charCodeAt(peg$currPos) === 35) { |
|
s1 = peg$c64; |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c65); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
if (peg$c66.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c67); } |
|
} |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
if (peg$c66.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c67); } |
|
} |
|
} |
|
if (s2 !== peg$FAILED) { |
|
if (input.charCodeAt(peg$currPos) === 10) { |
|
s3 = peg$c68; |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c69); } |
|
} |
|
if (s3 !== peg$FAILED) { |
|
s4 = peg$parse_(); |
|
if (s4 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c63(); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
if (input.charCodeAt(peg$currPos) === 35) { |
|
s1 = peg$c64; |
|
peg$currPos++; |
|
} else { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c65); } |
|
} |
|
if (s1 !== peg$FAILED) { |
|
s2 = []; |
|
if (peg$c66.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c67); } |
|
} |
|
while (s3 !== peg$FAILED) { |
|
s2.push(s3); |
|
if (peg$c66.test(input.charAt(peg$currPos))) { |
|
s3 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s3 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c67); } |
|
} |
|
} |
|
if (s2 !== peg$FAILED) { |
|
s3 = peg$currPos; |
|
peg$silentFails++; |
|
if (peg$c71.test(input.charAt(peg$currPos))) { |
|
s4 = input.charAt(peg$currPos); |
|
peg$currPos++; |
|
} else { |
|
s4 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c72); } |
|
} |
|
peg$silentFails--; |
|
if (s4 === peg$FAILED) { |
|
s3 = peg$c70; |
|
} else { |
|
peg$currPos = s3; |
|
s3 = peg$c1; |
|
} |
|
if (s3 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c63(); |
|
s0 = s1; |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
} else { |
|
peg$currPos = s0; |
|
s0 = peg$c1; |
|
} |
|
if (s0 === peg$FAILED) { |
|
s0 = peg$currPos; |
|
s1 = []; |
|
if (s1 !== peg$FAILED) { |
|
peg$reportedPos = s0; |
|
s1 = peg$c63(); |
|
} |
|
s0 = s1; |
|
} |
|
} |
|
} |
|
peg$silentFails--; |
|
if (s0 === peg$FAILED) { |
|
s1 = peg$FAILED; |
|
if (peg$silentFails === 0) { peg$fail(peg$c60); } |
|
} |
|
|
|
return s0; |
|
} |
|
|
|
|
|
var system = new CCS.System(); |
|
|
|
|
|
peg$result = peg$startRuleFunction(); |
|
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) { |
|
return peg$result; |
|
} else { |
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) { |
|
peg$fail({ type: "end", description: "end of input" }); |
|
} |
|
|
|
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); |
|
} |
|
} |
|
|
|
return { |
|
SyntaxError: SyntaxError, |
|
parse: parse |
|
}; |
|
})(); |