grammar at.qe.txture.ArchDSL with org.eclipse.xtext.common.Terminals generate archDSL "http://www.qe.at/txture/ArchDSL" import "http://www.eclipse.org/emf/2002/Ecore" as ecore //================================================================================================= // MAIN //------------------------------------------------------------------------------------------------- // This section contains the main definitions of the grammar. //================================================================================================= /** An ArchFile is the (syntactically invisible) top-level element in each file. */ ArchFile: (fragments += Fragment)* ; /** A Fragment is basically everything that may be contained in an ArchFile. */ Fragment: OrganizationalComponent | Location | Person | HardwareComponent | SoftwareComponent | Service ; /** Organizational Components model parts of an organization, i.e. Company and Department. */ OrganizationalComponent: Company | Department ; /** Describes a single company as a whole. */ Company: 'company' name = ID '{' ( ('CEO' ':' ceo = [Person|QualifiedName])? & ('CIO' ':' cio = [Person|QualifiedName])? & ('Headquarters' ':' headquarters = [Location|QualifiedName])? ) '}' ; /** Models a single department within a company. */ Department: 'department' name = ID 'of' company = [Company|QualifiedName] '{' ('head' ':' head = [Person|QualifiedName])? '}' ; /** Describes a single, physical location. */ Location: Building|Room ; /** A physical building, serving as a location. */ Building: 'location' name = ID '{' 'address' ':' address = STRING ('owner' ':' owningCompany = [Company|QualifiedName])? (rooms+=Room)* '}' ; /** A physical room in a building, serving as a location. */ Room: 'room' name = ID ; /** A Hardware Component represents a physical piece of technology. */ HardwareComponent: Server | Workstation | MobileDevice ; /** Describes a server and which software runs on it. */ Server: 'server' name = ID '{' systemSpecs = SystemSpecs ( ('location' ':' location = [Location|QualifiedName])? & ('owner' ':' owningCompany = [Company|QualifiedName])? & ('type' ':' serverTypes += ServerType (', ' serverTypes += ServerType)*)? ) (services += Service)* '}' ; /** A Service is an instance of some software running on a server. */ Service: SoftwareService|ProxyService ; /** A software service is a directly provided (i.e. non-proxy) service implemented by a certain software. */ SoftwareService: 'service' name = ID '{' ('visibility' ':' visibility = Visibility)? ('software' ':' software = [SoftwareComponent|QualifiedName]) (('at' 'port' portID = INT)|('on' 'url' url = URLRule))? '}' ; /** A Proxy Service is a redirection to a different service, which in turn may be a Proxy. */ ProxyService: 'proxy' 'service' name = ID '{' 'redirect' 'incoming' 'request' (('at' 'port' portID = INT)|('on' 'url' url = URLRule)) 'to' proxyTarget = [Service|QualifiedName] '}' ; /** A Workstation describes a single PC in a company. */ Workstation: 'workstation' name = ID '{' systemSpecs = SystemSpecs ( ('location' ':' location = [Location|QualifiedName])? & ('owner' ':' owningCompany = [Company|QualifiedName])? & ('user' ':' users += [Person|QualifiedName] (',' users+=[Person|QualifiedName])*)? ) ('local software' ':' localSoftware += [SoftwareComponent|QualifiedName] (',' localSoftware += [SoftwareComponent|QualifiedName])*)? '}' ; /** A mobile device describes a Smartphone, Tablet or other mobile computer. */ MobileDevice: 'mobile' 'device' name = ID '{' systemSpecs = SystemSpecs ( ('owner' ':' owningCompany = [Company|QualifiedName])? & ('user' ':' users += [Person|QualifiedName] (',' users+=[Person|QualifiedName])*)? ) ('local software' ':' localSoftware += [SoftwareComponent|QualifiedName] (',' localSoftware += [SoftwareComponent|QualifiedName])*)? '}' ; /** Describes an arbitrary software component. In this model, we only distinguish between Applications and Operating Systems. */ SoftwareComponent: Application | OperatingSystem ; /** A software application of arbitrary content. Could be Notepad, or Eclipse, or any other application. */ Application: 'application' name = ID '{' ( ('vendor' ':' vendor = [Company|QualifiedName])? & ('full' 'name' ':' productName = (ID|STRING))? & ('version' ':' version = SoftwareVersion)? ) '}' ; /** An Operating system of arbitrary content. Could be Ubuntu, or Windows, or Snow Leopard, or any other. */ OperatingSystem: 'operating' 'system' name = ID '{' ( ('full' 'name' ':' productName = (ID|STRING))? & ('vendor' ':' vendor = [Company|QualifiedName])? & ('version' ':' version = SoftwareVersion)? ) '}' ; //================================================================================================= // SUPPLEMENTARY //------------------------------------------------------------------------------------------------- // This section contains some supplementary data structures and enumerations. //================================================================================================= /** Models informationa bout a single person. */ Person: 'person' name = ID '{' 'first' 'name' ':' firstName = (ID|STRING) 'last' 'name' ':' lastName = (ID|STRING) 'email' ':' mailAddress = STRING '}' ; /** Used in the grammar only, to allow the user to enter URLs. Will be auto-converted to java.net.URL. */ URLRule: ID '://' URLAuthority (':' INT)? ('/' URLPath)? ('?' ID)? ('#' ID)? ; /** A part of an URL, describing the host name. */ URLAuthority returns ecore::EString: (ID|INT)(ID|'-'|'.'|INT)* ; /** A filepath for describing the URL target. */ URLPath returns ecore::EString: ID('/'ID)* ; /** The server type describes in more detail what the server is used for. */ enum ServerType: Gateway = 'gateway' | Edge = 'edge' | Internal = 'internal' | Proxy = 'proxy' ; /** The (hardware) System Specification for a given device. */ SystemSpecs: ('operating' 'system' ':' operatingSystem = [OperatingSystem|QualifiedName])? & ('cpu' ':' cpu = (ID|STRING))? & ('ram' ':' ram = MemorySpecification)? & ('hard' 'drive' ':' hdd = MemorySpecification)? & ('vendor' ':' vendor = [Company|QualifiedName])? & ('device' 'name' ':' deviceName = (ID|STRING))? ; /** A memory specification. Consists of the numeric amount and the measurement unit (e.g. 5MB consists of amount 5 and unit MB). */ MemorySpecification hidden(WS): amount = FloatingPoint unit = MemoryUnit ; /** A helper in the grammar for formulating a software version. */ SoftwareVersion returns ecore::EString: (INT|ID|'_') ('.' (INT|ID)|'_')* ; /** Lexer rule for formulating floating point numbers. Will be auto-converted into java.lang.Float. */ FloatingPoint returns ecore::EFloat: INT '.' INT ; /** The normal QualifiedName rule, as used by many Xtext projects for cross-referencing entities in different files. */ QualifiedName: ID ('.' ID)* ; /** An enumeration of the typical memory units. */ enum MemoryUnit: Byte = 'B' | Kilobyte = 'KB' | Megabyte = 'MB' | Gigabyte = 'GB' | Terabyte = 'TB' | Petabyte = 'PB' | Exabyte = 'EB' ; /** An enumeration of visibility kinds. */ enum Visibility: public = 'public' | private = 'private' ;