Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
CNNArchLang
Commits
3bfb1407
Commit
3bfb1407
authored
Aug 09, 2018
by
Svetlana Pavlitskaya
Browse files
moved to monticore 5.0.0 and newer math, tests are not passing yet
parent
6b193247
Pipeline
#67559
failed with stages
in 13 minutes and 46 seconds
Changes
33
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
3bfb1407
#
#
# ******************************************************************************
# 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/>.
# *******************************************************************************
#
stages
:
-
windows
-
linux
...
...
pom.xml
View file @
3bfb1407
...
...
@@ -37,12 +37,12 @@
<properties>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>
4.5.4.08.11.2017
</monticore.version>
<se-commons.version>
1.7.
7
</se-commons.version>
<monticore.version>
5.0.0
</monticore.version>
<se-commons.version>
1.7.
8
</se-commons.version>
<mc.grammars.assembly.version>
0.0.6
</mc.grammars.assembly.version>
<SIUnit.version>
0.0.1
0-SNAPSHOT
</SIUnit.version>
<Common-MontiCar.version>
0.0.1
2
</Common-MontiCar.version>
<Math.version>
0.0.1
1
</Math.version>
<SIUnit.version>
0.0.1
1
</SIUnit.version>
<Common-MontiCar.version>
0.0.1
4-SNAPSHOT
</Common-MontiCar.version>
<Math.version>
0.0.1
9-SNAPSHOT
</Math.version>
<!-- .. Libraries .................................................. -->
<guava.version>
18.0
</guava.version>
...
...
@@ -52,7 +52,7 @@
<commons-cli.version>
1.4
</commons-cli.version>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>
4.5.3.1
</monticore.plugin>
<monticore.plugin>
5.0.0
</monticore.plugin>
<assembly.plugin>
2.5.4
</assembly.plugin>
<compiler.plugin>
3.3
</compiler.plugin>
<source.plugin>
2.4
</source.plugin>
...
...
settings.xml
View file @
3bfb1407
<?xml version="1.0" encoding="UTF-8"?>
<!--
******************************************************************************
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/>.
*******************************************************************************
-->
<settings
xmlns=
"http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
...
...
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
View file @
3bfb1407
package
de
.
monticore
.
lang
.
monticar
;
grammar
CNNArch
extends
de
.
monticore
.
lang
.
math
.
Math
{
grammar
CNNArch
extends
de
.
monticore
.
lang
.
Math
,
de
.
monticore
.
lang
.
monticar
.
Common2
,
de
.
monticore
.
CommonExpressions
,
de
.
monticore
.
SetExpressions
{
token
NEWLINETOKEN
=
(
'\r'
'\n'
|
...
...
@@ -113,12 +114,12 @@ grammar CNNArch extends de.monticore.lang.math.Math {
/**
Expressions
for
variable
values
.
*/
ArchSimpleExpression
=
(
arithmeticExpression
:
MathArithmetic
Expression
|
booleanExpression
:
MathBoolean
Expression
ArchSimpleExpression
=
(
arithmeticExpression
:
Expression
|
booleanExpression
:
Expression
|
tupleExpression
:
TupleExpression
|
string
:
StringLiteral
);
TupleExpression
=
"("
expressions
:
MathArithmetic
Expression
","
expressions
:(
MathArithmetic
Expression
||
","
)*
")"
;
TupleExpression
=
"("
expressions
:
Expression
","
expressions
:(
Expression
||
","
)*
")"
;
/*
=================================*/
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTArchSpecialArgument.java
View file @
3bfb1407
...
...
@@ -23,25 +23,26 @@ package de.monticore.lang.monticar.cnnarch._ast;
import
de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables
;
import
java.util.List
;
import
java.util.Optional
;
public
class
ASTArchSpecialArgument
extends
ASTArchSpecialArgumentTOP
{
public
ASTArchSpecialArgument
()
{
}
public
ASTArchSpecialArgument
(
ASTArchExpression
rhs
,
List
<
String
>
nEWLINETOKENs
,
String
serial
,
String
parallel
,
String
conditional
)
{
public
ASTArchSpecialArgument
(
ASTArchExpression
rhs
,
List
<
String
>
nEWLINETOKENs
,
Optional
<
String
>
serial
,
Optional
<
String
>
parallel
,
Optional
<
String
>
conditional
)
{
super
(
rhs
,
nEWLINETOKENs
,
serial
,
parallel
,
conditional
);
}
@Override
public
String
getName
()
{
if
(
ge
tParallel
()
.
isPresent
()
){
if
(
isPresen
tParallel
()){
return
AllPredefinedVariables
.
PARALLEL_ARG_NAME
;
}
else
if
(
getSerial
().
isPresent
())
{
else
if
(
isPresent
Serial
())
{
return
AllPredefinedVariables
.
SERIAL_ARG_NAME
;
}
else
if
(
ge
tConditional
()
.
isPresent
()
){
else
if
(
isPresen
tConditional
()){
return
AllPredefinedVariables
.
CONDITIONAL_ARG_NAME
;
}
else
{
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CNNArchSymbolCoCo.java
View file @
3bfb1407
...
...
@@ -20,7 +20,7 @@
*/
package
de.monticore.lang.monticar.cnnarch._cocos
;
import
de.monticore.lang.math.
math.
_symboltable.expression.MathExpressionSymbol
;
import
de.monticore.lang.math._symboltable.expression.MathExpressionSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.*
;
import
de.monticore.symboltable.Symbol
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckExpressions.java
View file @
3bfb1407
...
...
@@ -20,8 +20,8 @@
*/
package
de.monticore.lang.monticar.cnnarch._cocos
;
import
de.monticore.lang.math.
math.
_symboltable.expression.MathExpressionSymbol
;
import
de.monticore.lang.math.
math.
_symboltable.expression.MathNameExpressionSymbol
;
import
de.monticore.lang.math._symboltable.expression.MathExpressionSymbol
;
import
de.monticore.lang.math._symboltable.expression.MathNameExpressionSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchExpressionSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol
;
import
de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckIOType.java
View file @
3bfb1407
...
...
@@ -41,7 +41,7 @@ public class CheckIOType extends CNNArchSymbolCoCo {
public
void
checkIO
(
IODeclarationSymbol
ioDeclaration
)
{
ArchTypeSymbol
type
=
ioDeclaration
.
getType
();
if
(
type
.
getDomain
().
is
Is
Complex
()
||
type
.
getDomain
().
is
Is
Boolean
()){
if
(
type
.
getDomain
().
isComplex
()
||
type
.
getDomain
().
isBoolean
()){
Log
.
error
(
"0"
+
ErrorCodes
.
INVALID_IO_TYPE
+
" Invalid IO element type. "
+
"Type has to be rational or whole number."
);
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckLayer.java
View file @
3bfb1407
...
...
@@ -38,7 +38,7 @@ public class CheckLayer implements CNNArchASTLayerCoCo{
@Override
public
void
check
(
ASTLayer
node
)
{
Set
<
String
>
nameSet
=
new
HashSet
<>();
for
(
ASTArchArgument
argument
:
node
.
getArguments
()){
for
(
ASTArchArgument
argument
:
node
.
getArguments
List
()){
String
name
=
argument
.
getName
();
if
(
nameSet
.
contains
(
name
)){
Log
.
error
(
"0"
+
ErrorCodes
.
DUPLICATED_ARG
+
" Duplicated name: "
+
name
+
...
...
@@ -65,7 +65,7 @@ public class CheckLayer implements CNNArchASTLayerCoCo{
requiredArguments
.
add
(
param
.
getName
());
}
}
for
(
ASTArchArgument
argument
:
node
.
getArguments
()){
for
(
ASTArchArgument
argument
:
node
.
getArguments
List
()){
requiredArguments
.
remove
(
argument
.
getName
());
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckRangeOperators.java
View file @
3bfb1407
...
...
@@ -28,13 +28,13 @@ public class CheckRangeOperators implements CNNArchASTArchValueRangeCoCo {
@Override
public
void
check
(
ASTArchValueRange
node
)
{
if
(
node
.
ge
tParallel
()
.
isPresent
()
){
if
(!
node
.
ge
tParallel2
()
.
isPresent
()
){
if
(
node
.
isPresen
tParallel
()){
if
(!
node
.
isPresen
tParallel2
()){
differentOperatorError
(
node
);
}
}
else
{
if
(
node
.
ge
tParallel2
()
.
isPresent
()
){
if
(
node
.
isPresen
tParallel2
()){
differentOperatorError
(
node
);
}
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArchSimpleExpressionSymbol.java
View file @
3bfb1407
...
...
@@ -20,7 +20,7 @@
*/
package
de.monticore.lang.monticar.cnnarch._symboltable
;
import
de.monticore.lang.math.
math.
_symboltable.expression.*
;
import
de.monticore.lang.math._symboltable.expression.*
;
import
de.monticore.lang.monticar.cnnarch.helper.Calculator
;
import
de.monticore.lang.monticar.cnnarch.helper.Utils
;
import
de.monticore.symboltable.Scope
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArchTypeSymbol.java
View file @
3bfb1407
...
...
@@ -45,7 +45,7 @@ public class ArchTypeSymbol extends CommonSymbol {
public
ArchTypeSymbol
()
{
super
(
""
,
KIND
);
ASTElementType
elementType
=
new
ASTElementType
();
elementType
.
set
TElementTyp
e
(
DEFAULT_ELEMENT_TYPE
);
elementType
.
set
Nam
e
(
DEFAULT_ELEMENT_TYPE
);
setDomain
(
elementType
);
}
...
...
@@ -244,7 +244,7 @@ public class ArchTypeSymbol extends CommonSymbol {
}
public
Builder
elementType
(
String
start
,
String
end
){
domain
=
new
ASTElementType
();
domain
.
set
TElementTyp
e
(
"Q("
+
start
+
":"
+
end
+
")"
);
domain
.
set
Nam
e
(
"Q("
+
start
+
":"
+
end
+
")"
);
return
this
;
}
...
...
@@ -257,7 +257,7 @@ public class ArchTypeSymbol extends CommonSymbol {
if
(
domain
==
null
){
domain
=
new
ASTElementType
();
domain
.
set
TElementTyp
e
(
DEFAULT_ELEMENT_TYPE
);
domain
.
set
Nam
e
(
DEFAULT_ELEMENT_TYPE
);
}
sym
.
setDomain
(
domain
);
return
sym
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/CNNArchSymbolTableCreator.java
View file @
3bfb1407
...
...
@@ -21,13 +21,13 @@
package
de.monticore.lang.monticar.cnnarch._symboltable
;
import
de.monticore.
lang.math.math
._ast.AST
Math
Expression
;
import
de.monticore.lang.math.
math.
_symboltable.MathSymbolTableCreator
;
import
de.monticore.lang.math.
math.
_symboltable.expression.MathExpressionSymbol
;
import
de.monticore.
expressionsbasis
._ast.ASTExpression
;
import
de.monticore.lang.math._symboltable.MathSymbolTableCreator
;
import
de.monticore.lang.math._symboltable.expression.MathExpressionSymbol
;
import
de.monticore.lang.monticar.cnnarch._ast.*
;
import
de.monticore.lang.monticar.cnnarch._visitor.CNNArchInheritanceVisitor
;
import
de.monticore.lang.monticar.cnnarch._visitor.CNNArchVisitor
;
import
de.monticore.lang.monticar.cnnarch._visitor.
Common
CNNArchDelegatorVisitor
;
import
de.monticore.lang.monticar.cnnarch._visitor.CNNArchDelegatorVisitor
;
import
de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedLayers
;
import
de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables
;
import
de.monticore.symboltable.*
;
...
...
@@ -58,9 +58,9 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
private
void
initSuperSTC
(
final
ResolvingConfiguration
resolvingConfig
)
{
this
.
mathSTC
=
new
ModifiedMathSymbolTableCreator
(
resolvingConfig
,
scopeStack
);
Common
CNNArchDelegatorVisitor
visitor
=
new
Common
CNNArchDelegatorVisitor
();
visitor
.
set
_de_monticore_lang_monticar_cnnarch__visitor_
CNNArchVisitor
(
this
);
visitor
.
set
_de_monticore_lang_math_math__visitor_
MathVisitor
(
mathSTC
);
CNNArchDelegatorVisitor
visitor
=
new
CNNArchDelegatorVisitor
();
visitor
.
setCNNArchVisitor
(
this
);
visitor
.
setMathVisitor
(
mathSTC
);
setRealThis
(
visitor
);
}
...
...
@@ -116,18 +116,18 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTCNNArchCompilationUnit
ast
)
{
CNNArchCompilationUnitSymbol
compilationUnitSymbol
=
(
CNNArchCompilationUnitSymbol
)
ast
.
getSymbol
().
get
();
compilationUnitSymbol
.
setArchitecture
((
ArchitectureSymbol
)
ast
.
getArchitecture
().
getSymbol
().
get
());
CNNArchCompilationUnitSymbol
compilationUnitSymbol
=
(
CNNArchCompilationUnitSymbol
)
ast
.
getSymbol
Opt
().
get
();
compilationUnitSymbol
.
setArchitecture
((
ArchitectureSymbol
)
ast
.
getArchitecture
().
getSymbol
Opt
().
get
());
List
<
VariableSymbol
>
parameters
=
new
ArrayList
<>(
ast
.
getArchitectureParameter
s
().
size
());
for
(
ASTArchitectureParameter
astParameter
:
ast
.
getArchitectureParameter
s
()){
parameters
.
add
((
VariableSymbol
)
astParameter
.
getSymbol
().
get
());
List
<
VariableSymbol
>
parameters
=
new
ArrayList
<>(
ast
.
getArchitectureParameter
List
().
size
());
for
(
ASTArchitectureParameter
astParameter
:
ast
.
getArchitectureParameter
List
()){
parameters
.
add
((
VariableSymbol
)
astParameter
.
getSymbol
Opt
().
get
());
}
compilationUnitSymbol
.
setParameters
(
parameters
);
List
<
IODeclarationSymbol
>
ioDeclarations
=
new
ArrayList
<>();
for
(
ASTIODeclaration
astIODeclaration
:
ast
.
getIoDeclarations
()){
ioDeclarations
.
add
((
IODeclarationSymbol
)
astIODeclaration
.
getSymbol
().
get
());
for
(
ASTIODeclaration
astIODeclaration
:
ast
.
getIoDeclarations
List
()){
ioDeclarations
.
add
((
IODeclarationSymbol
)
astIODeclaration
.
getSymbol
Opt
().
get
());
}
compilationUnitSymbol
.
setIoDeclarations
(
ioDeclarations
);
...
...
@@ -145,7 +145,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
public
void
endVisit
(
final
ASTArchitecture
node
)
{
//ArchitectureSymbol architecture = (ArchitectureSymbol) node.getSymbol().get();
architecture
.
setBody
((
ArchitectureElementSymbol
)
node
.
getBody
().
getSymbol
().
get
());
architecture
.
setBody
((
ArchitectureElementSymbol
)
node
.
getBody
().
getSymbol
Opt
().
get
());
removeCurrentScope
();
}
...
...
@@ -165,8 +165,8 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
public
void
endVisit
(
ASTArchitectureParameter
node
)
{
VariableSymbol
variable
=
new
VariableSymbol
(
node
.
getName
());
variable
.
setType
(
VariableType
.
ARCHITECTURE_PARAMETER
);
if
(
node
.
getDefault
().
isPresent
()){
variable
.
setDefaultExpression
((
ArchSimpleExpressionSymbol
)
node
.
getDefault
().
get
().
getSymbol
().
get
());
if
(
node
.
isPresent
Default
()){
variable
.
setDefaultExpression
((
ArchSimpleExpressionSymbol
)
node
.
getDefault
().
getSymbol
Opt
().
get
());
}
addToScopeAndLinkWithNode
(
variable
,
node
);
...
...
@@ -180,12 +180,12 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTIODeclaration
ast
)
{
IODeclarationSymbol
iODeclaration
=
(
IODeclarationSymbol
)
ast
.
getSymbol
().
get
();
if
(
ast
.
ge
tArrayDeclaration
()
.
isPresent
()
){
iODeclaration
.
setArrayLength
(
ast
.
getArrayDeclaration
().
get
().
getIntLiteral
().
getNumber
().
get
().
getDividend
().
intValue
());
IODeclarationSymbol
iODeclaration
=
(
IODeclarationSymbol
)
ast
.
getSymbol
Opt
().
get
();
if
(
ast
.
isPresen
tArrayDeclaration
()){
iODeclaration
.
setArrayLength
(
ast
.
getArrayDeclaration
().
getIntLiteral
().
getNumber
().
get
().
intValue
());
}
iODeclaration
.
setInput
(
ast
.
getIn
().
isPresent
());
iODeclaration
.
setType
((
ArchTypeSymbol
)
ast
.
getType
().
getSymbol
().
get
());
iODeclaration
.
setInput
(
ast
.
isPresent
In
());
iODeclaration
.
setType
((
ArchTypeSymbol
)
ast
.
getType
().
getSymbol
Opt
().
get
());
}
@Override
...
...
@@ -196,8 +196,8 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArchType
node
)
{
ArchTypeSymbol
sym
=
(
ArchTypeSymbol
)
node
.
getSymbol
().
get
();
List
<
ASTArchSimpleExpression
>
astDimensions
=
node
.
getShape
().
getDimensions
();
ArchTypeSymbol
sym
=
(
ArchTypeSymbol
)
node
.
getSymbol
Opt
().
get
();
List
<
ASTArchSimpleExpression
>
astDimensions
=
node
.
getShape
().
getDimensions
List
();
if
(
astDimensions
.
size
()
>=
1
){
sym
.
setChannelIndex
(
0
);
...
...
@@ -210,7 +210,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
}
List
<
ArchSimpleExpressionSymbol
>
dimensionList
=
new
ArrayList
<>(
3
);
for
(
ASTArchSimpleExpression
astExp
:
astDimensions
){
dimensionList
.
add
((
ArchSimpleExpressionSymbol
)
astExp
.
getSymbol
().
get
());
dimensionList
.
add
((
ArchSimpleExpressionSymbol
)
astExp
.
getSymbol
Opt
().
get
());
}
sym
.
setDimensionSymbols
(
dimensionList
);
sym
.
setDomain
(
node
.
getElementType
());
...
...
@@ -225,11 +225,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTLayerDeclaration
ast
)
{
LayerDeclarationSymbol
layerDeclaration
=
(
LayerDeclarationSymbol
)
ast
.
getSymbol
().
get
();
layerDeclaration
.
setBody
((
CompositeElementSymbol
)
ast
.
getBody
().
getSymbol
().
get
());
layerDeclaration
.
setBody
((
CompositeElementSymbol
)
ast
.
getBody
().
getSymbol
Opt
().
get
());
List
<
VariableSymbol
>
parameters
=
new
ArrayList
<>(
4
);
for
(
ASTLayerParameter
astParam
:
ast
.
getParameters
()){
VariableSymbol
parameter
=
(
VariableSymbol
)
astParam
.
getSymbol
().
get
();
for
(
ASTLayerParameter
astParam
:
ast
.
getParameters
List
()){
VariableSymbol
parameter
=
(
VariableSymbol
)
astParam
.
getSymbol
Opt
().
get
();
parameters
.
add
(
parameter
);
}
layerDeclaration
.
setParameters
(
parameters
);
...
...
@@ -246,9 +246,9 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTLayerParameter
ast
)
{
VariableSymbol
variable
=
(
VariableSymbol
)
ast
.
getSymbol
().
get
();
if
(
ast
.
getDefault
().
isPresent
()){
variable
.
setDefaultExpression
((
ArchSimpleExpressionSymbol
)
ast
.
getDefault
().
get
().
getSymbol
().
get
());
VariableSymbol
variable
=
(
VariableSymbol
)
ast
.
getSymbol
Opt
().
get
();
if
(
ast
.
isPresent
Default
()){
variable
.
setDefaultExpression
((
ArchSimpleExpressionSymbol
)
ast
.
getDefault
().
getSymbol
Opt
().
get
());
}
}
...
...
@@ -256,17 +256,20 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
public
void
endVisit
(
ASTArchSimpleExpression
ast
)
{
ArchSimpleExpressionSymbol
sym
=
new
ArchSimpleExpressionSymbol
();
MathExpressionSymbol
mathExp
=
null
;
if
(
ast
.
getArithmeticExpression
().
isPresent
())
{
mathExp
=
(
MathExpressionSymbol
)
ast
.
getArithmeticExpression
().
get
().
getSymbol
().
get
();
if
(
ast
.
isPresentArithmeticExpression
())
{
ASTExpression
arithmeticExpression
=
ast
.
getArithmeticExpression
();
if
(
arithmeticExpression
.
isPresentSymbol
())
{
mathExp
=
(
MathExpressionSymbol
)
arithmeticExpression
.
getSymbol
().
get
();
}
}
else
if
(
ast
.
ge
tBooleanExpression
()
.
isPresent
()
)
{
mathExp
=
(
MathExpressionSymbol
)
ast
.
getBooleanExpression
().
get
().
getSymbol
().
get
();
else
if
(
ast
.
isPresen
tBooleanExpression
())
{
mathExp
=
(
MathExpressionSymbol
)
ast
.
getBooleanExpression
().
getSymbol
Opt
().
get
();
}
else
if
(
ast
.
ge
tTupleExpression
()
.
isPresent
()
){
mathExp
=
(
MathExpressionSymbol
)
ast
.
getTupleExpression
().
get
().
getSymbol
().
get
();
else
if
(
ast
.
isPresen
tTupleExpression
()){
mathExp
=
(
MathExpressionSymbol
)
ast
.
getTupleExpression
().
getSymbol
Opt
().
get
();
}
else
{
sym
.
setValue
(
ast
.
getString
().
get
().
getValue
());
sym
.
setValue
(
ast
.
getString
().
getValue
());
}
sym
.
setMathExpression
(
mathExp
);
addToScopeAndLinkWithNode
(
sym
,
ast
);
...
...
@@ -274,11 +277,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArchExpression
node
)
{
if
(
node
.
ge
tExpression
()
.
isPresent
()
){
addToScopeAndLinkWithNode
(
node
.
getExpression
().
get
().
getSymbol
().
get
(),
node
);
if
(
node
.
isPresen
tExpression
()){
addToScopeAndLinkWithNode
(
node
.
getExpression
().
getSymbol
Opt
().
get
(),
node
);
}
else
{
addToScopeAndLinkWithNode
(
node
.
getSequence
().
get
().
getSymbol
().
get
(),
node
);
addToScopeAndLinkWithNode
(
node
.
getSequence
().
getSymbol
Opt
().
get
(),
node
);
}
}
...
...
@@ -290,10 +293,10 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArchValueRange
node
)
{
ArchRangeExpressionSymbol
sym
=
(
ArchRangeExpressionSymbol
)
node
.
getSymbol
().
get
();
sym
.
setParallel
(
node
.
ge
tParallel
()
.
isPresent
()
);
sym
.
setStartSymbol
((
ArchSimpleExpressionSymbol
)
node
.
getStart
().
getSymbol
().
get
());
sym
.
setEndSymbol
((
ArchSimpleExpressionSymbol
)
node
.
getEnd
().
getSymbol
().
get
());
ArchRangeExpressionSymbol
sym
=
(
ArchRangeExpressionSymbol
)
node
.
getSymbol
Opt
().
get
();
sym
.
setParallel
(
node
.
isPresen
tParallel
());
sym
.
setStartSymbol
((
ArchSimpleExpressionSymbol
)
node
.
getStart
().
getSymbol
Opt
().
get
());
sym
.
setEndSymbol
((
ArchSimpleExpressionSymbol
)
node
.
getEnd
().
getSymbol
Opt
().
get
());
}
@Override
...
...
@@ -304,13 +307,13 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArchParallelSequence
node
)
{
ArchSequenceExpressionSymbol
sym
=
(
ArchSequenceExpressionSymbol
)
node
.
getSymbol
().
get
();
ArchSequenceExpressionSymbol
sym
=
(
ArchSequenceExpressionSymbol
)
node
.
getSymbol
Opt
().
get
();
List
<
List
<
ArchSimpleExpressionSymbol
>>
elements
=
new
ArrayList
<>();
for
(
ASTArchSerialSequence
serialSequenceAST
:
node
.
getParallelValues
())
{
for
(
ASTArchSerialSequence
serialSequenceAST
:
node
.
getParallelValues
List
())
{
List
<
ArchSimpleExpressionSymbol
>
serialElements
=
new
ArrayList
<>();
for
(
ASTArchSimpleExpression
astExpression
:
serialSequenceAST
.
getSerialValues
())
{
serialElements
.
add
((
ArchSimpleExpressionSymbol
)
astExpression
.
getSymbol
().
get
());
for
(
ASTArchSimpleExpression
astExpression
:
serialSequenceAST
.
getSerialValues
List
())
{
serialElements
.
add
((
ArchSimpleExpressionSymbol
)
astExpression
.
getSymbol
Opt
().
get
());
}
elements
.
add
(
serialElements
);
}
...
...
@@ -326,11 +329,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTParallelBlock
node
)
{
CompositeElementSymbol
compositeElement
=
(
CompositeElementSymbol
)
node
.
getSymbol
().
get
();
CompositeElementSymbol
compositeElement
=
(
CompositeElementSymbol
)
node
.
getSymbol
Opt
().
get
();
List
<
ArchitectureElementSymbol
>
elements
=
new
ArrayList
<>();
for
(
ASTArchBody
astBody
:
node
.
getGroups
()){
elements
.
add
((
CompositeElementSymbol
)
astBody
.
getSymbol
().
get
());
for
(
ASTArchBody
astBody
:
node
.
getGroups
List
()){
elements
.
add
((
CompositeElementSymbol
)
astBody
.
getSymbol
Opt
().
get
());
}
compositeElement
.
setElements
(
elements
);
...
...
@@ -346,11 +349,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArchBody
ast
)
{
CompositeElementSymbol
compositeElement
=
(
CompositeElementSymbol
)
ast
.
getSymbol
().
get
();
CompositeElementSymbol
compositeElement
=
(
CompositeElementSymbol
)
ast
.
getSymbol
Opt
().
get
();
List
<
ArchitectureElementSymbol
>
elements
=
new
ArrayList
<>();
for
(
ASTArchitectureElement
astElement
:
ast
.
getElements
()){
elements
.
add
((
ArchitectureElementSymbol
)
astElement
.
getSymbol
().
get
());
for
(
ASTArchitectureElement
astElement
:
ast
.
getElements
List
()){
elements
.
add
((
ArchitectureElementSymbol
)
astElement
.
getSymbol
Opt
().
get
());
}
compositeElement
.
setElements
(
elements
);
...
...
@@ -365,11 +368,11 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTLayer
ast
)
{
LayerSymbol
layer
=
(
LayerSymbol
)
ast
.
getSymbol
().
get
();
LayerSymbol
layer
=
(
LayerSymbol
)
ast
.
getSymbol
Opt
().
get
();
List
<
ArgumentSymbol
>
arguments
=
new
ArrayList
<>(
6
);
for
(
ASTArchArgument
astArgument
:
ast
.
getArguments
()){
Optional
<
ArgumentSymbol
>
optArgument
=
astArgument
.
getSymbol
().
map
(
e
->
(
ArgumentSymbol
)
e
);
for
(
ASTArchArgument
astArgument
:
ast
.
getArguments
List
()){
Optional
<
ArgumentSymbol
>
optArgument
=
astArgument
.
getSymbol
Opt
().
map
(
e
->
(
ArgumentSymbol
)
e
);
optArgument
.
ifPresent
(
arguments:
:
add
);
}
layer
.
setArguments
(
arguments
);
...
...
@@ -380,7 +383,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArchArgument
node
)
{
ArchExpressionSymbol
value
;
value
=
(
ArchExpressionSymbol
)
node
.
getRhs
().
getSymbol
().
get
();
value
=
(
ArchExpressionSymbol
)
node
.
getRhs
().
getSymbol
Opt
().
get
();
ArgumentSymbol
argument
=
new
ArgumentSymbol
(
node
.
getName
());
argument
.
setRhs
(
value
);
...
...
@@ -394,9 +397,9 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTIOElement
node
)
{
IOSymbol
sym
=
(
IOSymbol
)
node
.
getSymbol
().
get
();
if
(
node
.
getIndex
().
isPresent
()){
sym
.
setArrayAccess
((
ArchSimpleExpressionSymbol
)
node
.
getIndex
().
get
().
getSymbol
().
get
());
IOSymbol
sym
=
(
IOSymbol
)
node
.
getSymbol
Opt
().
get
();
if
(
node
.
isPresent
Index
()){
sym
.
setArrayAccess
((
ArchSimpleExpressionSymbol
)
node
.
getIndex
().
getSymbol
Opt
().
get
());
}
removeCurrentScope
();
}
...
...
@@ -409,10 +412,10 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public
void
endVisit
(
ASTArrayAccessLayer
node
)
{
LayerSymbol
layer
=
(
LayerSymbol
)
node
.
getSymbol
().
get
();
LayerSymbol
layer
=
(
LayerSymbol
)
node
.
getSymbol
Opt
().
get
();
ArgumentSymbol
indexArgument
=
new
ArgumentSymbol
.
Builder
()
.
parameter
(
layer
.
getDeclaration
().
getParameter
(
AllPredefinedLayers
.
INDEX_NAME
).
get
())
.
value
((
ArchSimpleExpressionSymbol
)
node
.
getIndex
().
getSymbol
().
get
())
.
value
((
ArchSimpleExpressionSymbol
)
node
.
getIndex
().
getSymbol
Opt
().
get
())
.
build
();
indexArgument
.
setAstNode
(
node
.
getIndex
());
addToScope
(
indexArgument
);
...
...
@@ -425,8 +428,10 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
public
void
endVisit
(
ASTTupleExpression
node
)
{
TupleExpressionSymbol
symbol
=
new
TupleExpressionSymbol
();
for
(
ASTMathExpression
expression
:
node
.
getExpressions
()){
symbol
.
add
((
MathExpressionSymbol
)
expression
.
getSymbol
().
get
());
for
(
ASTExpression
expression
:
node
.
getExpressionsList
()){
if
(
expression
.
isPresentSymbol
())
{
symbol
.
add
((
MathExpressionSymbol
)
expression
.
getSymbolOpt
().
get
());
}
}
addToScopeAndLinkWithNode
(
symbol
,
node
);
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/IOSymbol.java
View file @
3bfb1407
...
...
@@ -228,8 +228,8 @@ public class IOSymbol extends ArchitectureElementSymbol {
if
(!
Utils
.
equals
(
inputType
,
getDefinition
().
getType
().
getDomain
()))
{
Log
.
error
(
"0"
+
ErrorCodes
.
INVALID_ELEMENT_INPUT_DOMAIN
+
" "
+
"The declared output type of '"
+
name
+
"' does not match with the actual type. "
+
"Declared type: "
+
getDefinition
().
getType
().
getDomain
().
get
TElementType
().
get
()
+
". "
+
"Actual type: "
+
inputType
.
get
TElementType
().
get
()
+
"."
);
"Declared type: "
+
getDefinition
().
getType
().
getDomain
().
get
Name
()
+
". "
+
"Actual type: "
+
inputType
.
get
Name
()
+
"."
);
}
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ModifiedMathSymbolTableCreator.java