|
|
|
@ -24,8 +24,8 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a named", function() {
|
|
|
|
|
expect(pass).toChangeAST('start "start" = &"a"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 2,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 1 }
|
|
|
|
|
}
|
|
|
|
@ -34,23 +34,23 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a choice", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" / &"b" / &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1],
|
|
|
|
|
expression: choiceDetails
|
|
|
|
|
resultCount: 2,
|
|
|
|
|
expression: choiceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" / &"b"* / &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: choiceDetails
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: choiceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" / &(&"b") / &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: choiceDetails
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: choiceDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for an action", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" { code }', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
posIndex: 1,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 2 }
|
|
|
|
@ -60,47 +60,47 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a sequence", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = ', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1],
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 1 }
|
|
|
|
|
resultCount: 2,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 1 }
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" &"b" &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 6,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" &"b" &"c"*', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5, 6],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 7,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" &"b"* &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 6,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" &("b"*)* &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5, 6],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 7,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a"* &"b" &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 6,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &("a"*)* &"b" &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 6,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &(("a"*)*)* &"b" &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5, 6],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 7,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
expect(pass).toChangeAST('start = &"a" &(&"b") &"c"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2, 3, 4, 5],
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
resultCount: 6,
|
|
|
|
|
expression: sequenceDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a labeled", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = label:&"a"', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 2,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 1 }
|
|
|
|
|
}
|
|
|
|
@ -109,8 +109,8 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a simple and", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = &(&"a")', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
posIndex: 1,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 2 }
|
|
|
|
@ -120,8 +120,8 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a simple not", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = !(&"a")', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
posIndex: 1,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 2 }
|
|
|
|
@ -131,22 +131,22 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a semantic and", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = &{ code }', ruleDetails({
|
|
|
|
|
resultIndices: [0],
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
resultCount: 1,
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a semantic not", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = !{ code }', ruleDetails({
|
|
|
|
|
resultIndices: [0],
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
resultCount: 1,
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for an optional", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = (&"a")?', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 2,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
expression: { resultIndex: 0, posIndex: 1 }
|
|
|
|
|
}
|
|
|
|
@ -155,8 +155,8 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a zero or more", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = (&"a")*', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
expression: { resultIndex: 1, posIndex: 2 }
|
|
|
|
|
}
|
|
|
|
@ -165,8 +165,8 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a one or more", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = (&"a")+', ruleDetails({
|
|
|
|
|
resultIndices: [0, 1, 2],
|
|
|
|
|
expression: {
|
|
|
|
|
resultCount: 3,
|
|
|
|
|
expression: {
|
|
|
|
|
resultIndex: 0,
|
|
|
|
|
expression: { resultIndex: 1, posIndex: 2 }
|
|
|
|
|
}
|
|
|
|
@ -175,29 +175,29 @@ describe("compiler pass |computeVarIndices|", function() {
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a rule reference", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = a', ruleDetails({
|
|
|
|
|
resultIndices: [0],
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
resultCount: 1,
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a literal", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = "a"', ruleDetails({
|
|
|
|
|
resultIndices: [0],
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
resultCount: 1,
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for a class", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = [a-z]', ruleDetails({
|
|
|
|
|
resultIndices: [0],
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
resultCount: 1,
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("computes variable indices for an any", function() {
|
|
|
|
|
expect(pass).toChangeAST('start = .', ruleDetails({
|
|
|
|
|
resultIndices: [0],
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
resultCount: 1,
|
|
|
|
|
expression: leafDetails
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|