Commit c4f67c3a authored by Lars Hermerschmidt's avatar Lars Hermerschmidt
Browse files

Generator moved to ba-poth repo

parent 13f98d56
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>secarc-example</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>generator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.se_rwth.montisecarc</groupId>
<artifactId>montiSecArcGenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>generator</artifactId>
<properties>
<!-- <monticore.version>2.0.6</monticore.version> -->
<!-- <umlp.version>1.6.0</umlp.version> -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.se_rwth.montisecarc</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>montiSecArcBE</artifactId>
</dependency>
<dependency>
<groupId>de.se_rwth.montisecarc</groupId>
<artifactId>montiSecArcFE</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>de.monticore.lang.common</groupId>
<artifactId>common-values</artifactId>
<version>1.9.0</version>
</dependency>
<!-- .. MontiCore .................................................... -->
<dependency>
<groupId>de.monticore</groupId>
<artifactId>de.monticore.re</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>de.monticore.ets</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>de.monticore.gli</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>de.monticore.freemarker</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>de.monticore.java</artifactId>
<version>${monticore.version}</version>
</dependency>
<!-- UML/P Languages -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.cdjava.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.odjava.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.scjava.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.sdjava.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.tcjava.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>de.monticore.lang.umlp</groupId> -->
<!-- <artifactId>de.umlp.ocl.fe</artifactId> -->
<!-- <version>${umlp.version}</version> -->
<!-- </dependency> -->
</dependencies>
</project>
package de.se_rwth.secarc.example;
import java.util.Map;
import com.google.inject.Guice;
import com.google.inject.Injector;
import interfaces2.language.ETSTool;
import interfaces2.language.LanguageFamily;
import mc.MCG;
import mc.ProblemReport.Type;
import mc.umlp.arcd.InjectorProvider;
import secarc.ets.check.MontiSecArcAnalysisCreator;
import secarc.ets.check.MontiSecArcContextConditionCreator;
/**
* Tool for {@link MontiSecArcAnalysis}.
*
* @author (last commit) $Author$
* @version $Revision$, $Date$
*
*/
public class MontiSecArcAnalysisTool extends ETSTool {
/**
* The main method of this tool. Creates, initializes and starts
* {@link MontiSecArcAnalysisTool}. Takes a list of {@link DSLTool} arguments.
*
* @param a list of {@link DSLTool} arguments.
*/
public static void main(String[] arguments) {
MCG.initMonticoreGlobals();
MontiSecArcAnalysisTool tool = new MontiSecArcAnalysisTool(arguments);
tool.init();
tool.run();
}
/**
* Constructor for secarc.MontiSecArcAnalysisTool
*
* @param arguments
*/
public MontiSecArcAnalysisTool(String[] arguments) {
super(arguments);
Injector injector = Guice.createInjector(new MontiSecArcDefaultModule());
InjectorProvider.setInjector(injector);
LanguageFamily languageFamily = new LanguageFamily();
languageFamily.addLanguage(MontiSecArcAnalysis.newLanguage(injector.getInstance(MontiSecArcComponent.class)));
setLanguages(languageFamily);
// set default CoCos
Map<String, Type> cocoConfig = MontiSecArcContextConditionCreator.createConfig();
cocoConfig.putAll(MontiSecArcAnalysisCreator.createConfig());
setCocoConfiguration(cocoConfig);
}
@Override
protected void initParameters(String[] args) {
super.initParameters(args);
// Default ExecutionUnits (can be changed by user with DSLTool command
// line parameters)
if (parameters.getAnalyses().isEmpty()) {
parameters.addAnalysis(Parameters.ALL, "parse");
}
if (parameters.getSyntheses().isEmpty()) {
parameters.addSynthesis("ALL", "generate");
}
}
@Override
public void initDSLRootFactory() {
// Determine file type by file extension
DSLRootFactoryByFileExtension rootfactory = new DSLRootFactoryByFileExtension(getModelInfrastructureProvider(), getErrorDelegator(),
parameters.getEncoding());
// Automatons end with file extension "aut"
AutomatonRootFactory aut = new AutomatonRootFactory(getModelInfrastructureProvider(), getErrorDelegator(), parameters.getEncoding());
rootfactory.addFileExtension("aut", aut);
// Renamings end with file extension "ren"
RenamingRootFactory ren = new RenamingRootFactory(getModelInfrastructureProvider(), getErrorDelegator(), parameters.getEncoding());
rootfactory.addFileExtension("ren", ren);
// Renamings end with file extension "ren"
InputRootFactory input = new InputRootFactory(getModelInfrastructureProvider(), getErrorDelegator(), parameters.getEncoding());
rootfactory.addFileExtension("input", input);
setDSLRootFactory(rootfactory);
}
@Override
protected void initDSLToolConfiguration() {
super.initDSLToolConfiguration();
// Add roots to the configuration
configuration.addDSLRootClassForUserName("aut", AutomatonRoot.class);
configuration.addDSLRootClassForUserName("ren", RenamingRoot.class);
configuration.addDSLRootClassForUserName("input", InputRoot.class);
// Add workflows to the configuration
configuration.addExecutionUnit("parse", new AutomatonParseWorkflow(AutomatonRoot.class));
configuration.addExecutionUnit("parse", new RenamingParsingWorkflow(RenamingRoot.class));
configuration.addExecutionUnit("parse", new InputParsingWorkflow(InputRoot.class));
configuration.addExecutionUnit("generate", new ExecuteWorkflow());
configuration.addExecutionUnit("generate", new RenameAndPrintWorkflow());
}
}
package secarc.gen;
import java.util.Collection;
import java.util.Iterator;
import secarc._ast.ASTSecArcFilterComponent;
import mc.ast.ASTNode;
import mc.codegen.TemplateCalculator;
import mc.codegen.TemplateOperator;
public class Constants extends TemplateCalculator<ASTNode> {
@Override
public boolean calc(ASTNode ast, TemplateOperator op) {
op.setValue("constants", this);
ASTSecArcFilterComponent component = (ASTSecArcFilterComponent)ast;
component.get_Children();
component.getPorts();
traverse(0, ast); //TODO use InheritanceVisitor instead
return true;
}
private void traverse (int depth, ASTNode ast) {
String prefix="";
for(int d = depth;d>0;d--) {
prefix=prefix+" ";
}
System.out.println(prefix + ast.getClass());
Collection<ASTNode> nodes = ast.get_Children();
Iterator<ASTNode> it = nodes.iterator();
while(it.hasNext()) {
ASTNode node = it.next();
traverse(depth+1, node);
}
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.se_rwth.montisecarc</groupId>
<artifactId>montiSecArc</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>montiSecArcGenerator</artifactId>
<packaging>pom</packaging>
<modules>
<module>usage</module>
<module>generator</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/models">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>usage</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment