|
|
|
@ -16,6 +16,10 @@ describe("PEG.js grammar parser", function() {
|
|
|
|
|
sequenceOfLabeleds = {
|
|
|
|
|
type: "sequence",
|
|
|
|
|
elements: [labeledAbcd, labeledEfgh, labeledIjkl]
|
|
|
|
|
},
|
|
|
|
|
choiceOfLiterals = {
|
|
|
|
|
type: "choice",
|
|
|
|
|
alternatives: [literalAbcd, literalEfgh, literalIjkl]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function oneRuleGrammar(displayName, expression) {
|
|
|
|
@ -150,6 +154,13 @@ describe("PEG.js grammar parser", function() {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Canonical expression is "\"abcd\" / \"efgh\" / \"ijkl\"". */
|
|
|
|
|
it("parses expression", function() {
|
|
|
|
|
expect('start = "abcd" / "efgh" / "ijkl"').toParseAs(
|
|
|
|
|
oneRuleGrammar(null, choiceOfLiterals)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Canonical choice is "\"abcd\" / \"efgh\" / \"ijkl\"". */
|
|
|
|
|
it("parses choice", function() {
|
|
|
|
|
expect('start = "abcd" "efgh" "ijkl"').toParseAs(
|
|
|
|
|