Commit 31c40ca4 authored by Thomas Michael Timmermanns's avatar Thomas Michael Timmermanns Committed by Thomas Michael Timmermanns

Added NEWLINETOKEN.

parent a5e00e92
......@@ -9,51 +9,51 @@ grammar CNNArch extends de.monticore.lang.math.Math {
Architecture
"}";
Architecture = methodDeclaration:MethodDeclaration*
body:ArchBody;
Architecture = NEWLINETOKEN* methodDeclaration:MethodDeclaration* NEWLINETOKEN*
body:ArchBody NEWLINETOKEN*;
interface ArchitectureElement;
interface Variable;
ast Variable = method String getName(){};
IODeclaration = "def"
IODeclaration = NEWLINETOKEN* "def"
(in:"input" | out:"output")
type:ArchType
Name&
(ArrayDeclaration)?;
(ArrayDeclaration)? NEWLINETOKEN*;
ArchType = ElementType "^" Shape;
Shape = "{" dimensions:(ArchSimpleExpression || ",")* "}";
ArchitectureParameter implements Variable = Name& ("=" default:ArchSimpleExpression)?;
ArchitectureParameter implements Variable = NEWLINETOKEN* Name& ("=" default:ArchSimpleExpression)? NEWLINETOKEN*;
MethodDeclaration = "def"
MethodDeclaration = NEWLINETOKEN* "def"
Name& "("
parameters:(MethodParameter || ",")* ")" "{"
body:ArchBody "}";
parameters:(MethodParameter || ",")* ")" "{" NEWLINETOKEN*
body:ArchBody NEWLINETOKEN* "}";
MethodParameter implements Variable = Name& ("=" default:ArchSimpleExpression)?;
MethodParameter implements Variable = NEWLINETOKEN* Name& ("=" default:ArchSimpleExpression)? NEWLINETOKEN*;
scope ArchBody = elements:(ArchitectureElement || "->")*;
IOLayer implements ArchitectureElement = Name& ("[" index:ArchSimpleExpression "]")?;
IOLayer implements ArchitectureElement = NEWLINETOKEN* Name& ("[" index:ArchSimpleExpression "]")?;
MethodLayer implements ArchitectureElement = Name& "(" arguments:(ArchArgument || ",")* ")";
MethodLayer implements ArchitectureElement = NEWLINETOKEN* Name& "(" arguments:(ArchArgument || ",")* ")";
interface ArchArgument;
ast ArchArgument = method String getName(){}
method ASTArchExpression getRhs(){};
ArchParameterArgument implements ArchArgument = Name "=" rhs:ArchExpression;
ArchParameterArgument implements ArchArgument = NEWLINETOKEN* Name "=" rhs:ArchExpression NEWLINETOKEN*;
ArchSpecialArgument implements ArchArgument = (serial:"->" | parallel:"|" | conditional:"?") "="
rhs:ArchExpression;
ArchSpecialArgument implements ArchArgument = NEWLINETOKEN* (serial:"->" | parallel:"|" | conditional:"?") "="
rhs:ArchExpression NEWLINETOKEN*;
ast ArchSpecialArgument = method public String getName(){return "";};
ParallelLayer implements ArchitectureElement = "(" groups:ArchBody "|" groups:(ArchBody || "|")+ ")";
ParallelLayer implements ArchitectureElement = NEWLINETOKEN* "(" NEWLINETOKEN* groups:ArchBody NEWLINETOKEN* "|" NEWLINETOKEN* groups:(ArchBody || "|")+ NEWLINETOKEN* ")";
ArrayAccessLayer implements ArchitectureElement = "[" index:ArchSimpleExpression "]";
ArrayAccessLayer implements ArchitectureElement = NEWLINETOKEN* "[" index:ArchSimpleExpression "]";
ArchExpression = (expression:ArchSimpleExpression | sequence:ArchValueSequence);
......@@ -78,4 +78,8 @@ grammar CNNArch extends de.monticore.lang.math.Math {
TupleExpression implements MathExpression = "(" expressions:MathExpression "," expressions:(MathExpression || ",")* ")";
token NEWLINETOKEN =
('\r' '\n' |
'\r' |
'\n' ):;
}
\ No newline at end of file
......@@ -22,13 +22,15 @@ package de.monticore.lang.monticar.cnnarch._ast;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
import java.util.List;
public class ASTArchSpecialArgument extends ASTArchSpecialArgumentTOP {
public ASTArchSpecialArgument() {
}
public ASTArchSpecialArgument(ASTArchExpression rhs, String serial, String parallel, String conditional) {
super(rhs, serial, parallel, conditional);
public ASTArchSpecialArgument(ASTArchExpression rhs, List<String> nEWLINETOKENs, String serial, String parallel, String conditional) {
super(rhs, nEWLINETOKENs, serial, parallel, conditional);
}
@Override
......
......@@ -21,7 +21,6 @@
package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchitecture;
import de.monticore.lang.monticar.cnnarch._ast.ASTIODeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.IODeclarationSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.IOLayerSymbol;
......
......@@ -23,14 +23,12 @@
package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.symboltable.CommonScopeSpanningSymbol;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ArchitectureSymbol extends CommonScopeSpanningSymbol {
......
......@@ -30,11 +30,8 @@ import de.monticore.lang.monticar.cnnarch._visitor.CNNArchVisitor;
import de.monticore.lang.monticar.cnnarch._visitor.CommonCNNArchDelegatorVisitor;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedMethods;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
import de.monticore.lang.monticar.common2._ast.ASTCommonDimensionElement;
import de.monticore.lang.monticar.common2._ast.ASTCommonMatrixType;
import de.monticore.symboltable.*;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import java.util.*;
......
......@@ -21,7 +21,6 @@
package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedMethods;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
import de.se_rwth.commons.SourcePosition;
import de.se_rwth.commons.logging.Log;
......
......@@ -21,7 +21,6 @@
package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.ScopeSpanningSymbol;
import de.monticore.symboltable.Symbol;
import de.monticore.symboltable.resolving.ResolvingFilter;
......
......@@ -20,9 +20,6 @@
*/
package de.monticore.lang.monticar.cnnarch.helper;
import de.monticore.lang.math.math._symboltable.expression.MathExpressionSymbol;
import de.se_rwth.commons.logging.Log;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
......
......@@ -21,14 +21,12 @@
package de.monticore.lang.monticar.cnnarch.helper;
import de.monticore.lang.math.math._symboltable.expression.*;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.TupleExpressionSymbol;
import de.monticore.lang.monticar.ranges._ast.ASTRange;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.function.Function;
......
......@@ -20,11 +20,10 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.lang.monticar.ranges._ast.ASTRange;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
......@@ -32,9 +31,6 @@ import org.jscience.mathematics.number.Rational;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Add extends PredefinedMethodDeclaration {
......
......@@ -22,7 +22,8 @@ package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodDeclarationSymbol;
import java.util.*;
import java.util.Arrays;
import java.util.List;
public class AllPredefinedMethods {
......
......@@ -20,19 +20,16 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.lang.monticar.ranges._ast.ASTRange;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
public class Concatenate extends PredefinedMethodDeclaration {
......
......@@ -20,9 +20,9 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -22,7 +22,9 @@ package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Pooling extends PredefinedMethodDeclaration {
......
......@@ -20,9 +20,9 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -20,9 +20,9 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -20,9 +20,9 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -20,9 +20,9 @@
*/
package de.monticore.lang.monticar.cnnarch.predefined;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.MethodLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.PredefinedMethodDeclaration;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -21,7 +21,6 @@
package de.monticore.lang.monticar.cnnarch;
import de.monticore.lang.monticar.cnnarch._parser.CNNArchParser;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol;
import de.monticore.symboltable.Scope;
import org.junit.Ignore;
......
......@@ -21,12 +21,9 @@
package de.monticore.lang.monticar.cnnarch.cocos;
import de.monticore.lang.monticar.cnnarch.AbstractSymtabTest;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchitecture;
import de.monticore.lang.monticar.cnnarch._ast.ASTCNNArchCompilationUnit;
import de.monticore.lang.monticar.cnnarch._ast.ASTCNNArchNode;
import de.monticore.lang.monticar.cnnarch._cocos.CNNArchCoCoChecker;
import de.monticore.lang.monticar.cnnarch._cocos.CNNArchCocos;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Finding;
......
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