PEG.js grammar: Formatting & comments

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

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

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

Loading…
Cancel
Save