|
| 1 | +module lang::textmate::conversiontests::NestedCategories |
| 2 | + |
| 3 | +import Grammar; |
| 4 | +import ParseTree; |
| 5 | +import util::Maybe; |
| 6 | + |
| 7 | +import lang::textmate::Conversion; |
| 8 | +import lang::textmate::ConversionConstants; |
| 9 | +import lang::textmate::ConversionTests; |
| 10 | +import lang::textmate::ConversionUnit; |
| 11 | + |
| 12 | +start syntax Start |
| 13 | + = A01 | A02 | A03 | A04 | A05 | A06 | A07 | A08 | A09 | A10 | A11 | A12; |
| 14 | + |
| 15 | +lexical A01 = @category="a" B01 [\ ] C01; |
| 16 | +lexical B01 = @category="b" D01 [\ ] "bar01"; |
| 17 | +lexical C01 = @category="c" D01 [\ ] "baz01"; |
| 18 | +lexical D01 = @category="d" "foo01"; |
| 19 | + |
| 20 | +lexical A02 = @category="a" B02 [\ ] C02; |
| 21 | +lexical B02 = @category="b" D02 [\ ] "bar02"; |
| 22 | +lexical C02 = @category="c" D02 [\ ] "baz02"; |
| 23 | +lexical D02 = "foo02"; |
| 24 | + |
| 25 | +lexical A03 = @category="a" B03 [\ ] C03; |
| 26 | +lexical B03 = @category="b" D03 [\ ] "bar03"; |
| 27 | +lexical C03 = D03 [\ ] "baz03"; |
| 28 | +lexical D03 = @category="d" "foo03"; |
| 29 | + |
| 30 | +lexical A04 = @category="a" B04 [\ ] C04; |
| 31 | +lexical B04 = @category="b" D04 [\ ] "bar04"; |
| 32 | +lexical C04 = D04 [\ ] "baz04"; |
| 33 | +lexical D04 = "foo04"; |
| 34 | + |
| 35 | +lexical A05 = @category="a" B05 [\ ] C05; |
| 36 | +lexical B05 = D05 [\ ] "bar05"; |
| 37 | +lexical C05 = D05 [\ ] "baz05"; |
| 38 | +lexical D05 = @category="d" "foo05"; |
| 39 | + |
| 40 | +lexical A06 = @category="a" B06 [\ ] C06; |
| 41 | +lexical B06 = D06 [\ ] "bar06"; |
| 42 | +lexical C06 = D06 [\ ] "baz06"; |
| 43 | +lexical D06 = "foo06"; |
| 44 | + |
| 45 | +lexical A07 = B07 [\ ] C07; |
| 46 | +lexical B07 = @category="b" D07 [\ ] "bar07"; |
| 47 | +lexical C07 = @category="c" D07 [\ ] "baz07"; |
| 48 | +lexical D07 = @category="d" "foo07"; |
| 49 | + |
| 50 | +lexical A08 = B08 [\ ] C08; |
| 51 | +lexical B08 = @category="b" D08 [\ ] "bar08"; |
| 52 | +lexical C08 = @category="c" D08 [\ ] "baz08"; |
| 53 | +lexical D08 = "foo08"; |
| 54 | + |
| 55 | +lexical A09 = B09 [\ ] C09; |
| 56 | +lexical B09 = @category="b" D09 [\ ] "bar09"; |
| 57 | +lexical C09 = D09 [\ ] "baz09"; |
| 58 | +lexical D09 = @category="d" "foo09"; // Design decision: D09 should be converted |
| 59 | + // to a TextMate rule, because it's |
| 60 | + // reachable via C09, which doesn't have a |
| 61 | + // category |
| 62 | + |
| 63 | +lexical A10 = B10 [\ ] C10; |
| 64 | +lexical B10 = @category="b" D10 [\ ] "bar10"; |
| 65 | +lexical C10 = D10 [\ ] "baz10"; |
| 66 | +lexical D10 = "foo10"; |
| 67 | + |
| 68 | +lexical A11 = B11 [\ ] C11; |
| 69 | +lexical B11 = D11 [\ ] "bar11"; |
| 70 | +lexical C11 = D11 [\ ] "baz11"; |
| 71 | +lexical D11 = @category="d" "foo11"; |
| 72 | + |
| 73 | +lexical A12 = B12 [\ ] C12; |
| 74 | +lexical B12 = D12 [\ ] "bar12"; |
| 75 | +lexical C12 = D12 [\ ] "baz12"; |
| 76 | +lexical D12 = "foo12"; |
| 77 | + |
| 78 | +Grammar rsc = preprocess(grammar(#Start)); |
| 79 | + |
| 80 | +list[ConversionUnit] units = [ |
| 81 | + unit(rsc, prod(lex("C07"),[lex("D07"),lit(" "),lit("baz07")],{\tag("category"("c"))}), false, false, <just(lit(" ")),nothing()>, <nothing(),nothing()>), |
| 82 | + unit(rsc, prod(lex("C08"),[lex("D08"),lit(" "),lit("baz08")],{\tag("category"("c"))}), false, false, <just(lit(" ")),nothing()>, <nothing(),nothing()>), |
| 83 | + unit(rsc, prod(lex("A01"),[lex("B01"),lit(" "),lex("C01")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), |
| 84 | + unit(rsc, prod(lex("A02"),[lex("B02"),lit(" "),lex("C02")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), |
| 85 | + unit(rsc, prod(lex("A03"),[lex("B03"),lit(" "),lex("C03")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), |
| 86 | + unit(rsc, prod(lex("A04"),[lex("B04"),lit(" "),lex("C04")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), |
| 87 | + unit(rsc, prod(lex("A05"),[lex("B05"),lit(" "),lex("C05")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), |
| 88 | + unit(rsc, prod(lex("A06"),[lex("B06"),lit(" "),lex("C06")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), |
| 89 | + unit(rsc, prod(lex("B07"),[lex("D07"),lit(" "),lit("bar07")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), |
| 90 | + unit(rsc, prod(lex("B08"),[lex("D08"),lit(" "),lit("bar08")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), |
| 91 | + unit(rsc, prod(lex("B09"),[lex("D09"),lit(" "),lit("bar09")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), |
| 92 | + unit(rsc, prod(lex("B10"),[lex("D10"),lit(" "),lit("bar10")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), |
| 93 | + unit(rsc, prod(lex("D09"),[lit("foo09")],{\tag("category"("d"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), |
| 94 | + unit(rsc, prod(lex("D11"),[lit("foo11")],{\tag("category"("d"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), |
| 95 | + unit(rsc, prod(lex(KEYWORDS_PRODUCTION_NAME),[alt({lit("foo07"),lit("foo06"),lit("foo09"),lit("foo08"),lit("foo03"),lit("foo02"),lit("foo05"),lit("foo04"),lit("foo10"),lit("baz09"),lit("foo11"),lit("baz06"),lit("baz05"),lit("baz08"),lit("baz07"),lit("baz02"),lit("baz04"),lit("baz03"),lit("bar06"),lit("bar05"),lit("bar02"),lit("bar04"),lit("bar03"),lit("bar11"),lit("bar10"),lit("foo12"),lit("foo01"),lit("baz12"),lit("baz01"),lit("bar09"),lit("baz11"),lit("bar08"),lit("baz10"),lit("bar07"),lit("bar12"),lit("bar01")})],{\tag("category"("keyword.control"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>) |
| 96 | +]; |
| 97 | + |
| 98 | +test bool analyzeTest() = doAnalyzeTest(rsc, units, name = "NestedCategories"); |
| 99 | +test bool transformTest() = doTransformTest(units, <15, 0, 0>, name = "NestedCategories"); |
0 commit comments