PEG.js grammar: Formatting & comments

redux
David Majda 10 years ago
parent 6f2510e49e
commit 0459ab6b37

@ -42,12 +42,7 @@ module.exports = (function() {
rules: extractList(rules, 0) rules: extractList(rules, 0)
}; };
}, },
peg$c4 = function(code) { peg$c4 = function(code) { return { type: "initializer", code: code }; },
return {
type: "initializer",
code: code
};
},
peg$c5 = "=", peg$c5 = "=",
peg$c6 = { type: "literal", value: "=", description: "\"=\"" }, peg$c6 = { type: "literal", value: "=", description: "\"=\"" },
peg$c7 = function(name, displayName, expression) { peg$c7 = function(name, displayName, expression) {
@ -83,11 +78,7 @@ module.exports = (function() {
peg$c13 = ":", peg$c13 = ":",
peg$c14 = { type: "literal", value: ":", description: "\":\"" }, peg$c14 = { type: "literal", value: ":", description: "\":\"" },
peg$c15 = function(label, expression) { peg$c15 = function(label, expression) {
return { return { type: "labeled", label: label, expression: expression };
type: "labeled",
label: label,
expression: expression
};
}, },
peg$c16 = function(operator, expression) { peg$c16 = function(operator, expression) {
return { type: OPS_TO_PREFIXED_TYPES[operator], expression: expression }; return { type: OPS_TO_PREFIXED_TYPES[operator], expression: expression };

@ -48,6 +48,8 @@
} }
} }
/* ---- Syntactic Grammar ----- */
Grammar Grammar
= __ initializer:(Initializer __)? rules:(Rule __)+ { = __ initializer:(Initializer __)? rules:(Rule __)+ {
return { return {
@ -58,18 +60,14 @@ Grammar
} }
Initializer Initializer
= code:CodeBlock EOS { = code:CodeBlock EOS { return { type: "initializer", code: code }; }
return {
type: "initializer",
code: code
};
}
Rule Rule
= name:IdentifierName __ = name:IdentifierName __
displayName:(StringLiteral __)? displayName:(StringLiteral __)?
"=" __ "=" __
expression:Expression EOS { expression:Expression EOS
{
return { return {
type: "rule", type: "rule",
name: name, name: name,
@ -109,11 +107,7 @@ SequenceExpression
LabeledExpression LabeledExpression
= label:Identifier __ ":" __ expression:PrefixedExpression { = label:Identifier __ ":" __ expression:PrefixedExpression {
return { return { type: "labeled", label: label, expression: expression };
type: "labeled",
label: label,
expression: expression
};
} }
/ PrefixedExpression / PrefixedExpression
@ -161,7 +155,7 @@ SemanticPredicateOperator
= "&" = "&"
/ "!" / "!"
/* "Lexical" elements */ /* ---- Lexical Grammar ----- */
SourceCharacter SourceCharacter
= . = .

Loading…
Cancel
Save