Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta variables to SDF3 Stratego mix syntax test #65

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a7b63b6
Add meta variables to SDF3 Stratego mix syntax test
Apanatshka Mar 29, 2022
b2c0b47
Failed attempt at meta list variables in mix syntax
Apanatshka Mar 29, 2022
0625814
meta-listvar instead of meta-list-var as constructor for list meta-va…
jasperdenkers Apr 5, 2022
ed74418
Add test for lists meta-vars in concrete object syntax
jasperdenkers Apr 5, 2022
c68e6a7
Rename/cleanup test strategies and actions to be more consistent
jasperdenkers Apr 5, 2022
76fd71b
Add failing test with Conc
Apanatshka Apr 5, 2022
47937bc
Add missing list normalization rule for meta list var
jasperdenkers Apr 15, 2022
83876cf
Merge branch 'master' into sdf3-meta
Apanatshka Mar 7, 2023
9355c3c
We've settled on this as code that should work
Apanatshka Mar 8, 2023
f3c9705
More tests, for meta-listvar and for FromTerm as a sublist
Apanatshka Mar 9, 2023
32fe7b5
Add Stratego 2 version of integrationtest. Does not parse sublists co…
Apanatshka Mar 9, 2023
2f1168f
Commit forgotten changes of unambiguous mix syntax snippets
Apanatshka Mar 9, 2023
7c50b89
Merge branch 'master' into sdf3-meta
jasperdenkers Jul 17, 2023
fc6a669
Apply same fix as in other mix syntax integrationtest project (ab146a69)
jasperdenkers Jul 17, 2023
fe78334
Merge branch 'master' into sdf3-meta
Apanatshka Jan 28, 2025
ff18689
Workaround issue with Spoofax 2.5.22 trying to use 2.5.21 when the ve…
Apanatshka Jan 29, 2025
49f92fb
This version of the tests should work once the latest changes to Stra…
Apanatshka Jan 31, 2025
b5c3c5b
Error on variable sections in SDF3, since they're not supported
Apanatshka Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,17 @@ rules
where
<?s> s';
<eq> (<length> ty*, <length> ty'*)

rules

nabl-constraint(|ctx):
section@VariablesProductive(_) -> <fail>
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";
<task-create-error(|ctx, msg)> section

nabl-constraint(|ctx):
section@LexVariablesProductive(_) -> <fail>
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";
<task-create-error(|ctx, msg)> section
11 changes: 8 additions & 3 deletions org.metaborg.sdf3.meta.integrationtest/editor/Main.esv
Original file line number Diff line number Diff line change
Expand Up @@ -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)
35 changes: 34 additions & 1 deletion org.metaborg.sdf3.meta.integrationtest/syntax/foo.sdf3
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <|[ <Stmt> ]|>
StrategoLang-PreTerm.ToTerm = <stmt |[ <Stmt> ]|>

StrategoLang-PreTerm.ToTerm = <|[ <Start> ]|>
StrategoLang-PreTerm.ToTerm = <program |[ <Start> ]|>

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]
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 13 additions & 3 deletions org.metaborg.sdf3.meta.integrationtest/test/swap.spt
Original file line number Diff line number Diff line change
Expand Up @@ -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;]]
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;]]
51 changes: 40 additions & 11 deletions org.metaborg.sdf3.meta.integrationtest/trans/swap.str
Original file line number Diff line number Diff line change
Expand Up @@ -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, <topdown(try(swap-exp))> 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, <oncetd(s)> 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 ; ]|
|[ ~e2 + ~e1 ; ]|

swap-exps-concrete-syntax-var:
|[ exp + exp2 ; ]| ->
|[ exp2 + exp ; ]|

reverse-stmts-concrete-syntax-varlist:
|[ stmt1* ]| ->
|[ stmt2* ]|
where stmt2* := <reverse> stmt1*

surround-stmts-concrete-syntax-varlist:
|[ stmt1* ]| ->
program |[ a; stmt1* b; ]|
where stmt2* := <reverse> stmt1*

surround-stmts-concrete-syntax-varlist2:
|[ stmt1* ]| ->
program |[ stmt2* a; stmt1* stmt1* b; stmt2* ]|
where stmt2* := <reverse> stmt1*

surround-stmts-concrete-syntax-list-fromterm:
|[ ~*stmt1* ]| ->
program |[ a; ~*stmt1* b; ]|
where stmt2* := <reverse> stmt1*
14 changes: 14 additions & 0 deletions sdf3.stratego2.integrationtest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/.cache
/bin
/src-gen
/target

/.classpath
/.project
/.settings
/.factorypath

/.polyglot.metaborg.yaml

/trans/foo.tbl
/trans/table-foo.bin
8 changes: 8 additions & 0 deletions sdf3.stratego2.integrationtest/.mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>org.metaborg</groupId>
<artifactId>spoofax-maven-plugin-pomless</artifactId>
<version>2.6.0-SNAPSHOT</version>
</extension>
</extensions>
23 changes: 23 additions & 0 deletions sdf3.stratego2.integrationtest/editor/Main.esv
Original file line number Diff line number Diff line change
@@ -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)
45 changes: 45 additions & 0 deletions sdf3.stratego2.integrationtest/metaborg.yaml
Original file line number Diff line number Diff line change
@@ -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
88 changes: 88 additions & 0 deletions sdf3.stratego2.integrationtest/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<modelVersion>4.0.0</modelVersion>
<artifactId>sdf3.stratego2.integrationtest</artifactId>
<packaging>spoofax-language</packaging>

<parent>
<groupId>org.metaborg</groupId>
<artifactId>parent.language</artifactId>
<version>2.6.0-SNAPSHOT</version>
<relativePath>../../releng/parent/java</relativePath>
</parent>

<dependencies>
<!-- compile -->
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>org.metaborg.meta.lang.esv</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
</dependency>
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>org.metaborg.meta.lang.template</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
</dependency>
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>org.metaborg.meta.lang.spt</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>stratego.lang</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
</dependency>

<!-- source -->
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>meta.lib.spoofax</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>strategolib</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
</dependency>
<dependency>
<groupId>org.metaborg</groupId>
<artifactId>gpp</artifactId>
<version>${metaborg-version}</version>
<type>spoofax-language</type>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.metaborg</groupId>
<artifactId>spoofax-maven-plugin</artifactId>
<version>${metaborg-version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<languageUnderTest>org.metaborg:sdf3.stratego2.integrationtest:${metaborg-version}</languageUnderTest>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading