|
|
@ -14,11 +14,12 @@ describe("compiler pass |removeProxyRules|", function() {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var proxiedRefDetails = { type: "rule_ref", name: "proxied" },
|
|
|
|
var defaultOptions = { allowedStartRules: ["start"] },
|
|
|
|
|
|
|
|
proxiedRefDetails = { type: "rule_ref", name: "proxied" },
|
|
|
|
simpleDetails = expressionDetails({ expression: proxiedRefDetails });
|
|
|
|
simpleDetails = expressionDetails({ expression: proxiedRefDetails });
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a rule", function() {
|
|
|
|
it("removes proxy rule from a rule", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = proxy'), {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = proxy'), defaultOptions, {
|
|
|
|
rules: [
|
|
|
|
rules: [
|
|
|
|
{ type: "rule", name: "start", expression: proxiedRefDetails },
|
|
|
|
{ type: "rule", name: "start", expression: proxiedRefDetails },
|
|
|
|
{ type: "rule", name: "proxied" }
|
|
|
|
{ type: "rule", name: "proxied" }
|
|
|
@ -29,6 +30,7 @@ describe("compiler pass |removeProxyRules|", function() {
|
|
|
|
it("removes proxy rule from a named", function() {
|
|
|
|
it("removes proxy rule from a named", function() {
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
proxyGrammar('start "start" = proxy'),
|
|
|
|
proxyGrammar('start "start" = proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
simpleDetails
|
|
|
|
simpleDetails
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -36,55 +38,91 @@ describe("compiler pass |removeProxyRules|", function() {
|
|
|
|
it("removes proxy rule from a choice", function() {
|
|
|
|
it("removes proxy rule from a choice", function() {
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
proxyGrammar('start = proxy / "a" / "b"'),
|
|
|
|
proxyGrammar('start = proxy / "a" / "b"'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
expressionDetails({ alternatives: [proxiedRefDetails, {}, {}] })
|
|
|
|
expressionDetails({ alternatives: [proxiedRefDetails, {}, {}] })
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
proxyGrammar('start = "a" / "b" / proxy'),
|
|
|
|
proxyGrammar('start = "a" / "b" / proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
expressionDetails({ alternatives: [{}, {}, proxiedRefDetails] })
|
|
|
|
expressionDetails({ alternatives: [{}, {}, proxiedRefDetails] })
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from an action", function() {
|
|
|
|
it("removes proxy rule from an action", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = proxy { }'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = proxy { }'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a sequence", function() {
|
|
|
|
it("removes proxy rule from a sequence", function() {
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
proxyGrammar('start = proxy "a" "b"'),
|
|
|
|
proxyGrammar('start = proxy "a" "b"'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
expressionDetails({ elements: [proxiedRefDetails, {}, {}] })
|
|
|
|
expressionDetails({ elements: [proxiedRefDetails, {}, {}] })
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
proxyGrammar('start = "a" "b" proxy'),
|
|
|
|
proxyGrammar('start = "a" "b" proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
expressionDetails({ elements: [{}, {}, proxiedRefDetails] })
|
|
|
|
expressionDetails({ elements: [{}, {}, proxiedRefDetails] })
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a labeled", function() {
|
|
|
|
it("removes proxy rule from a labeled", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = label:proxy'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = label:proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a text", function() {
|
|
|
|
it("removes proxy rule from a text", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = $proxy'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = $proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a simple and", function() {
|
|
|
|
it("removes proxy rule from a simple and", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = &proxy'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = &proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a simple not", function() {
|
|
|
|
it("removes proxy rule from a simple not", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = &proxy'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = &proxy'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from an optional", function() {
|
|
|
|
it("removes proxy rule from an optional", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = proxy?'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = proxy?'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a zero or more", function() {
|
|
|
|
it("removes proxy rule from a zero or more", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = proxy*'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = proxy*'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("removes proxy rule from a one or more", function() {
|
|
|
|
it("removes proxy rule from a one or more", function() {
|
|
|
|
expect(pass).toChangeAST(proxyGrammar('start = proxy+'), simpleDetails);
|
|
|
|
expect(pass).toChangeAST(
|
|
|
|
|
|
|
|
proxyGrammar('start = proxy+'),
|
|
|
|
|
|
|
|
defaultOptions,
|
|
|
|
|
|
|
|
simpleDetails
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("doesn't remove a proxy rule listed in |allowedStartRules|", function() {
|
|
|
|
it("doesn't remove a proxy rule listed in |allowedStartRules|", function() {
|
|
|
|