|
|
|
@ -35,10 +35,13 @@ module.exports = (function() {
|
|
|
|
|
return {
|
|
|
|
|
type: "grammar",
|
|
|
|
|
initializer: extractOptional(initializer, 0),
|
|
|
|
|
rules: extractList(rules, 0)
|
|
|
|
|
rules: extractList(rules, 0),
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c1 = function(code) { return { type: "initializer", code: code }; },
|
|
|
|
|
peg$c1 = function(code) {
|
|
|
|
|
return { type: "initializer", code: code, location: location() };
|
|
|
|
|
},
|
|
|
|
|
peg$c2 = "=",
|
|
|
|
|
peg$c3 = { type: "literal", value: "=", description: "\"=\"" },
|
|
|
|
|
peg$c4 = function(name, displayName, expression) {
|
|
|
|
@ -49,35 +52,59 @@ module.exports = (function() {
|
|
|
|
|
? {
|
|
|
|
|
type: "named",
|
|
|
|
|
name: displayName[0],
|
|
|
|
|
expression: expression
|
|
|
|
|
expression: expression,
|
|
|
|
|
location: location()
|
|
|
|
|
}
|
|
|
|
|
: expression
|
|
|
|
|
: expression,
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c5 = "/",
|
|
|
|
|
peg$c6 = { type: "literal", value: "/", description: "\"/\"" },
|
|
|
|
|
peg$c7 = function(first, rest) {
|
|
|
|
|
return rest.length > 0
|
|
|
|
|
? { type: "choice", alternatives: buildList(first, rest, 3) }
|
|
|
|
|
? {
|
|
|
|
|
type: "choice",
|
|
|
|
|
alternatives: buildList(first, rest, 3),
|
|
|
|
|
location: location()
|
|
|
|
|
}
|
|
|
|
|
: first;
|
|
|
|
|
},
|
|
|
|
|
peg$c8 = function(expression, code) {
|
|
|
|
|
return code !== null
|
|
|
|
|
? { type: "action", expression: expression, code: code[1] }
|
|
|
|
|
? {
|
|
|
|
|
type: "action",
|
|
|
|
|
expression: expression,
|
|
|
|
|
code: code[1],
|
|
|
|
|
location: location()
|
|
|
|
|
}
|
|
|
|
|
: expression;
|
|
|
|
|
},
|
|
|
|
|
peg$c9 = function(first, rest) {
|
|
|
|
|
return rest.length > 0
|
|
|
|
|
? { type: "sequence", elements: buildList(first, rest, 1) }
|
|
|
|
|
? {
|
|
|
|
|
type: "sequence",
|
|
|
|
|
elements: buildList(first, rest, 1),
|
|
|
|
|
location: location()
|
|
|
|
|
}
|
|
|
|
|
: first;
|
|
|
|
|
},
|
|
|
|
|
peg$c10 = ":",
|
|
|
|
|
peg$c11 = { type: "literal", value: ":", description: "\":\"" },
|
|
|
|
|
peg$c12 = function(label, expression) {
|
|
|
|
|
return { type: "labeled", label: label, expression: expression };
|
|
|
|
|
return {
|
|
|
|
|
type: "labeled",
|
|
|
|
|
label: label,
|
|
|
|
|
expression: expression,
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c13 = function(operator, expression) {
|
|
|
|
|
return { type: OPS_TO_PREFIXED_TYPES[operator], expression: expression };
|
|
|
|
|
return {
|
|
|
|
|
type: OPS_TO_PREFIXED_TYPES[operator],
|
|
|
|
|
expression: expression,
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c14 = "$",
|
|
|
|
|
peg$c15 = { type: "literal", value: "$", description: "\"$\"" },
|
|
|
|
@ -86,7 +113,11 @@ module.exports = (function() {
|
|
|
|
|
peg$c18 = "!",
|
|
|
|
|
peg$c19 = { type: "literal", value: "!", description: "\"!\"" },
|
|
|
|
|
peg$c20 = function(expression, operator) {
|
|
|
|
|
return { type: OPS_TO_SUFFIXED_TYPES[operator], expression: expression };
|
|
|
|
|
return {
|
|
|
|
|
type: OPS_TO_SUFFIXED_TYPES[operator],
|
|
|
|
|
expression: expression,
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c21 = "?",
|
|
|
|
|
peg$c22 = { type: "literal", value: "?", description: "\"?\"" },
|
|
|
|
@ -100,10 +131,14 @@ module.exports = (function() {
|
|
|
|
|
peg$c30 = { type: "literal", value: ")", description: "\")\"" },
|
|
|
|
|
peg$c31 = function(expression) { return expression; },
|
|
|
|
|
peg$c32 = function(name) {
|
|
|
|
|
return { type: "rule_ref", name: name };
|
|
|
|
|
return { type: "rule_ref", name: name, location: location() };
|
|
|
|
|
},
|
|
|
|
|
peg$c33 = function(operator, code) {
|
|
|
|
|
return { type: OPS_TO_SEMANTIC_PREDICATE_TYPES[operator], code: code };
|
|
|
|
|
return {
|
|
|
|
|
type: OPS_TO_SEMANTIC_PREDICATE_TYPES[operator],
|
|
|
|
|
code: code,
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c34 = { type: "any", description: "any character" },
|
|
|
|
|
peg$c35 = { type: "other", description: "whitespace" },
|
|
|
|
@ -155,7 +190,12 @@ module.exports = (function() {
|
|
|
|
|
peg$c81 = "i",
|
|
|
|
|
peg$c82 = { type: "literal", value: "i", description: "\"i\"" },
|
|
|
|
|
peg$c83 = function(value, ignoreCase) {
|
|
|
|
|
return { type: "literal", value: value, ignoreCase: ignoreCase !== null };
|
|
|
|
|
return {
|
|
|
|
|
type: "literal",
|
|
|
|
|
value: value,
|
|
|
|
|
ignoreCase: ignoreCase !== null,
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c84 = { type: "other", description: "string" },
|
|
|
|
|
peg$c85 = "\"",
|
|
|
|
@ -177,7 +217,8 @@ module.exports = (function() {
|
|
|
|
|
parts: filterEmptyStrings(parts),
|
|
|
|
|
inverted: inverted !== null,
|
|
|
|
|
ignoreCase: ignoreCase !== null,
|
|
|
|
|
rawText: text()
|
|
|
|
|
rawText: text(),
|
|
|
|
|
location: location()
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
peg$c99 = "-",
|
|
|
|
@ -226,7 +267,7 @@ module.exports = (function() {
|
|
|
|
|
peg$c132 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
|
|
|
|
|
peg$c133 = ".",
|
|
|
|
|
peg$c134 = { type: "literal", value: ".", description: "\".\"" },
|
|
|
|
|
peg$c135 = function() { return { type: "any" }; },
|
|
|
|
|
peg$c135 = function() { return { type: "any", location: location() }; },
|
|
|
|
|
peg$c136 = { type: "other", description: "code block" },
|
|
|
|
|
peg$c137 = "{",
|
|
|
|
|
peg$c138 = { type: "literal", value: "{", description: "\"{\"" },
|
|
|
|
|