Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

CNNArch.mc4 2.59 KB
Newer Older
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
1
package de.monticore.lang.monticar;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
2

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
3
grammar CNNArch extends de.monticore.lang.math.Math {
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
4

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
5
    CNNArchCompilationUnit = Architecture;
6

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
7 8 9 10
    symbol scope Architecture = "architecture"
                                name:Name& "{"
                                defs:ArchDeclaration*
                                body:ArchBody "}";
11

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
12
    interface ArchDeclaration;
13
    interface ArchitectureElement;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
14
    interface Variable;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
15

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
16 17 18 19 20
    symbol IODeclaration implements ArchDeclaration = "def"
                                                      (in:"input" | out:"output")
                                                      type:ArchType
                                                      Name&
                                                      (ArrayDeclaration)?;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
21

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
22
    ArchType implements Type = (ElementType ("^" "{" (IOVariable || ",")+ "}")?)?;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
23

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
24
    symbol IOVariable implements Variable = Name&;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
25

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
26
    symbol Constant implements Variable = "def" Name& "=" rhs:ArchRhs;
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
27

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
28 29 30 31
    symbol scope MethodDeclaration implements ArchDeclaration = "def"
                                                                Name& "("
                                                                parameters:(Parameter || ",")* ")" "{"
                                                                body:ArchBody "}";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
32

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
33
    symbol Parameter implements Variable = Name& ("=" default:ArchRhs)?;
34

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
35
    ArchBody = elements:(ArchitectureElement || "->")*;
36

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
37
    IOLayer implements ArchitectureElement = Name& ("[" index:ArchExpression "]")?;
38

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
39
    MethodLayer implements ArchitectureElement = Name& "(" arguments:(Argument || ",")* ")";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
40

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
41
    Argument = Name "=" rhs:ArchRhs;
42

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
43
    ArchRhs = (expression:ArchExpression | sequence:ArchValueSequence);
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
44

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
45
    ArchValueSequence = "[" parallelValues:(SerialValues || "|")* "]";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
46

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
47
    SerialValues = (ArchExpression || "->")+;
48

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
49 50 51 52
    ArchValueRange extends ArchValueSequence = "[" start:ArchExpression
                                               (serial:"->" | parallel:"|")
                                               (":" step:ArchExpression)?
                                               ":" end:ArchExpression "]";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
53

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
54
    ParallelLayer implements ArchitectureElement = "(" groups:(ArchBody || "|")+ ")";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
55

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
56
    ArrayAccessLayer implements ArchitectureElement = "[" index:ArchExpression "]";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
57

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
58 59 60
    ArchExpression = (arithmeticExpression:MathArithmeticExpression
                   | booleanExpression:MathBooleanExpression
                   | tupleExpression:TupleExpression);
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
61

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
62
    TupleExpression implements MathExpression = "(" expressions:MathArithmeticExpression "," expressions:(MathArithmeticExpression || ",")* ")";
Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
63

Thomas Michael Timmermanns's avatar
Thomas Michael Timmermanns committed
64
}