-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
310 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
rascal-textmate-core/src/main/rascal/lang/textmate/conversiontests/NestedCategories.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
module lang::textmate::conversiontests::NestedCategories | ||
|
||
import Grammar; | ||
import ParseTree; | ||
import util::Maybe; | ||
|
||
import lang::textmate::Conversion; | ||
import lang::textmate::ConversionConstants; | ||
import lang::textmate::ConversionTests; | ||
import lang::textmate::ConversionUnit; | ||
|
||
start syntax Start | ||
= A01 | A02 | A03 | A04 | A05 | A06 | A07 | A08 | A09 | A10 | A11 | A12; | ||
|
||
lexical A01 = @category="a" B01 [\ ] C01; | ||
lexical B01 = @category="b" D01 [\ ] "bar01"; | ||
lexical C01 = @category="c" D01 [\ ] "baz01"; | ||
lexical D01 = @category="d" "foo01"; | ||
|
||
lexical A02 = @category="a" B02 [\ ] C02; | ||
lexical B02 = @category="b" D02 [\ ] "bar02"; | ||
lexical C02 = @category="c" D02 [\ ] "baz02"; | ||
lexical D02 = "foo02"; | ||
|
||
lexical A03 = @category="a" B03 [\ ] C03; | ||
lexical B03 = @category="b" D03 [\ ] "bar03"; | ||
lexical C03 = D03 [\ ] "baz03"; | ||
lexical D03 = @category="d" "foo03"; | ||
|
||
lexical A04 = @category="a" B04 [\ ] C04; | ||
lexical B04 = @category="b" D04 [\ ] "bar04"; | ||
lexical C04 = D04 [\ ] "baz04"; | ||
lexical D04 = "foo04"; | ||
|
||
lexical A05 = @category="a" B05 [\ ] C05; | ||
lexical B05 = D05 [\ ] "bar05"; | ||
lexical C05 = D05 [\ ] "baz05"; | ||
lexical D05 = @category="d" "foo05"; | ||
|
||
lexical A06 = @category="a" B06 [\ ] C06; | ||
lexical B06 = D06 [\ ] "bar06"; | ||
lexical C06 = D06 [\ ] "baz06"; | ||
lexical D06 = "foo06"; | ||
|
||
lexical A07 = B07 [\ ] C07; | ||
lexical B07 = @category="b" D07 [\ ] "bar07"; | ||
lexical C07 = @category="c" D07 [\ ] "baz07"; | ||
lexical D07 = @category="d" "foo07"; | ||
|
||
lexical A08 = B08 [\ ] C08; | ||
lexical B08 = @category="b" D08 [\ ] "bar08"; | ||
lexical C08 = @category="c" D08 [\ ] "baz08"; | ||
lexical D08 = "foo08"; | ||
|
||
lexical A09 = B09 [\ ] C09; | ||
lexical B09 = @category="b" D09 [\ ] "bar09"; | ||
lexical C09 = D09 [\ ] "baz09"; | ||
lexical D09 = @category="d" "foo09"; // Design decision: D09 should be converted | ||
// to a TextMate rule, because it's | ||
// reachable via C09, which doesn't have a | ||
// category | ||
|
||
lexical A10 = B10 [\ ] C10; | ||
lexical B10 = @category="b" D10 [\ ] "bar10"; | ||
lexical C10 = D10 [\ ] "baz10"; | ||
lexical D10 = "foo10"; | ||
|
||
lexical A11 = B11 [\ ] C11; | ||
lexical B11 = D11 [\ ] "bar11"; | ||
lexical C11 = D11 [\ ] "baz11"; | ||
lexical D11 = @category="d" "foo11"; | ||
|
||
lexical A12 = B12 [\ ] C12; | ||
lexical B12 = D12 [\ ] "bar12"; | ||
lexical C12 = D12 [\ ] "baz12"; | ||
lexical D12 = "foo12"; | ||
|
||
Grammar rsc = preprocess(grammar(#Start)); | ||
|
||
list[ConversionUnit] units = [ | ||
unit(rsc, prod(lex("C07"),[lex("D07"),lit(" "),lit("baz07")],{\tag("category"("c"))}), false, false, <just(lit(" ")),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("C08"),[lex("D08"),lit(" "),lit("baz08")],{\tag("category"("c"))}), false, false, <just(lit(" ")),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("A01"),[lex("B01"),lit(" "),lex("C01")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("A02"),[lex("B02"),lit(" "),lex("C02")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("A03"),[lex("B03"),lit(" "),lex("C03")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("A04"),[lex("B04"),lit(" "),lex("C04")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("A05"),[lex("B05"),lit(" "),lex("C05")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("A06"),[lex("B06"),lit(" "),lex("C06")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("B07"),[lex("D07"),lit(" "),lit("bar07")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("B08"),[lex("D08"),lit(" "),lit("bar08")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("B09"),[lex("D09"),lit(" "),lit("bar09")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("B10"),[lex("D10"),lit(" "),lit("bar10")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("D09"),[lit("foo09")],{\tag("category"("d"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), | ||
unit(rsc, prod(lex("D11"),[lit("foo11")],{\tag("category"("d"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>), | ||
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()>) | ||
]; | ||
|
||
test bool analyzeTest() = doAnalyzeTest(rsc, units, name = "NestedCategories"); | ||
test bool transformTest() = doTransformTest(units, <15, 0, 0>, name = "NestedCategories"); |
211 changes: 211 additions & 0 deletions
211
rascal-textmate-core/src/main/rascal/lang/textmate/conversiontests/NestedCategories.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
# SYNTAX TEST "NestedCategories" | ||
|
||
foo01 bar01 foo01 baz01 | ||
# ^ a | ||
# ^^^^^^ b | ||
# ^^^^^^ c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo01 bar01 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo01 baz01 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo01 | ||
# ^^^^^ -d | ||
|
||
foo02 bar02 foo02 baz02 | ||
# ^ a | ||
# ^^^^^^^^^^^ b | ||
# ^^^^^^^^^^^ c | ||
# ^^^^^ ^^^^^ -d | ||
|
||
foo02 bar02 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo02 baz02 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo02 | ||
# ^^^^^ -d | ||
|
||
foo03 bar03 foo03 baz03 | ||
# ^ ^^^^^^ a | ||
# ^^^^^^ b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo03 bar03 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo03 baz03 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo03 | ||
# ^^^^^ -d | ||
|
||
foo04 bar04 foo04 baz04 | ||
# ^^^^^^^^^^^^ a | ||
# ^^^^^^^^^^^ b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ -d | ||
|
||
foo04 bar04 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo04 baz04 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo04 | ||
# ^^^^^ -d | ||
|
||
foo05 bar05 foo05 baz05 | ||
# ^^^^^^^ ^^^^^^ a | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo05 bar05 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo05 baz05 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo05 | ||
# ^^^^^ -d | ||
|
||
foo06 bar06 foo06 baz06 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ a | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ -d | ||
|
||
foo06 bar06 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo06 baz06 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo06 | ||
# ^^^^^ -d | ||
|
||
foo07 bar07 foo07 baz07 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^ b | ||
# ^^^^^^ c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo07 bar07 | ||
# ^^^^^^ b | ||
# ^^^^^ d | ||
|
||
foo07 baz07 | ||
# ^^^^^^ c | ||
# ^^^^^ d | ||
|
||
foo07 | ||
# ^^^^^ -d | ||
|
||
foo08 bar08 foo08 baz08 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^^^^^^ b | ||
# ^^^^^^^^^^^ c | ||
# ^^^^^ ^^^^^ -d | ||
|
||
foo08 bar08 | ||
# ^^^^^^^^^^^ b | ||
# ^^^^^ -d | ||
|
||
foo08 baz08 | ||
# ^^^^^^^^^^^ c | ||
# ^^^^^ -d | ||
|
||
foo08 | ||
# ^^^^^ -d | ||
|
||
foo09 bar09 foo09 baz09 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^ b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo09 bar09 | ||
# ^^^^^^ b | ||
# ^^^^^ d | ||
|
||
foo09 baz09 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ d | ||
|
||
foo09 | ||
# ^^^^^ d | ||
|
||
foo10 bar10 foo10 baz10 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^^^^^^ b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ -d | ||
|
||
foo10 bar10 | ||
# ^^^^^^^^^^^ b | ||
# ^^^^^ -d | ||
|
||
foo10 baz10 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo10 | ||
# ^^^^^ -d | ||
|
||
foo11 bar11 foo11 baz11 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo11 bar11 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ d | ||
|
||
foo11 baz11 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ d | ||
|
||
foo11 | ||
# ^^^^^ d | ||
|
||
foo12 bar12 foo12 baz12 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ -d | ||
|
||
foo11 bar11 foo11 baz11 | ||
# ^^^^^^^^^^^^^^^^^^^^^^^ -a | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ ^^^^^ d | ||
|
||
foo12 bar12 | ||
# ^^^^^^^^^^^ -b | ||
# ^^^^^ -d | ||
|
||
foo12 baz12 | ||
# ^^^^^^^^^^^ -c | ||
# ^^^^^ -d | ||
|
||
foo12 | ||
# ^^^^^ -d |