Tagging.mc4 2.33 KB
Newer Older
vonWenckstern's avatar
vonWenckstern committed
1
2
3
4
5
6
7
8
9
package de.monticore.lang;

/**
 * Basic grammar to tag non-functional properties
 *
 * @author Michael von Wenckstern
 */
grammar Tagging extends de.monticore.common.Common {

10
  TaggingUnit =
vonWenckstern's avatar
vonWenckstern committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    ("package" package:(Name& || ".")+ ";")? 
    (ImportStatement)*
    "conforms" "to" (QualifiedName || ",")+ ";"
	TagBody;
	
	// name should be optional, but than we need an transformation step in the parser
	// b/c the symbol table needs a name
	// and we need the symbol table for coco checks
	// maybe later for convience we make the optional
	TagBody = "tags" Name? ("for" targetModel: Scope)? "{"
	   Tag+ "}";
	   
//	interface TagElement;
	
  Tag = "tag" (Scope || ",")+ "with" TagElement+;
26
  symbol TagElement = Name (TagValue | ";");
vonWenckstern's avatar
vonWenckstern committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

 fragment token WSS = (' ' | '\t' | '\r' | '\n');

 token TagValue = '=' WSS* BasicTagValue (WSS* ';');
 fragment token BasicTagValue = (Recursion | TagToken | String);
 fragment token Recursion = '{' (~('{' | '}' | '"') | String | Recursion)+ '}';
 fragment token TagToken = (~('"' | '{' | '}' | ';'))+;

	interface Scope;
	ast Scope =
	  method public String getQualifiedNameString() {
     return "";
    }
	  method public String getScopeKind() {
	    return "undefined";
	  };

	// this one is only defined here, to get Parser Tags
	NameScope implements Scope = QualifiedName;
	ast NameScope =
	  method public String getQualifiedNameString() {
       return getQualifiedName().toString();
     }
	  method public String getScopeKind() {
  	  return "NameScope";
  	};

	ConnectorScope extends NameScope = source:QualifiedName "->" QualifiedName;
  ast ConnectorScope =
    method public String getQualifiedNameString() {
       return getQualifiedName().toString();
     }
    method public String getScopeKind() {
      return "ConnectorScope";
    };

/* ast Scope =
  method public de.monticore.types.types._ast.ASTQualifiedName getQualifiedName() {
   return null;
  }
  method public String getQualifiedNameAsString() {
     return de.se_rwth.commons.Joiners.DOT.join(getQualifiedName().getParts());
  };
  ast NameScope =
  method public String getQualifiedNameAsString() {
     return de.se_rwth.commons.Joiners.DOT.join(getQualifiedName().getParts());
  };
  ast ConnectorScope =
    method public String getQualifiedNameAsString() {
       return de.se_rwth.commons.Joiners.DOT.join(getQualifiedName().getParts());
    }; */
}