added symbolTableCreator

parent 9b2e777e
......@@ -2,10 +2,12 @@ package de.monticore.lang.monticar;
grammar CNNTrain extends de.monticore.common.Common {
symbol scope Configuration = "training" name:Name&
"{" (assignments:ParameterAssignment)+ "}";
CNNTrainCompilationUnit = TrainingConfiguration;
ParameterAssignment = lhs:TrainingParameter "=" rhs:Rhs;
symbol scope TrainingConfiguration = "training" name:Name& "{"
(assignments:ParameterAssignment)+ "}";
ParameterAssignment = lhs:TrainingParameter "=" rhs:ParameterRhs;
enum TrainingParameter = DATA:"data"
| LABELS:"labels"
| EPOCHS:"epochs"
......@@ -15,7 +17,7 @@ grammar CNNTrain extends de.monticore.common.Common {
Rhs = stringVal:String
ParameterRhs = stringVal:String
| intVal:Num_Int
| doubleVal:Num_Double
| refOrBool:Name;
......
......@@ -22,17 +22,17 @@ package de.monticore.lang.monticar.cnntrain._ast;
import java.util.List;
public class ASTConfiguration extends ASTConfigurationTOP {
public class ASTTrainingConfiguration extends ASTTrainingConfigurationTOP {
public ASTConfiguration() {
public ASTTrainingConfiguration() {
}
public ASTConfiguration(String name, List<ASTParameterAssignment> assignments) {
public ASTTrainingConfiguration(String name, List<ASTParameterAssignment> assignments) {
super(name, assignments);
}
public ASTRhs get(String lhsName) {
ASTRhs rhs = null;
public ASTParameterRhs get(String lhsName) {
ASTParameterRhs rhs = null;
lhsName = lhsName.replace("_", "");
for (ASTParameterAssignment assignment : getAssignments()) {
String assignmentLhs = assignment.getLhs().name();
......
/**
*
* ******************************************************************************
* 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._symboltable;
import de.monticore.lang.monticar.cnntrain._ast.ASTCNNTrainCompilationUnit;
import de.monticore.lang.monticar.cnntrain._ast.ASTTrainingConfiguration;
import de.monticore.symboltable.ArtifactScope;
import de.monticore.symboltable.ImportStatement;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.ResolvingConfiguration;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Optional;
public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
private String compilationUnitPackage = "";
public CNNTrainSymbolTableCreator(final ResolvingConfiguration resolvingConfig,
final MutableScope enclosingScope) {
super(resolvingConfig, enclosingScope);
}
public CNNTrainSymbolTableCreator(final ResolvingConfiguration resolvingConfig,
final Deque<MutableScope> scopeStack) {
super(resolvingConfig, scopeStack);
}
@Override
public void visit(final ASTCNNTrainCompilationUnit compilationUnit) {
Log.debug("Building Symboltable for Script: " + compilationUnit.getTrainingConfiguration().getName(),
CNNTrainSymbolTableCreator.class.getSimpleName());
List<ImportStatement> imports = new ArrayList<>();
ArtifactScope artifactScope = new ArtifactScope(
Optional.empty(),
compilationUnitPackage,
imports);
putOnStack(artifactScope);
}
public void visit(final ASTTrainingConfiguration trainingConfiguration) {
TrainingConfigurationSymbol configSymbol = new TrainingConfigurationSymbol(
trainingConfiguration.getName()
);
addToScopeAndLinkWithNode(configSymbol, trainingConfiguration);
}
public void endVisit(final ASTTrainingConfiguration trainingConfiguration) {
removeCurrentScope();
}
}
......@@ -20,12 +20,12 @@
*/
package de.monticore.lang.monticar.cnntrain._symboltable;
public class ConfigurationSymbol extends de.monticore.symboltable.CommonScopeSpanningSymbol {
public class TrainingConfigurationSymbol extends de.monticore.symboltable.CommonScopeSpanningSymbol {
public static final ConfigurationKind KIND = new ConfigurationKind();
public static final TrainingConfigurationKind KIND = new TrainingConfigurationKind();
public ConfigurationSymbol(String name) {
public TrainingConfigurationSymbol(String name) {
super(name, KIND);
}
......
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