11.13.  Architecture DSL Language Specification

For the sake of completeness please find a formal grammar of our architecture DSL in EBNF form. The semantics of the language have been described in the preceding sections.

Body            = Declaration* Connection*
                ;
Declaration     = ArtifactDecl
                | ExtendDecl
                | ApplyDecl
                | RequireDecl
                | IncludeDecl
                | ExcludeDecl
                | InterfaceExt
                | ConnectorExt
                | InterfaceDecl
                | ConnectorDecl
                | Scheme
                | ClassDecl
                | TemplateDecl
                ;
ClassDecl       = "class" IDENT "{" ClassMember* "}"
                ;
ClassMember     = "interface" List
                | "connector" List
                ;
List            = IDENT ("," IDENT)*
                ;
ArtifactDecl    = StereoTypes "artifact" IDENT (":" IDENT)? "{" Body "}"
                ;
ExtendDecl      = "extend" IDENT "{" ExtendBody "}"
                | StereoType+ "extend" IDENT "{" ExtendBody "}"
                ;

ExtendBody      = Declaration* DisconnectDecl* Connection*
                ;
DisconnectDecl  = "disconnect" IDENT? "from" IdentList
                ;
        
StereoTypes     = StereoType*
                ;
        
StereoType      = "public"
                | "hidden"
                | "local"
                | "exposed"
                | "unrestricted"
                | "relaxed"
                | "strict"
                | "optional"
                | "deprecated"
                ;
ApplyDecl       = "apply" STRING
                ;

RequireDecl     = "require" STRING
                ;
        
IncludeDecl     = "strong"? "include" STRING
                | "include" "all"
                | "include" "dependency-types" DependencyTypes
                ;
ExcludeDecl     = "exclude" STRING
                | "exclude" "dependency-types" DependencyTypes
                ;

DependencyTypes = DependencyType ("," DependencyType)*
                ;
        
DependencyType  = IDENT
                ;
        
InterfaceDecl   = ("override"|"optional")? "interface" IDENT "{" InterfaceBody "}"
                ;
InterfaceExt    = "extend" "interface" IDENT "{" InterfaceBody "}"
                ;
        
InterfaceBody   = IDeclaration*
                ;
                  
IDeclaration    = IncludeDecl
                | ExcludeDecl
                | Export
                ;
ConnectorDecl   = "override"? "connector" IDENT "{" ConnectorBody "}"
                ;
        
ConnectorExt    = "extend" "connector" IDENT "{" ConnectorBody "}"
                ;
        
ConnectorBody   = CDeclaration*
                ;
CDeclaration    = IncludeDecl
                | ExcludeDecl
                | Include
                ;
        
Export          = "export" SpecIdentList  
                ;
Include         = "include" SpecIdentList
                ;
        
SpecIdentList   = SpecIdent ("," SpecIdent)*
                ;
        
SpecIdent       = "any" ("." IDENT)*
                | IDENT ("." IDENT)*
                ;
IdentList       = Identifier ("," Identifier)*
                ;
        
Identifier      = IDENT ("." IDENT)*  
                ;
                              
Connection      = "connect" "to" IdentList
                | "connect" Identifier "to" IdentList
                | "connect" "to" IdentList "using" IDENT
                ;
Scheme          = "connection-scheme" IDENT (":" IDENT "to" IDENT)? "{" TargetUse* "}"
                ;
        
TargetUse       = "connect" Identifier "to" TargetIdentList
                | "connect" "any" "." Identifier "to" TargetIdentList
                ;
        
TargetIdentList = TargetIdent ("," TargetIdent)*
                ;
        
TargetIdent     = "target" ("." IDENT)+
                | "target" "." "any" ("." IDENT)+
                ;
IDENT           = ("A" .. "Z" | "a" .. "z")("A" .. "Z" | "a" .. "z" | "0" .. "9" | "_" | "-")*
                ;
                    
TemplateDecl    = StereoTypes "template" IDENT (":" IDENT)? "{" TemplateBody "}"
                ;
          
TemplateBody    = TemplateInclude+ TemplateExclude* TemplArtifact TemplateConnect*
                ;
  
TemplateInclude = "include" STRING
                ;
          
TemplateExclude = "exclude" STRING
                ;
          
TemplateConnect = "connect" "to" IdentList
                | "connect" Identifier "to" IdentList
                | "connect" "to" IdentList "using" IDENT
                | "connect" "all" "using" IDENT
                ;
TemplArtifact   = StereoTypes "artifact" NameExpr (":" IDENT)? "{" Body "}"
                ;
          
NameExpr        = NameItem
                | NameItem "+" NameExpr
                ;
          
NameItem        = STRING
                | "$" ["1"-"9"] 
                | IDENT "(" NameExpr ")"
                ;

                // '@' stands for any character except the context specific terminator
STRING          = '"' (@ | '\\' @)* '"' | "'" (@ | '\\' @)* "'"
                ;