moved symbol scope from non-terminal Architecture to non-terminal CompilationUnit

parent 411cf752
......@@ -43,7 +43,7 @@
<SIUnit.version>0.0.6-SNAPSHOT</SIUnit.version>
<Common-MontiCar.version>0.0.3-SNAPSHOT</Common-MontiCar.version>
<Embedded-MontiArc.version>0.0.3-SNAPSHOT</Embedded-MontiArc.version>
<Embedded-MontiArc-Behaviour.version>0.0.3-SNAPSHOT</Embedded-MontiArc-Behaviour.version>
<Math.version>0.0.3-SNAPSHOT-REWORK</Math.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
......@@ -154,15 +154,15 @@
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-behaviour</artifactId>
<version>${Embedded-MontiArc-Behaviour.version}</version>
<groupId>de.monticore.lang</groupId>
<artifactId>math</artifactId>
<version>${Math.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-behaviour</artifactId>
<version>${Embedded-MontiArc-Behaviour.version}</version>
<groupId>de.monticore.lang</groupId>
<artifactId>math</artifactId>
<version>${Math.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
......
package de.monticore.lang.monticar;
grammar CNNArch extends de.monticore.common.Common {
grammar CNNArch extends de.monticore.lang.math.Math {
CNNArchCompilationUnit = Architecture;
symbol scope CNNArchCompilationUnit = "architecture" Name& "{" Architecture "}";
symbol scope Architecture = "architecture"
Name& "{"
(MainLayer)+
OutputLayer
"}";
Architecture = (MainLayer)+ OutputLayer;
//InputPort = Name "-->";
//OutputPort = "-->" Name;
interface Layer;
ast Layer = method ASTMethod getMethod(){};
......@@ -24,11 +18,11 @@ grammar CNNArch extends de.monticore.common.Common {
method public ASTArgumentRhs getRhs(){};
ArgumentRhs = stringVal:String
| intVal:Num_Int
| doubleVal:Num_Double
| intTuple:IntTuple
| refOrBool:Name;
IntTuple = "(" values:Num_Int "," values:(Num_Int || ",")+ ")";
| number:Number
| tuple:Tuple
| booleanVal:Boolean;
Tuple = "(" values:Number "," values:(Number || ",")+ ")";
enum Boolean = TRUE:"true" | FALSE:"false" | TRUE:"True" | FALSE:"False";
......
/**
*
* ******************************************************************************
* 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.cnnarch._ast;
import java.util.Optional;
public class ASTArgumentRhs extends ASTArgumentRhsTOP{
private boolean containsBoolean;
public ASTArgumentRhs() {
}
public ASTArgumentRhs(String stringVal, String intVal, String doubleVal, ASTIntTuple intTuple, String refOrBool) {
super(stringVal, intVal, doubleVal, intTuple, refOrBool);
}
@Override
public void setRefOrBool(String refOrBool) {
if (refOrBool.equalsIgnoreCase("true")
|| refOrBool.equalsIgnoreCase("false")){
containsBoolean = true;
super.setRefOrBool(refOrBool.toLowerCase());
}
else {
containsBoolean = false;
super.setRefOrBool(refOrBool);
}
}
public Optional<String> getRef(){
if (containsBoolean) {
return Optional.empty();
}
else {
return getRefOrBool();
}
}
public Optional<String> getBooleanVal(){
if (containsBoolean) {
return getRefOrBool();
}
else {
return Optional.empty();
}
}
}
\ No newline at end of file
/**
*
* ******************************************************************************
* 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.cnnarch._symboltable;
public class ArchitectureSymbol extends de.monticore.symboltable.CommonScopeSpanningSymbol {
public static final ArchitectureKind KIND = new ArchitectureKind();
public ArchitectureSymbol(String name) {
super(name, KIND);
}
}
......@@ -49,7 +49,7 @@ public class CNNArchSymbolTableCreator extends CNNArchSymbolTableCreatorTOP {
@Override
public void visit(final ASTCNNArchCompilationUnit compilationUnit) {
Log.debug("Building Symboltable for Script: " + compilationUnit.getArchitecture().getName(),
Log.debug("Building Symboltable for Script: " + compilationUnit.getName(),
CNNArchSymbolTableCreator.class.getSimpleName());
List<ImportStatement> imports = new ArrayList<>();
......@@ -60,16 +60,15 @@ public class CNNArchSymbolTableCreator extends CNNArchSymbolTableCreatorTOP {
imports);
putOnStack(artifactScope);
}
public void visit(final ASTArchitecture architecture) {
ArchitectureSymbol architectureSymbol = new ArchitectureSymbol(
architecture.getName()
CNNArchCompilationUnitSymbol compilationUnitSymbol = new CNNArchCompilationUnitSymbol(
compilationUnit.getName()
);
addToScopeAndLinkWithNode(architectureSymbol, architecture);
addToScopeAndLinkWithNode(compilationUnitSymbol, compilationUnit);
}
public void endVisit(final ASTArchitecture architecture) {
removeCurrentScope();
}
......
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