diff --git a/org.metaborg.meta.lang.template/trans/analysis/name-constraints.str b/org.metaborg.meta.lang.template/trans/analysis/name-constraints.str index 6aae9ae81..35275477f 100644 --- a/org.metaborg.meta.lang.template/trans/analysis/name-constraints.str +++ b/org.metaborg.meta.lang.template/trans/analysis/name-constraints.str @@ -428,3 +428,17 @@ rules where s'; ( ty*, ty'*) + +rules + + nabl-constraint(|ctx): + section@VariablesProductive(_) -> + where + msg := "The SDF2 variables section is no longer support, please write your own A.meta-var and A.meta-listvar definitions in context-free syntax"; + section + + nabl-constraint(|ctx): + section@LexVariablesProductive(_) -> + where + msg := "The SDF2 variables section is no longer support, please write your own A.meta-var and A.meta-listvar definitions in context-free syntax"; + section diff --git a/org.metaborg.sdf3.meta.integrationtest/editor/Main.esv b/org.metaborg.sdf3.meta.integrationtest/editor/Main.esv index 721a83a26..8c54faef4 100644 --- a/org.metaborg.sdf3.meta.integrationtest/editor/Main.esv +++ b/org.metaborg.sdf3.meta.integrationtest/editor/Main.esv @@ -13,6 +13,11 @@ menus menu: "Transform" - action: "Swap (abstract syntax)" = swap-editor-abstract-syntax (source) - action: "Swap (concrete syntax)" = swap-editor-concrete-syntax (source) - action: "Swap (concrete syntax simple)" = swap-editor-concrete-syntax-simple (source) + action: "Swap exps (abstract syntax)" = editor-action-swap-exps-abstract-syntax (source) + action: "Swap exps (concrete syntax)" = editor-action-swap-exps-concrete-syntax (source) + action: "Swap exps (concrete syntax simple)" = editor-action-swap-exps-concrete-syntax-simple (source) + action: "Swap exps (concrete syntax var)" = editor-action-swap-exps-concrete-syntax-var (source) + action: "Reverse stmts (concrete syntax varlist)" = editor-action-reverse-stmts-concrete-syntax-varlist (source) + action: "Surround stmts (concrete syntax varlist)" = editor-action-surround-stmts-concrete-syntax-varlist (source) + action: "Surround stmts 2 (concrete syntax varlist)" = editor-action-surround-stmts-concrete-syntax-varlist2 (source) + action: "Surround stmts (concrete syntax list fromterm)" = editor-action-surround-stmts-concrete-syntax-list-fromterm (source) \ No newline at end of file diff --git a/org.metaborg.sdf3.meta.integrationtest/syntax/foo.sdf3 b/org.metaborg.sdf3.meta.integrationtest/syntax/foo.sdf3 index c556b6f64..bfe91f3f6 100644 --- a/org.metaborg.sdf3.meta.integrationtest/syntax/foo.sdf3 +++ b/org.metaborg.sdf3.meta.integrationtest/syntax/foo.sdf3 @@ -9,12 +9,45 @@ imports context-free start-symbols - StrategoLang-Module + Module + +context-free sorts + + Module StmtListMeta context-free syntax + Module = StrategoLang-Module + StrategoLang-PreTerm.ToTerm = <|[ ]|> StrategoLang-PreTerm.ToTerm = ]|> + StrategoLang-PreTerm.ToTerm = <|[ ]|> + StrategoLang-PreTerm.ToTerm = ]|> + Exp.FromTerm = [~[StrategoLang-Term]] Exp.FromTerm = [~exp:[StrategoLang-Term]] + + StmtListMeta.FromTerm = [~*[StrategoLang-Term]] + + Stmt+ = StmtListMeta + Stmt+.Conc = Stmt+ StmtListMeta + +context-free syntax // meta variables + + Exp.meta-var = ExpVar + + StmtListMeta.meta-listvar = StmtListVar + +lexical sorts + + ExpVar StmtListVar + +lexical syntax + + ExpVar = 'exp' [0-9]* + StmtListVar = 'stmt' [0-9]* '*' + +lexical restrictions + + ExpVar -/- [0-9] \ No newline at end of file diff --git a/org.metaborg.sdf3.meta.integrationtest/syntax/thesyntax.sdf3 b/org.metaborg.sdf3.meta.integrationtest/syntax/thesyntax.sdf3 index 3c2534959..2e57cf9f7 100644 --- a/org.metaborg.sdf3.meta.integrationtest/syntax/thesyntax.sdf3 +++ b/org.metaborg.sdf3.meta.integrationtest/syntax/thesyntax.sdf3 @@ -15,7 +15,7 @@ context-free sorts context-free syntax - Start.Program = Stmt + Start.Program = Stmt+ Stmt.Stmt = [[Exp];] Exp.Add = [[Exp] + [Exp]] Exp.Var = VAR \ No newline at end of file diff --git a/org.metaborg.sdf3.meta.integrationtest/test/swap.spt b/org.metaborg.sdf3.meta.integrationtest/test/swap.spt index fb672e692..e475e9278 100644 --- a/org.metaborg.sdf3.meta.integrationtest/test/swap.spt +++ b/org.metaborg.sdf3.meta.integrationtest/test/swap.spt @@ -4,8 +4,18 @@ language sdf3-meta-integrationtest start symbol Start -test swap [[x + y;]] transform "Transform -> Swap (abstract syntax)" to [[y + x;]] +test swap [[x + y;]] transform "Transform -> Swap exps (abstract syntax)" to [[y + x;]] -test swap [[x + y;]] transform "Transform -> Swap (concrete syntax)" to [[y + x;]] +test swap [[x + y;]] transform "Transform -> Swap exps (concrete syntax)" to [[y + x;]] -test swap [[x + y;]] transform "Transform -> Swap (concrete syntax simple)" to [[y + x;]] \ No newline at end of file +test swap [[x + y;]] transform "Transform -> Swap exps (concrete syntax simple)" to [[y + x;]] + +test swap [[x + y;]] transform "Transform -> Swap exps (concrete syntax var)" to [[y + x;]] + +test swap [[x; y;]] transform "Transform -> Reverse stmts (concrete syntax varlist)" to [[y; x;]] + +test swap [[x; y;]] transform "Transform -> Surround stmts (concrete syntax varlist)" to [[a; x; y; b;]] + +test swap [[x; y;]] transform "Transform -> Surround stmts 2 (concrete syntax varlist)" to [[y; x; a; x; y; x; y; b; y; x;]] + +test swap [[x; y;]] transform "Transform -> Surround stmts (concrete syntax list fromterm)" to [[a; x; y; b;]] \ No newline at end of file diff --git a/org.metaborg.sdf3.meta.integrationtest/trans/swap.str b/org.metaborg.sdf3.meta.integrationtest/trans/swap.str index 0fea0b7f5..34b00b7da 100644 --- a/org.metaborg.sdf3.meta.integrationtest/trans/swap.str +++ b/org.metaborg.sdf3.meta.integrationtest/trans/swap.str @@ -7,20 +7,49 @@ imports rules - swap-editor-abstract-syntax = swap-editor(swap-exp-abstract-syntax|) - swap-editor-concrete-syntax = swap-editor(swap-exp-concrete-syntax|) - swap-editor-concrete-syntax-simple = swap-editor(swap-exp-concrete-syntax-simple|) - - swap-editor(swap-exp|): - (_, _, ast, path, _) -> (path, ast) - - swap-exp-abstract-syntax: + editor-action-swap-exps-abstract-syntax = editor-action(swap-exps-abstract-syntax) + editor-action-swap-exps-concrete-syntax = editor-action(swap-exps-concrete-syntax) + editor-action-swap-exps-concrete-syntax-simple = editor-action(swap-exps-concrete-syntax-simple) + editor-action-swap-exps-concrete-syntax-var = editor-action(swap-exps-concrete-syntax-var) + editor-action-reverse-stmts-concrete-syntax-varlist = editor-action(reverse-stmts-concrete-syntax-varlist) + editor-action-surround-stmts-concrete-syntax-varlist = editor-action(surround-stmts-concrete-syntax-varlist) + editor-action-surround-stmts-concrete-syntax-varlist2 = editor-action(surround-stmts-concrete-syntax-varlist2) + editor-action-surround-stmts-concrete-syntax-list-fromterm = editor-action(surround-stmts-concrete-syntax-list-fromterm) + + editor-action(s): + (_, _, ast, path, _) -> (path, ast) + + swap-exps-abstract-syntax: Add(e1, e2) -> Add(e2, e1) - swap-exp-concrete-syntax: + swap-exps-concrete-syntax: stmt |[ ~exp:e1 + ~exp:e2 ; ]| -> stmt |[ ~exp:e2 + ~exp:e1 ; ]| - swap-exp-concrete-syntax-simple: + swap-exps-concrete-syntax-simple: |[ ~e1 + ~e2 ; ]| -> - |[ ~e2 + ~e1 ; ]| \ No newline at end of file + |[ ~e2 + ~e1 ; ]| + + swap-exps-concrete-syntax-var: + |[ exp + exp2 ; ]| -> + |[ exp2 + exp ; ]| + + reverse-stmts-concrete-syntax-varlist: + |[ stmt1* ]| -> + |[ stmt2* ]| + where stmt2* := stmt1* + + surround-stmts-concrete-syntax-varlist: + |[ stmt1* ]| -> + program |[ a; stmt1* b; ]| + where stmt2* := stmt1* + + surround-stmts-concrete-syntax-varlist2: + |[ stmt1* ]| -> + program |[ stmt2* a; stmt1* stmt1* b; stmt2* ]| + where stmt2* := stmt1* + + surround-stmts-concrete-syntax-list-fromterm: + |[ ~*stmt1* ]| -> + program |[ a; ~*stmt1* b; ]| + where stmt2* := stmt1* diff --git a/sdf3.stratego2.integrationtest/.gitignore b/sdf3.stratego2.integrationtest/.gitignore new file mode 100644 index 000000000..a0dffdd88 --- /dev/null +++ b/sdf3.stratego2.integrationtest/.gitignore @@ -0,0 +1,14 @@ +/.cache +/bin +/src-gen +/target + +/.classpath +/.project +/.settings +/.factorypath + +/.polyglot.metaborg.yaml + +/trans/foo.tbl +/trans/table-foo.bin \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/.mvn/extensions.xml b/sdf3.stratego2.integrationtest/.mvn/extensions.xml new file mode 100644 index 000000000..878ae8be4 --- /dev/null +++ b/sdf3.stratego2.integrationtest/.mvn/extensions.xml @@ -0,0 +1,8 @@ + + + + org.metaborg + spoofax-maven-plugin-pomless + 2.6.0-SNAPSHOT + + diff --git a/sdf3.stratego2.integrationtest/editor/Main.esv b/sdf3.stratego2.integrationtest/editor/Main.esv new file mode 100644 index 000000000..8c54faef4 --- /dev/null +++ b/sdf3.stratego2.integrationtest/editor/Main.esv @@ -0,0 +1,23 @@ +module Main + +language + + extensions : s3mit + + provider : target/metaborg/stratego.jar + + table : target/metaborg/sdf.tbl + start symbols : Start + +menus + + menu: "Transform" + + action: "Swap exps (abstract syntax)" = editor-action-swap-exps-abstract-syntax (source) + action: "Swap exps (concrete syntax)" = editor-action-swap-exps-concrete-syntax (source) + action: "Swap exps (concrete syntax simple)" = editor-action-swap-exps-concrete-syntax-simple (source) + action: "Swap exps (concrete syntax var)" = editor-action-swap-exps-concrete-syntax-var (source) + action: "Reverse stmts (concrete syntax varlist)" = editor-action-reverse-stmts-concrete-syntax-varlist (source) + action: "Surround stmts (concrete syntax varlist)" = editor-action-surround-stmts-concrete-syntax-varlist (source) + action: "Surround stmts 2 (concrete syntax varlist)" = editor-action-surround-stmts-concrete-syntax-varlist2 (source) + action: "Surround stmts (concrete syntax list fromterm)" = editor-action-surround-stmts-concrete-syntax-list-fromterm (source) \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/metaborg.yaml b/sdf3.stratego2.integrationtest/metaborg.yaml new file mode 100644 index 000000000..e8da3f9f2 --- /dev/null +++ b/sdf3.stratego2.integrationtest/metaborg.yaml @@ -0,0 +1,45 @@ +--- +id: org.metaborg:sdf3.stratego2.integrationtest:2.6.0-SNAPSHOT +name: sdf3-stratego2-integrationtest +dependencies: + compile: + - org.metaborg:org.metaborg.meta.lang.esv:${metaborgVersion} + - org.metaborg:org.metaborg.meta.lang.template:${metaborgVersion} + - org.metaborg:org.metaborg.meta.lang.spt:${metaborgVersion} + # Workaround to get Stratego 2 dialect to register before trans/swap.str2 is parsed + - org.metaborg:org.metaborg.meta.lang.stratego:${metaborgVersion} + - org.metaborg:stratego.lang:${metaborgVersion} + source: + - org.metaborg:meta.lib.spoofax:${metaborgVersion} + - org.metaborg:stratego.lang:${metaborgVersion} + - org.metaborg:strategolib:${metaborgVersion} + - org.metaborg:gpp:${metaborgVersion} + java: + - org.metaborg:strategolib:${metaborgVersion} + - org.metaborg:gpp:${metaborgVersion} +pardonedLanguages: +- EditorService +- Stratego-Sugar +- SDF +language: + sdf: + pretty-print: sdf3-stratego2-integrationtest + version: sdf3 + sdf2table: java + sdf-meta: + - foo + placeholder: + prefix: "$" + stratego: + format: jar + args: + - -la + - stratego-sglr + - -la + - stratego-xtc + - -la + - stratego-aterm + - -la + - stratego-sdf + - -la + - strc diff --git a/sdf3.stratego2.integrationtest/pom.xml b/sdf3.stratego2.integrationtest/pom.xml new file mode 100644 index 000000000..079fe606e --- /dev/null +++ b/sdf3.stratego2.integrationtest/pom.xml @@ -0,0 +1,88 @@ + + + 4.0.0 + sdf3.stratego2.integrationtest + spoofax-language + + + org.metaborg + parent.language + 2.6.0-SNAPSHOT + ../../releng/parent/java + + + + + + org.metaborg + org.metaborg.meta.lang.esv + ${metaborg-version} + spoofax-language + + + org.metaborg + org.metaborg.meta.lang.template + ${metaborg-version} + spoofax-language + + + org.metaborg + org.metaborg.meta.lang.spt + ${metaborg-version} + spoofax-language + test + + + org.metaborg + stratego.lang + ${metaborg-version} + spoofax-language + + + + + org.metaborg + meta.lib.spoofax + ${metaborg-version} + spoofax-language + provided + + + org.metaborg + strategolib + ${metaborg-version} + spoofax-language + + + org.metaborg + gpp + ${metaborg-version} + spoofax-language + + + + + + + org.metaborg + spoofax-maven-plugin + ${metaborg-version} + + + test + + test + + + + + org.metaborg:sdf3.stratego2.integrationtest:${metaborg-version} + + + + + \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/syntax/foo.sdf3 b/sdf3.stratego2.integrationtest/syntax/foo.sdf3 new file mode 100644 index 000000000..438502791 --- /dev/null +++ b/sdf3.stratego2.integrationtest/syntax/foo.sdf3 @@ -0,0 +1,49 @@ +module foo + +imports + + StrategoLang/import-namespaced + StrategoLang/core/modules-namespaced + StrategoLang/sugar/terms-namespaced + thesyntax + +context-free start-symbols + + Module + +context-free sorts + + Module + +context-free syntax + + Module = StrategoLang-Module + + StrategoLang-PreTerm.ToTerm = ]|> + StrategoLang-PreTerm.ToTerm = ]|> + + Exp.FromTerm = [~[StrategoLang-Term]] + Exp.FromTerm = [~exp:[StrategoLang-Term]] + + Stmt.FromTerm = [~[StrategoLang-Term]] + +context-free syntax // meta variables + + Exp.meta-var = ExpVar + + Stmt.meta-listvar = StmtListVar + +lexical sorts + + ExpVar StmtListVar + +lexical syntax + + ExpVar = 'exp' [0-9]* + StmtListVar = 'stmt' [0-9]* '*' + VAR = ExpVar {reject} + +lexical restrictions + + ExpVar -/- [0-9] + \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/syntax/sdf3-stratego2-integrationtest.sdf3 b/sdf3.stratego2.integrationtest/syntax/sdf3-stratego2-integrationtest.sdf3 new file mode 100644 index 000000000..aa79bd95e --- /dev/null +++ b/sdf3.stratego2.integrationtest/syntax/sdf3-stratego2-integrationtest.sdf3 @@ -0,0 +1,8 @@ +module sdf3-stratego2-integrationtest + +imports + thesyntax + +context-free start-symbols + + Start diff --git a/sdf3.stratego2.integrationtest/syntax/thesyntax.sdf3 b/sdf3.stratego2.integrationtest/syntax/thesyntax.sdf3 new file mode 100644 index 000000000..2e57cf9f7 --- /dev/null +++ b/sdf3.stratego2.integrationtest/syntax/thesyntax.sdf3 @@ -0,0 +1,21 @@ +module thesyntax + +lexical sorts + VAR + +lexical syntax + LAYOUT = [\t\ \n\r] + VAR = [a-z]+ + +context-free restrictions + LAYOUT? -/- [\ \t\n\r] + +context-free sorts + Start Stmt Exp + +context-free syntax + + Start.Program = Stmt+ + Stmt.Stmt = [[Exp];] + Exp.Add = [[Exp] + [Exp]] + Exp.Var = VAR \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/test/swap.spt b/sdf3.stratego2.integrationtest/test/swap.spt new file mode 100644 index 000000000..a2ca09944 --- /dev/null +++ b/sdf3.stratego2.integrationtest/test/swap.spt @@ -0,0 +1,21 @@ +module swap + +language sdf3-stratego2-integrationtest + +start symbol Start + +test swap [[x + y;]] transform "Transform -> Swap exps (abstract syntax)" to [[y + x;]] + +test swap [[x + y;]] transform "Transform -> Swap exps (concrete syntax)" to [[y + x;]] + +test swap [[x + y;]] transform "Transform -> Swap exps (concrete syntax simple)" to [[y + x;]] + +test swap [[x + y;]] transform "Transform -> Swap exps (concrete syntax var)" to [[y + x;]] + +test swap [[x; y;]] transform "Transform -> Reverse stmts (concrete syntax varlist)" to [[y; x;]] + +test swap [[x; y;]] transform "Transform -> Surround stmts (concrete syntax varlist)" to [[a; x; y; b;]] + +test swap [[x; y;]] transform "Transform -> Surround stmts 2 (concrete syntax varlist)" to [[y; x; a; x; y; x; y; b; y; x;]] + +test swap [[x; y;]] transform "Transform -> Surround stmts (concrete syntax list fromterm)" to [[a; x; y; b;]] \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/trans/pp.str2 b/sdf3.stratego2.integrationtest/trans/pp.str2 new file mode 100644 index 000000000..64ced1c7f --- /dev/null +++ b/sdf3.stratego2.integrationtest/trans/pp.str2 @@ -0,0 +1,52 @@ +module pp + +imports + strategolib + +imports + + gpp + libspoofax/sdf/pp + libspoofax/editor/refactoring/- + pp/sdf3-stratego2-integrationtest-parenthesize + pp/sdf3-stratego2-integrationtest-pp + +rules + editor-format :: ? * ? * ? * string * string -> string * ? + editor-format: + (node, _, ast, path, project-path) -> (filename, result) + with + ext := path + ; filename := path + ; result := node + +rules + + pp-sdf3-stratego2-integrationtest-string = + parenthesize-sdf3-stratego2-integrationtest + ; prettyprint-sdf3-stratego2-integrationtest-start-symbols + ; !V([], ) + ; box2text-string(|120) + + pp-partial-sdf3-stratego2-integrationtest-string = + parenthesize-sdf3-stratego2-integrationtest + ; prettyprint-sdf3-stratego2-integrationtest + ; !V([], ) + ; box2text-string(|120) + + pp-partial-sdf3-stratego2-integrationtest-string(|sort) = + parenthesize-sdf3-stratego2-integrationtest + ; prettyprint-sdf3-stratego2-integrationtest(|sort) + ; !V([], ) + ; box2text-string(|120) + + pp-debug : + ast -> result + with + result := ast + <+ ast + ; result := "" + +rules + + construct-textual-change = construct-textual-change(pp-partial-sdf3-stratego2-integrationtest-string, parenthesize, override-reconstruction, resugar) diff --git a/sdf3.stratego2.integrationtest/trans/sdf3_stratego2_integrationtest.str2 b/sdf3.stratego2.integrationtest/trans/sdf3_stratego2_integrationtest.str2 new file mode 100644 index 000000000..aec47855d --- /dev/null +++ b/sdf3.stratego2.integrationtest/trans/sdf3_stratego2_integrationtest.str2 @@ -0,0 +1,7 @@ +module sdf3_stratego2_integrationtest + +imports + + swap + completion/completion + pp diff --git a/sdf3.stratego2.integrationtest/trans/swap.analyzed.aterm b/sdf3.stratego2.integrationtest/trans/swap.analyzed.aterm new file mode 100644 index 000000000..41d28a1a5 --- /dev/null +++ b/sdf3.stratego2.integrationtest/trans/swap.analyzed.aterm @@ -0,0 +1,734 @@ +Module( + "swap" +, [ Imports([Import("strategolib"), ImportWildcard("signatures")]) + , Signature( + [ Constructors( + [ OpDecl( + "Conc" + , FunType( + [ ConstType(Sort("List", [SortVar("a")])) + , ConstType(Sort("List", [SortVar("a")])) + ] + , ConstType(Sort("List", [SortVar("a")])) + ) + ) + ] + ) + ] + ) + , Rules( + [ DefHasType( + "swap-editor-abstract-syntax" + , FunTType( + [] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + ] + ) + , Sort("Tuple", [DynT(Dyn()), DynT(Dyn())]) + ) + ) + ) + , SDefNoArgs( + "swap-editor-abstract-syntax" + , CallT( + SVar("editor-action") + , [ Seq( + TypeTest(Sort("Exp", [])) + , CallT(SVar("swap-exps-abstract-syntax"), [], []) + ) + ] + , [] + ) + ) + , DefHasType( + "swap-editor-concrete-syntax" + , FunTType( + [] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + ] + ) + , Sort("Tuple", [DynT(Dyn()), DynT(Dyn())]) + ) + ) + ) + , SDefNoArgs( + "swap-editor-concrete-syntax" + , CallT( + SVar("editor-action") + , [ Seq( + TypeTest(Sort("Stmt", [])) + , CallT(SVar("swap-exps-concrete-syntax"), [], []) + ) + ] + , [] + ) + ) + , DefHasType( + "swap-editor-concrete-syntax-simple" + , FunTType( + [] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + ] + ) + , Sort("Tuple", [DynT(Dyn()), DynT(Dyn())]) + ) + ) + ) + , SDefNoArgs( + "swap-editor-concrete-syntax-simple" + , CallT( + SVar("editor-action") + , [ Seq( + TypeTest(Sort("Stmt", [])) + , CallT(SVar("swap-exps-concrete-syntax-simple"), [], []) + ) + ] + , [] + ) + ) + , DefHasType( + "swap-editor-concrete-syntax-var" + , FunTType( + [] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + ] + ) + , Sort("Tuple", [DynT(Dyn()), DynT(Dyn())]) + ) + ) + ) + , SDefNoArgs( + "swap-editor-concrete-syntax-var" + , CallT( + SVar("editor-action") + , [ Seq( + TypeTest(Sort("Stmt", [])) + , CallT(SVar("swap-exps-concrete-syntax-var"), [], []) + ) + ] + , [] + ) + ) + , DefHasType( + "reverse-editor-concrete-syntax-varlist" + , FunTType( + [] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + ] + ) + , Sort("Tuple", [DynT(Dyn()), DynT(Dyn())]) + ) + ) + ) + , SDefNoArgs( + "reverse-editor-concrete-syntax-varlist" + , CallT( + SVar("editor-action") + , [ Seq( + TypeTest(Sort("Start", [])) + , CallT(SVar("reverse-stmts-concrete-syntax-varlist"), [], []) + ) + ] + , [] + ) + ) + , DefHasType( + "surround-editor-concrete-syntax-varlist" + , FunTType( + [] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + , DynT(Dyn()) + ] + ) + , Sort("Tuple", [DynT(Dyn()), DynT(Dyn())]) + ) + ) + ) + , SDefNoArgs( + "surround-editor-concrete-syntax-varlist" + , CallT( + SVar("editor-action") + , [ Seq( + TypeTest(Sort("Start", [])) + , CallT(SVar("surround-stmts-concrete-syntax-varlist"), [], []) + ) + ] + , [] + ) + ) + , DefHasType( + "editor-action" + , FunTType( + [FunTType([], [], FunNoArgsType(DynT(Dyn()), DynT(Dyn())))] + , [] + , FunNoArgsType( + Sort( + "Tuple" + , [ SortVar("a") + , SortVar("b") + , DynT(Dyn()) + , SortVar("d") + , SortVar("e") + ] + ) + , Sort("Tuple", [SortVar("d"), DynT(Dyn())]) + ) + ) + ) + , RDefT( + "editor-action" + , [DefaultVarDec("swap-exp")] + , [] + , Rule( + NoAnnoList( + Tuple( + [Wld(), Wld(), Var("ast"), Var("path"), Wld()] + ) + ) + , NoAnnoList( + Tuple( + [ Var("path") + , App( + CallT(SVar("oncetd"), [CallNoArgs(SVar("swap-exp"))], []) + , Var("ast") + ) + ] + ) + ) + , [] + ) + ) + , DefHasType( + "swap-exps-abstract-syntax" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Exp", []), Sort("Exp", [])) + ) + ) + , RDefNoArgs( + "swap-exps-abstract-syntax" + , Rule( + NoAnnoList(Op("Add", [Var("e1"), Var("e2")])) + , NoAnnoList(Op("Add", [Var("e2"), Var("e1")])) + , [] + ) + ) + , DefHasType( + "swap-exps-concrete-syntax" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Stmt", []), Sort("Stmt", [])) + ) + ) + , RDefNoArgs( + "swap-exps-concrete-syntax" + , Rule( + NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Add", [Var("e1"), Var("e2")]))] + ) + ) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Add", [Var("e2"), Var("e1")]))] + ) + ) + , [] + ) + ) + , DefHasType( + "swap-exps-concrete-syntax-simple" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Stmt", []), Sort("Stmt", [])) + ) + ) + , RDefNoArgs( + "swap-exps-concrete-syntax-simple" + , Rule( + NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Add", [Var("e1"), Var("e2")]))] + ) + ) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Add", [Var("e2"), Var("e1")]))] + ) + ) + , [] + ) + ) + , DefHasType( + "swap-exps-concrete-syntax-var" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Stmt", []), Sort("Stmt", [])) + ) + ) + , RDefNoArgs( + "swap-exps-concrete-syntax-var" + , Rule( + NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Add", [Var("exp"), Var("exp2")]))] + ) + ) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Add", [Var("exp2"), Var("exp")]))] + ) + ) + , [] + ) + ) + , DefHasType( + "reverse-stmts-abstract-syntax" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "reverse-stmts-abstract-syntax" + , Rule( + NoAnnoList(Op("Program", [Var(ListVar("stmt1*"))])) + , NoAnnoList(Op("Program", [Var(ListVar("stmt2*"))])) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(Sort("List", [Sort("Stmt", [])])) + , CallT(SVar("reverse"), [], []) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasType( + "reverse-stmts-concrete-syntax-varlist" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "reverse-stmts-concrete-syntax-varlist" + , Rule( + NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [Var(ListVar("stmt1*")), NoAnnoList(Op("Nil", []))] + ) + ) + ] + ) + ) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [Var(ListVar("stmt2*")), NoAnnoList(Op("Nil", []))] + ) + ) + ] + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(Sort("List", [Sort("Stmt", [])])) + , CallT(SVar("reverse"), [], []) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasType( + "surround-stmts-abstract-syntax" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "surround-stmts-abstract-syntax" + , Rule( + NoAnnoList(Op("Program", [Var(ListVar("stmt1*"))])) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + List( + [ NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"a\""))]))] + ) + ) + , Var(ListVar("stmt1*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"b\""))]))] + ) + ) + ] + ) + ) + ] + ) + ) + , [] + ) + ) + , DefHasType( + "surround-stmts-concrete-syntax-varlist" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "surround-stmts-concrete-syntax-varlist" + , Rule( + NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [Var(ListVar("stmt1*")), NoAnnoList(Op("Nil", []))] + ) + ) + ] + ) + ) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [ NoAnnoList( + Op( + "Conc" + , [ NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("a"))]))] + ) + ) + , Var(ListVar("stmt1*")) + ] + ) + ) + , NoAnnoList( + Op( + "Cons" + , [ NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("b"))]))] + ) + ) + , NoAnnoList(Op("Nil", [])) + ] + ) + ) + ] + ) + ) + ] + ) + ) + , [] + ) + ) + , DefHasType( + "surround-stmts-abstract-syntax2" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "surround-stmts-abstract-syntax2" + , Rule( + NoAnnoList(Op("Program", [Var(ListVar("stmt1*"))])) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + List( + [ Var(ListVar("stmt2*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"a\""))]))] + ) + ) + , Var(ListVar("stmt1*")) + , Var(ListVar("stmt1*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"b\""))]))] + ) + ) + , Var(ListVar("stmt2*")) + ] + ) + ) + ] + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(Sort("List", [Sort("Stmt", [])])) + , CallT(SVar("reverse"), [], []) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasType( + "surround-stmts-concrete-syntax-varlist2" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "surround-stmts-concrete-syntax-varlist2" + , Rule( + NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [Var(ListVar("stmt1*")), NoAnnoList(Op("Nil", []))] + ) + ) + ] + ) + ) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Conc" + , [ NoAnnoList( + Op( + "Conc" + , [ NoAnnoList( + Op( + "Conc" + , [ Var(ListVar("stmt2*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("a"))]))] + ) + ) + , Var(ListVar("stmt1*")) + ] + ) + ) + , Var(ListVar("stmt1*")) + ] + ) + ) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("b"))]))] + ) + ) + , Var(ListVar("stmt2*")) + ] + ) + ) + ] + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(Sort("List", [Sort("Stmt", [])])) + , CallT(SVar("reverse"), [], []) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasType( + "surround-stmts-concrete-syntax-list-fromterm" + , FunTType( + [] + , [] + , FunNoArgsType(Sort("Start", []), Sort("Start", [])) + ) + ) + , RDefNoArgs( + "surround-stmts-concrete-syntax-list-fromterm" + , Rule( + NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [Var(ListVar("stmt1*")), NoAnnoList(Op("Nil", []))] + ) + ) + ] + ) + ) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + Op( + "Cons" + , [ NoAnnoList( + Op( + "Conc" + , [ NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("a"))]))] + ) + ) + , Var(ListVar("stmt1*")) + ] + ) + ) + , NoAnnoList( + Op( + "Cons" + , [ NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("b"))]))] + ) + ) + , NoAnnoList(Op("Nil", [])) + ] + ) + ) + ] + ) + ) + ] + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(Sort("List", [Sort("Stmt", [])])) + , CallT(SVar("reverse"), [], []) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + ] + ) + ] +) \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/trans/swap.aterm b/sdf3.stratego2.integrationtest/trans/swap.aterm new file mode 100644 index 000000000..faa9ce007 --- /dev/null +++ b/sdf3.stratego2.integrationtest/trans/swap.aterm @@ -0,0 +1,417 @@ +Module( + "swap" +, [ Imports([Import("strategolib"), ImportWildcard("signatures")]) + , Signature( + [ Constructors( + [ OpDecl( + "Conc" + , OpFunType( + [ ConstType(Sort("List", [SortVar("a")])) + , ConstType(Sort("List", [SortVar("a")])) + ] + , ConstType(Sort("List", [SortVar("a")])) + ) + ) + ] + ) + ] + ) + , Rules( + [ DefHasTypeNoArgs( + "swap-editor-abstract-syntax" + , FunNoArgsType( + TupleT( + DynT(Dyn()) + , [DynT(Dyn()), DynT(Dyn()), DynT(Dyn()), DynT(Dyn())] + ) + , TupleT(DynT(Dyn()), [DynT(Dyn())]) + ) + ) + , SDefNoArgs( + "swap-editor-abstract-syntax" + , CallT( + SVar("editor-action") + , [Seq(TypeTest(SortTNoArgs("Exp")), CallNoArgs(SVar("swap-exps-abstract-syntax")))] + , [] + ) + ) + , DefHasTypeNoArgs( + "swap-editor-concrete-syntax" + , FunNoArgsType( + TupleT( + DynT(Dyn()) + , [DynT(Dyn()), DynT(Dyn()), DynT(Dyn()), DynT(Dyn())] + ) + , TupleT(DynT(Dyn()), [DynT(Dyn())]) + ) + ) + , SDefNoArgs( + "swap-editor-concrete-syntax" + , CallT( + SVar("editor-action") + , [Seq(TypeTest(SortTNoArgs("Stmt")), CallNoArgs(SVar("swap-exps-concrete-syntax")))] + , [] + ) + ) + , DefHasTypeNoArgs( + "swap-editor-concrete-syntax-simple" + , FunNoArgsType( + TupleT( + DynT(Dyn()) + , [DynT(Dyn()), DynT(Dyn()), DynT(Dyn()), DynT(Dyn())] + ) + , TupleT(DynT(Dyn()), [DynT(Dyn())]) + ) + ) + , SDefNoArgs( + "swap-editor-concrete-syntax-simple" + , CallT( + SVar("editor-action") + , [Seq(TypeTest(SortTNoArgs("Stmt")), CallNoArgs(SVar("swap-exps-concrete-syntax-simple")))] + , [] + ) + ) + , DefHasTypeNoArgs( + "swap-editor-concrete-syntax-var" + , FunNoArgsType( + TupleT( + DynT(Dyn()) + , [DynT(Dyn()), DynT(Dyn()), DynT(Dyn()), DynT(Dyn())] + ) + , TupleT(DynT(Dyn()), [DynT(Dyn())]) + ) + ) + , SDefNoArgs( + "swap-editor-concrete-syntax-var" + , CallT( + SVar("editor-action") + , [Seq(TypeTest(SortTNoArgs("Stmt")), CallNoArgs(SVar("swap-exps-concrete-syntax-var")))] + , [] + ) + ) + , DefHasTypeNoArgs( + "reverse-editor-concrete-syntax-varlist" + , FunNoArgsType( + TupleT( + DynT(Dyn()) + , [DynT(Dyn()), DynT(Dyn()), DynT(Dyn()), DynT(Dyn())] + ) + , TupleT(DynT(Dyn()), [DynT(Dyn())]) + ) + ) + , SDefNoArgs( + "reverse-editor-concrete-syntax-varlist" + , CallT( + SVar("editor-action") + , [Seq(TypeTest(SortTNoArgs("Start")), CallNoArgs(SVar("reverse-stmts-concrete-syntax-varlist")))] + , [] + ) + ) + , DefHasTypeNoArgs( + "surround-editor-concrete-syntax-varlist" + , FunNoArgsType( + TupleT( + DynT(Dyn()) + , [DynT(Dyn()), DynT(Dyn()), DynT(Dyn()), DynT(Dyn())] + ) + , TupleT(DynT(Dyn()), [DynT(Dyn())]) + ) + ) + , SDefNoArgs( + "surround-editor-concrete-syntax-varlist" + , CallT( + SVar("editor-action") + , [Seq(TypeTest(SortTNoArgs("Start")), CallNoArgs(SVar("surround-stmts-concrete-syntax-varlist")))] + , [] + ) + ) + , DefHasTType( + "editor-action" + , [FunNoArgsType(DynT(Dyn()), DynT(Dyn()))] + , [] + , FunNoArgsType( + TupleT( + SortTVar("a") + , [SortTVar("b"), DynT(Dyn()), SortTVar("d"), SortTVar("e")] + ) + , TupleT(SortTVar("d"), [DynT(Dyn())]) + ) + ) + , RDefT( + "editor-action" + , [DefaultVarDec("swap-exp")] + , [] + , Rule( + NoAnnoList( + Tuple( + [Wld(), Wld(), Var("ast"), Var("path"), Wld()] + ) + ) + , NoAnnoList( + Tuple( + [ Var("path") + , App( + Call(SVar("oncetd"), [CallNoArgs(SVar("swap-exp"))]) + , Var("ast") + ) + ] + ) + ) + , [] + ) + ) + , DefHasTypeNoArgs("swap-exps-abstract-syntax", FunNoArgsType(SortTNoArgs("Exp"), SortTNoArgs("Exp"))) + , RDefNoArgs( + "swap-exps-abstract-syntax" + , Rule( + NoAnnoList(Op("Add", [Var("e1"), Var("e2")])) + , NoAnnoList(Op("Add", [Var("e2"), Var("e1")])) + , [] + ) + ) + , DefHasTypeNoArgs("swap-exps-concrete-syntax", FunNoArgsType(SortTNoArgs("Stmt"), SortTNoArgs("Stmt"))) + , RDefNoArgs( + "swap-exps-concrete-syntax" + , Rule( + NoAnnoList( + ToTerm( + Stmt(Add(FromTerm(Var("e1")), FromTerm(Var("e2")))) + ) + ) + , NoAnnoList( + ToTerm( + Stmt(Add(FromTerm(Var("e2")), FromTerm(Var("e1")))) + ) + ) + , [] + ) + ) + , DefHasTypeNoArgs("swap-exps-concrete-syntax-simple", FunNoArgsType(SortTNoArgs("Stmt"), SortTNoArgs("Stmt"))) + , RDefNoArgs( + "swap-exps-concrete-syntax-simple" + , Rule( + NoAnnoList( + ToTerm( + Stmt(Add(FromTerm(Var("e1")), FromTerm(Var("e2")))) + ) + ) + , NoAnnoList( + ToTerm( + Stmt(Add(FromTerm(Var("e2")), FromTerm(Var("e1")))) + ) + ) + , [] + ) + ) + , DefHasTypeNoArgs("swap-exps-concrete-syntax-var", FunNoArgsType(SortTNoArgs("Stmt"), SortTNoArgs("Stmt"))) + , RDefNoArgs( + "swap-exps-concrete-syntax-var" + , Rule( + NoAnnoList(ToTerm(Stmt(Add(meta-var("exp"), meta-var("exp2"))))) + , NoAnnoList(ToTerm(Stmt(Add(meta-var("exp2"), meta-var("exp"))))) + , [] + ) + ) + , DefHasTypeNoArgs("reverse-stmts-abstract-syntax", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "reverse-stmts-abstract-syntax" + , Rule( + NoAnnoList(Op("Program", [Var(ListVar("stmt1*"))])) + , NoAnnoList(Op("Program", [Var(ListVar("stmt2*"))])) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(SortT("List", [SortTNoArgs("Stmt")])) + , CallNoArgs(SVar("reverse")) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasTypeNoArgs("reverse-stmts-concrete-syntax-varlist", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "reverse-stmts-concrete-syntax-varlist" + , Rule( + NoAnnoList(ToTerm(Program([meta-listvar("stmt1*")]))) + , NoAnnoList(ToTerm(Program([meta-listvar("stmt2*")]))) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(SortT("List", [SortTNoArgs("Stmt")])) + , CallNoArgs(SVar("reverse")) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasTypeNoArgs("surround-stmts-abstract-syntax", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "surround-stmts-abstract-syntax" + , Rule( + NoAnnoList(Op("Program", [Var(ListVar("stmt1*"))])) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + List( + [ NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"a\""))]))] + ) + ) + , Var(ListVar("stmt1*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"b\""))]))] + ) + ) + ] + ) + ) + ] + ) + ) + , [] + ) + ) + , DefHasTypeNoArgs("surround-stmts-concrete-syntax-varlist", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "surround-stmts-concrete-syntax-varlist" + , Rule( + NoAnnoList(ToTerm(Program([meta-listvar("stmt1*")]))) + , NoAnnoList( + ToTerm( + Program( + [Conc(Stmt(Var("a")), meta-listvar("stmt1*")), Stmt(Var("b"))] + ) + ) + ) + , [] + ) + ) + , DefHasTypeNoArgs("surround-stmts-abstract-syntax2", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "surround-stmts-abstract-syntax2" + , Rule( + NoAnnoList(Op("Program", [Var(ListVar("stmt1*"))])) + , NoAnnoList( + Op( + "Program" + , [ NoAnnoList( + List( + [ Var(ListVar("stmt2*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"a\""))]))] + ) + ) + , Var(ListVar("stmt1*")) + , Var(ListVar("stmt1*")) + , NoAnnoList( + Op( + "Stmt" + , [NoAnnoList(Op("Var", [NoAnnoList(Str("\"b\""))]))] + ) + ) + , Var(ListVar("stmt2*")) + ] + ) + ) + ] + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(SortT("List", [SortTNoArgs("Stmt")])) + , CallNoArgs(SVar("reverse")) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasTypeNoArgs("surround-stmts-concrete-syntax-varlist2", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "surround-stmts-concrete-syntax-varlist2" + , Rule( + NoAnnoList(ToTerm(Program([meta-listvar("stmt1*")]))) + , NoAnnoList( + ToTerm( + Program( + Conc( + Conc( + Conc(meta-listvar("stmt2*"), Stmt(Var("a")), meta-listvar("stmt1*")) + , meta-listvar("stmt1*") + ) + , Stmt(Var("b")) + , meta-listvar("stmt2*") + ) + ) + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(SortT("List", [SortTNoArgs("Stmt")])) + , CallNoArgs(SVar("reverse")) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + , DefHasTypeNoArgs("surround-stmts-concrete-syntax-list-fromterm", FunNoArgsType(SortTNoArgs("Start"), SortTNoArgs("Start"))) + , RDefNoArgs( + "surround-stmts-concrete-syntax-list-fromterm" + , Rule( + NoAnnoList(ToTerm(Program([FromTerm(Var(ListVar("stmt1*")))]))) + , NoAnnoList( + ToTerm( + Program( + [ Conc(Stmt(Var("a")), FromTerm(Var(ListVar("stmt1*")))) + , Stmt(Var("b")) + ] + ) + ) + ) + , [ WhereClause( + Assign( + Var(ListVar("stmt2*")) + , App( + Seq( + TypeTest(SortT("List", [SortTNoArgs("Stmt")])) + , CallNoArgs(SVar("reverse")) + ) + , Var(ListVar("stmt1*")) + ) + ) + ) + ] + ) + ) + ] + ) + ] +) \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/trans/swap.meta b/sdf3.stratego2.integrationtest/trans/swap.meta new file mode 100644 index 000000000..19d432165 --- /dev/null +++ b/sdf3.stratego2.integrationtest/trans/swap.meta @@ -0,0 +1 @@ +Meta([Syntax("foo")]) \ No newline at end of file diff --git a/sdf3.stratego2.integrationtest/trans/swap.str2 b/sdf3.stratego2.integrationtest/trans/swap.str2 new file mode 100644 index 000000000..cbe37e22b --- /dev/null +++ b/sdf3.stratego2.integrationtest/trans/swap.str2 @@ -0,0 +1,77 @@ +module swap + +imports + + strategolib + signatures/- + +rules + + editor-action-swap-exps-abstract-syntax :: ? * ? * ? * ? * ? -> ? * ? + editor-action-swap-exps-abstract-syntax = editor-action(is(Exp);swap-exps-abstract-syntax|) + + editor-action-swap-exps-concrete-syntax :: ? * ? * ? * ? * ? -> ? * ? + editor-action-swap-exps-concrete-syntax = editor-action(is(Stmt);swap-exps-concrete-syntax|) + + editor-action-swap-exps-concrete-syntax-simple :: ? * ? * ? * ? * ? -> ? * ? + editor-action-swap-exps-concrete-syntax-simple = editor-action(is(Stmt);swap-exps-concrete-syntax-simple|) + + editor-action-swap-exps-concrete-syntax-var :: ? * ? * ? * ? * ? -> ? * ? + editor-action-swap-exps-concrete-syntax-var = editor-action(is(Stmt);swap-exps-concrete-syntax-var|) + + editor-action-reverse-stmts-concrete-syntax-varlist :: ? * ? * ? * ? * ? -> ? * ? + editor-action-reverse-stmts-concrete-syntax-varlist = editor-action(is(Start);reverse-stmts-concrete-syntax-varlist|) + + editor-action-surround-stmts-concrete-syntax-varlist :: ? * ? * ? * ? * ? -> ? * ? + editor-action-surround-stmts-concrete-syntax-varlist = editor-action(is(Start);surround-stmts-concrete-syntax-varlist|) + + editor-action-surround-stmts-concrete-syntax-varlist2 :: ? * ? * ? * ? * ? -> ? * ? + editor-action-surround-stmts-concrete-syntax-varlist2 = editor-action(is(Start);surround-stmts-concrete-syntax-varlist2|) + + editor-action-surround-stmts-concrete-syntax-list-fromterm :: ? * ? * ? * ? * ? -> ? * ? + editor-action-surround-stmts-concrete-syntax-list-fromterm = editor-action(is(Start);surround-stmts-concrete-syntax-list-fromterm|) + + editor-action(? -> ?|) :: a * b * ? * d * e -> d * ? + editor-action(swap-exp|): + (_, _, ast, path, _) -> (path, ast) + + swap-exps-abstract-syntax :: Exp -> Exp + swap-exps-abstract-syntax: + Add(e1, e2) -> Add(e2, e1) + + swap-exps-concrete-syntax :: Stmt -> Stmt + swap-exps-concrete-syntax: + stmt |[ ~exp:e1 + ~exp:e2; ]| -> + stmt |[ ~exp:e2 + ~exp:e1; ]| + + swap-exps-concrete-syntax-simple :: Stmt -> Stmt + swap-exps-concrete-syntax-simple: + stmt |[ ~e1 + ~e2; ]| -> + stmt |[ ~e2 + ~e1; ]| + + swap-exps-concrete-syntax-var :: Stmt -> Stmt + swap-exps-concrete-syntax-var: + stmt |[ exp + exp2 ; ]| -> + stmt |[ exp2 + exp ; ]| + + reverse-stmts-concrete-syntax-varlist :: Start -> Start + reverse-stmts-concrete-syntax-varlist: + program |[ stmt1* ]| -> + program |[ stmt2* ]| + where stmt2* := stmt1* + + surround-stmts-concrete-syntax-varlist :: Start -> Start + surround-stmts-concrete-syntax-varlist: + program |[ stmt1* ]| -> + program |[ a; stmt1* b; ]| + + surround-stmts-concrete-syntax-varlist2 :: Start -> Start + surround-stmts-concrete-syntax-varlist2: + program |[ stmt1* ]| -> + program |[ stmt2* a; stmt1* stmt1* b; stmt2* ]| + where stmt2* := stmt1* + + surround-stmts-concrete-syntax-list-fromterm :: Start -> Start + surround-stmts-concrete-syntax-list-fromterm: + program |[ ~stmt1* ]| -> + program |[ a; ~stmt1* b; ]|