Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArchLang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
languages
CNNArchLang
Commits
ad995430
Commit
ad995430
authored
Feb 12, 2018
by
Thomas Michael Timmermanns
Committed by
Thomas Michael Timmermanns
Feb 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
165b3f66
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
33 additions
and
42 deletions
+33
-42
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTArchSpecialArgument.java
...re/lang/monticar/cnnarch/_ast/ASTArchSpecialArgument.java
+3
-3
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckVariableName.java
...icore/lang/monticar/cnnarch/_cocos/CheckVariableName.java
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArgumentSymbol.java
...re/lang/monticar/cnnarch/_symboltable/ArgumentSymbol.java
+3
-3
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/Constraints.java
...icore/lang/monticar/cnnarch/_symboltable/Constraints.java
+1
-14
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/LayerSymbol.java
...icore/lang/monticar/cnnarch/_symboltable/LayerSymbol.java
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/MethodDeclarationSymbol.java
...onticar/cnnarch/_symboltable/MethodDeclarationSymbol.java
+3
-7
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/MethodLayerSymbol.java
...lang/monticar/cnnarch/_symboltable/MethodLayerSymbol.java
+1
-1
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ModifiedMathSymbolTableCreator.java
.../cnnarch/_symboltable/ModifiedMathSymbolTableCreator.java
+0
-1
src/main/java/de/monticore/lang/monticar/cnnarch/helper/Utils.java
...java/de/monticore/lang/monticar/cnnarch/helper/Utils.java
+13
-4
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/AllPredefinedVariables.java
...g/monticar/cnnarch/predefined/AllPredefinedVariables.java
+6
-6
No files found.
src/main/grammars/de/monticore/lang/monticar/CNNArch.mc4
View file @
ad995430
...
...
@@ -61,7 +61,7 @@ grammar CNNArch extends de.monticore.lang.math.Math {
ArchExpression
=
(
expression
:
ArchSimpleExpression
|
sequence
:
ArchValueSequence
);
interface
ArchValueSequence
;
interface
ArchValueSequence
;
ArchParallelSequence
implements
ArchValueSequence
=
"["
parallelValues
:(
ArchSerialSequence
||
"|"
)*
"]"
;
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_ast/ASTArchSpecialArgument.java
View file @
ad995430
...
...
@@ -34,13 +34,13 @@ public class ASTArchSpecialArgument extends ASTArchSpecialArgumentTOP {
@Override
public
String
getName
()
{
if
(
getParallel
().
isPresent
()){
return
AllPredefinedVariables
.
CARDINALITY
_NAME
;
return
AllPredefinedVariables
.
PARALLEL_ARG
_NAME
;
}
else
if
(
getSerial
().
isPresent
())
{
return
AllPredefinedVariables
.
FOR
_NAME
;
return
AllPredefinedVariables
.
SERIAL_ARG
_NAME
;
}
else
if
(
getConditional
().
isPresent
()){
return
AllPredefinedVariables
.
IF
_NAME
;
return
AllPredefinedVariables
.
CONDITIONAL_ARG
_NAME
;
}
else
{
throw
new
IllegalStateException
();
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_cocos/CheckVariableName.java
View file @
ad995430
...
...
@@ -54,7 +54,7 @@ public class CheckVariableName implements CNNArchASTVariableCoCo {
". No variable can be named 'true' or 'false'"
,
node
.
get_SourcePositionStart
());
}
else
if
(
name
.
equals
(
AllPredefinedVariables
.
IF
_NAME
.
toLowerCase
())){
else
if
(
name
.
equals
(
AllPredefinedVariables
.
CONDITIONAL_ARG
_NAME
.
toLowerCase
())){
Log
.
error
(
"0"
+
ErrorCodes
.
ILLEGAL_NAME
+
" Illegal name: "
+
name
+
". No variable can be named 'if'"
,
node
.
get_SourcePositionStart
());
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ArgumentSymbol.java
View file @
ad995430
...
...
@@ -62,7 +62,7 @@ public class ArgumentSymbol extends CommonSymbol {
}
protected
void
setRhs
(
ArchExpressionSymbol
rhs
)
{
if
(
getName
().
equals
(
AllPredefinedVariables
.
FOR
_NAME
)
if
(
getName
().
equals
(
AllPredefinedVariables
.
SERIAL_ARG
_NAME
)
&&
rhs
instanceof
ArchSimpleExpressionSymbol
&&
(!
rhs
.
getValue
().
isPresent
()
||
!
rhs
.
getValue
().
get
().
equals
(
1
))){
this
.
rhs
=
ArchRangeExpressionSymbol
.
of
(
...
...
@@ -70,7 +70,7 @@ public class ArgumentSymbol extends CommonSymbol {
(
ArchSimpleExpressionSymbol
)
rhs
,
false
);
}
else
if
(
getName
().
equals
(
AllPredefinedVariables
.
CARDINALITY
_NAME
)
else
if
(
getName
().
equals
(
AllPredefinedVariables
.
PARALLEL_ARG
_NAME
)
&&
rhs
instanceof
ArchSimpleExpressionSymbol
&&
(!
rhs
.
getValue
().
isPresent
()
||
!
rhs
.
getValue
().
get
().
equals
(
1
)))
{
this
.
rhs
=
ArchRangeExpressionSymbol
.
of
(
...
...
@@ -116,7 +116,7 @@ public class ArgumentSymbol extends CommonSymbol {
List
<
ArgumentSymbol
>
serialArgumentList
=
new
ArrayList
<>(
serialElementList
.
size
());
for
(
ArchSimpleExpressionSymbol
element
:
serialElementList
){
ArchSimpleExpressionSymbol
value
=
element
;
if
(
getName
().
equals
(
AllPredefinedVariables
.
FOR_NAME
)
||
getName
().
equals
(
AllPredefinedVariables
.
CARDINALITY
_NAME
)){
if
(
getName
().
equals
(
AllPredefinedVariables
.
SERIAL_ARG_NAME
)
||
getName
().
equals
(
AllPredefinedVariables
.
PARALLEL_ARG
_NAME
)){
value
=
ArchSimpleExpressionSymbol
.
of
(
1
);
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/Constraints.java
View file @
ad995430
...
...
@@ -160,7 +160,6 @@ public enum Constraints {
}
return
false
;
}
@Override
protected
String
msgString
()
{
return
AllPredefinedMethods
.
PADDING_VALID
+
", "
...
...
@@ -222,7 +221,7 @@ public enum Constraints {
for
(
List
<
ArchSimpleExpressionSymbol
>
expList
:
exp
.
getElements
().
get
())
{
for
(
ArchSimpleExpressionSymbol
singleExp
:
expList
)
{
if
(!
isValid
(
singleExp
))
{
Log
.
error
(
"0"
+
ILLEGAL_ASSIGNMENT
+
" Illegal assignment of '"
+
printName
(
name
)
+
"'. "
+
Log
.
error
(
"0"
+
ILLEGAL_ASSIGNMENT
+
" Illegal assignment of '"
+
name
+
"'. "
+
"Expression must be "
+
msgString
()
+
"."
,
sourcePosition
);
return
false
;
...
...
@@ -231,16 +230,4 @@ public enum Constraints {
}
return
true
;
}
private
String
printName
(
String
name
){
if
(
name
.
equals
(
AllPredefinedVariables
.
FOR_NAME
)){
return
"->"
;
}
else
if
(
name
.
equals
(
AllPredefinedVariables
.
CARDINALITY_NAME
)){
return
"|"
;
}
else
{
return
name
;
}
}
}
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/LayerSymbol.java
View file @
ad995430
...
...
@@ -211,7 +211,7 @@ public abstract class LayerSymbol extends CommonScopeSpanningSymbol {
}
/**
* deepCopy for LayerSymbols, ArgumentSymbol and ArchExpressionSymbols but does not copy math expressions
or scope and ast information
.
* deepCopy for LayerSymbols, ArgumentSymbol and ArchExpressionSymbols but does not copy math expressions.
* @return returns a copy of this object
*/
abstract
public
LayerSymbol
copy
();
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/MethodDeclarationSymbol.java
View file @
ad995430
...
...
@@ -26,12 +26,8 @@ package de.monticore.lang.monticar.cnnarch._symboltable;
import
de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables
;
import
de.monticore.symboltable.CommonScopeSpanningSymbol
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.function.BiConsumer
;
import
java.util.function.BiFunction
;
public
class
MethodDeclarationSymbol
extends
CommonScopeSpanningSymbol
{
...
...
@@ -61,17 +57,17 @@ public class MethodDeclarationSymbol extends CommonScopeSpanningSymbol {
protected
void
setParameters
(
List
<
VariableSymbol
>
parameters
)
{
this
.
parameters
=
parameters
;
if
(!
getParameter
(
AllPredefinedVariables
.
IF
_NAME
).
isPresent
()){
if
(!
getParameter
(
AllPredefinedVariables
.
CONDITIONAL_ARG
_NAME
).
isPresent
()){
VariableSymbol
ifParam
=
AllPredefinedVariables
.
createIfParameter
();
this
.
parameters
.
add
(
ifParam
);
ifParam
.
putInScope
(
getSpannedScope
());
}
if
(!
getParameter
(
AllPredefinedVariables
.
FOR
_NAME
).
isPresent
()){
if
(!
getParameter
(
AllPredefinedVariables
.
SERIAL_ARG
_NAME
).
isPresent
()){
VariableSymbol
forParam
=
AllPredefinedVariables
.
createForParameter
();
this
.
parameters
.
add
(
forParam
);
forParam
.
putInScope
(
getSpannedScope
());
}
if
(!
getParameter
(
AllPredefinedVariables
.
CARDINALITY
_NAME
).
isPresent
()){
if
(!
getParameter
(
AllPredefinedVariables
.
PARALLEL_ARG
_NAME
).
isPresent
()){
VariableSymbol
forParam
=
AllPredefinedVariables
.
createCardinalityParameter
();
this
.
parameters
.
add
(
forParam
);
forParam
.
putInScope
(
getSpannedScope
());
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/MethodLayerSymbol.java
View file @
ad995430
...
...
@@ -68,7 +68,7 @@ public class MethodLayerSymbol extends LayerSymbol {
}
public
ArchExpressionSymbol
getIfExpression
(){
Optional
<
ArgumentSymbol
>
argument
=
getArgument
(
AllPredefinedVariables
.
IF
_NAME
);
Optional
<
ArgumentSymbol
>
argument
=
getArgument
(
AllPredefinedVariables
.
CONDITIONAL_ARG
_NAME
);
if
(
argument
.
isPresent
()){
return
argument
.
get
().
getRhs
();
}
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/_symboltable/ModifiedMathSymbolTableCreator.java
View file @
ad995430
...
...
@@ -31,7 +31,6 @@ import de.monticore.symboltable.ResolvingConfiguration;
import
java.util.Deque
;
public
class
ModifiedMathSymbolTableCreator
extends
MathSymbolTableCreator
{
//todo: remove this class if MontiMath is fixed
public
ModifiedMathSymbolTableCreator
(
ResolvingConfiguration
resolverConfiguration
,
MutableScope
enclosingScope
)
{
super
(
resolverConfiguration
,
enclosingScope
);
...
...
src/main/java/de/monticore/lang/monticar/cnnarch/helper/Utils.java
View file @
ad995430
...
...
@@ -96,9 +96,6 @@ public class Utils {
public
static
boolean
equals
(
ASTElementType
firstType
,
ASTElementType
secondType
){
ASTRange
firstRange
=
firstType
.
getRange
().
get
();
ASTRange
secondRange
=
secondType
.
getRange
().
get
();
if
(
firstType
.
isIsBoolean
()
^
secondType
.
isIsBoolean
()
||
firstType
.
isIsNatural
()
^
secondType
.
isIsNatural
()
||
firstType
.
isIsRational
()
^
secondType
.
isIsRational
()
...
...
@@ -106,6 +103,19 @@ public class Utils {
||
firstType
.
isIsComplex
()
^
secondType
.
isIsComplex
()){
return
false
;
}
if
(
firstType
.
getRange
().
isPresent
()){
if
(!
secondType
.
getRange
().
isPresent
()){
return
false
;
}
}
else
{
return
!
secondType
.
getRange
().
isPresent
();
}
return
equals
(
firstType
.
getRange
().
get
(),
secondType
.
getRange
().
get
());
}
public
static
boolean
equals
(
ASTRange
firstRange
,
ASTRange
secondRange
){
if
(
firstRange
.
getStartInf
().
isPresent
()
^
secondRange
.
getStartInf
().
isPresent
()
||
firstRange
.
getEndInf
().
isPresent
()
^
secondRange
.
getEndInf
().
isPresent
()){
return
false
;
...
...
@@ -125,5 +135,4 @@ public class Utils {
return
true
;
}
}
src/main/java/de/monticore/lang/monticar/cnnarch/predefined/AllPredefinedVariables.java
View file @
ad995430
...
...
@@ -26,15 +26,15 @@ import de.monticore.lang.monticar.cnnarch._symboltable.VariableType;
public
class
AllPredefinedVariables
{
public
static
final
String
IF
_NAME
=
"?"
;
public
static
final
String
FOR
_NAME
=
"->"
;
public
static
final
String
CARDINALITY
_NAME
=
"|"
;
public
static
final
String
CONDITIONAL_ARG
_NAME
=
"?"
;
public
static
final
String
SERIAL_ARG
_NAME
=
"->"
;
public
static
final
String
PARALLEL_ARG
_NAME
=
"|"
;
public
static
final
String
TRUE_NAME
=
"true"
;
public
static
final
String
FALSE_NAME
=
"false"
;
public
static
VariableSymbol
createIfParameter
(){
return
new
VariableSymbol
.
Builder
()
.
name
(
IF
_NAME
)
.
name
(
CONDITIONAL_ARG
_NAME
)
.
type
(
VariableType
.
METHOD_PARAMETER
)
.
constraints
(
Constraints
.
BOOLEAN
)
.
defaultValue
(
true
)
...
...
@@ -43,7 +43,7 @@ public class AllPredefinedVariables {
public
static
VariableSymbol
createForParameter
(){
return
new
VariableSymbol
.
Builder
()
.
name
(
FOR
_NAME
)
.
name
(
SERIAL_ARG
_NAME
)
.
type
(
VariableType
.
METHOD_PARAMETER
)
.
constraints
(
Constraints
.
INTEGER
,
Constraints
.
POSITIVE
)
.
defaultValue
(
1
)
...
...
@@ -52,7 +52,7 @@ public class AllPredefinedVariables {
public
static
VariableSymbol
createCardinalityParameter
(){
return
new
VariableSymbol
.
Builder
()
.
name
(
CARDINALITY
_NAME
)
.
name
(
PARALLEL_ARG
_NAME
)
.
type
(
VariableType
.
METHOD_PARAMETER
)
.
constraints
(
Constraints
.
INTEGER
,
Constraints
.
POSITIVE
)
.
defaultValue
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment