Commit 75ebafab authored by Svetlana Pavlitskaya's avatar Svetlana Pavlitskaya
Browse files

added generator interface

parent 2b2f2468
Pipeline #71192 passed with stages
in 7 minutes and 9 seconds
......@@ -30,17 +30,16 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-train</artifactId>
<version>0.2.4-SNAPSHOT</version>
<version>0.2.5-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>5.0.0</monticore.version>
<monticore.version>5.0.1</monticore.version>
<se-commons.version>1.7.8</se-commons.version>
<mc.grammars.assembly.version>0.0.6-SNAPSHOT</mc.grammars.assembly.version>
<SIUnit.version>0.0.11</SIUnit.version>
<mc.grammars.assembly.version>0.0.6</mc.grammars.assembly.version>
<Common-MontiCar.version>0.0.14-SNAPSHOT</Common-MontiCar.version>
<!-- .. Libraries .................................................. -->
......@@ -50,7 +49,7 @@
<jscience.version>4.3.1</jscience.version>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>5.0.0</monticore.plugin>
<monticore.plugin>5.0.1</monticore.plugin>
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
......@@ -114,21 +113,6 @@
<version>${se-commons.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>NumberUnit</artifactId>
<version>${SIUnit.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>NumberUnit</artifactId>
<version>${SIUnit.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>common-monticar</artifactId>
......
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.monticar.cnntrain;
import de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol;
import de.monticore.symboltable.Scope;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
public interface CNNTrainGenerator {
String getInstanceName();
void setInstanceName(String instanceName);
String getGenerationTargetPath();
void setGenerationTargetPath(String generationTargetPath);
void generate(Path modelsDirPath, String rootModelNames);
void generate(Scope scope, String rootModelName);
//check cocos with CNNTrainCocos.checkAll(configuration) before calling this method.
void generateFile(ConfigurationSymbol configuration) throws IOException;
//check cocos with CNNTrainCocos.checkAll(configuration) before calling this method.
Map<String, String> generateStrings(ConfigurationSymbol configuration);
}
......@@ -104,10 +104,7 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
@Override
public void endVisit(ASTNumEpochEntry node) {
EntrySymbol entry = new EntrySymbol(node.getName());
ValueSymbol value = new ValueSymbol();
Integer value_as_int = getIntegerFromNumber(node.getValue());
value.setValue(value_as_int);
entry.setValue(value);
entry.setValue(getValueSymbolForInteger(node.getValue()));
addToScopeAndLinkWithNode(entry, node);
configuration.getEntryMap().put(node.getName(), entry);
}
......@@ -115,10 +112,7 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
@Override
public void endVisit(ASTBatchSizeEntry node) {
EntrySymbol entry = new EntrySymbol(node.getName());
ValueSymbol value = new ValueSymbol();
Integer value_as_int = getIntegerFromNumber(node.getValue());
value.setValue(value_as_int);
entry.setValue(value);
entry.setValue(getValueSymbolForInteger(node.getValue()));
addToScopeAndLinkWithNode(entry, node);
configuration.getEntryMap().put(node.getName(), entry);
}
......@@ -126,9 +120,7 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
@Override
public void endVisit(ASTLoadCheckpointEntry node) {
EntrySymbol entry = new EntrySymbol(node.getName());
ValueSymbol value = new ValueSymbol();
value.setValue(getBooleanForValue(node.getValue()));
entry.setValue(value);
entry.setValue(getValueSymbolForBoolean(node.getValue()));
addToScopeAndLinkWithNode(entry, node);
configuration.getEntryMap().put(node.getName(), entry);
}
......@@ -136,9 +128,7 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
@Override
public void endVisit(ASTNormalizeEntry node) {
EntrySymbol entry = new EntrySymbol(node.getName());
ValueSymbol value = new ValueSymbol();
value.setValue(getBooleanForValue(node.getValue()));
entry.setValue(value);
entry.setValue(getValueSymbolForBoolean(node.getValue()));
addToScopeAndLinkWithNode(entry, node);
configuration.getEntryMap().put(node.getName(), entry);
}
......@@ -240,15 +230,26 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
addToScopeAndLinkWithNode(value, node);
}
private ValueSymbol getValueSymbolForInteger(ASTIntegerValue astIntegerValue) {
ValueSymbol value = new ValueSymbol();
Integer value_as_int = getIntegerFromNumber(astIntegerValue);
value.setValue(value_as_int);
return value;
}
private ValueSymbol getValueSymbolForBoolean(ASTBooleanValue astBooleanValue) {
ValueSymbol value = new ValueSymbol();
Boolean value_as_bool = getBooleanForValue(astBooleanValue);
value.setValue(value_as_bool);
return value;
}
private int getIntegerFromNumber(ASTIntegerValue value) {
return value.getNumberWithUnit().getNumber().get().intValue();
}
private boolean getBooleanForValue(ASTBooleanValue value2) {
if (value2.isPresentTRUE()) {
return true;
}
return false;
return value2.isPresentTRUE();
}
}
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