Fusion Grammar

Fusion (largely) follows the Managed Object Format (MOF) grammar specified in the DMTF Common Information Model. The grammar is repeated here with notes where the grammar is different from the DMTF specified model. The grammar is specified using an augmented Bacus-Naur form (ABNF). Within the grammar, a '*" represents zero or more elements, specifications with square brackets are treated as optional, and specifications within parenthesis are groupings that occur together. Literal characters in the specifications are enclosed in double quotes. Terminals within rules are specified using upper case names.

MOF Specification

A MOF specification defines zero or more schema elements, and is parsed by a MOF compiler.

A MOF specification is composed of the following elements:

mofSpecification = *mofProduction
mofProduction = compilerDirective / qualifierTypeDeclaration
		/ structureDeclaration / classDeclaration / interfaceDeclaration
		/ enumerationDeclaration / complexValueDeclaration

Compiler directives

Compiler directives direct the processing of input strings containing MOF.

CompilerDirective = PRAGMA directiveName "(" directiveValue ")"
directiveName = identifier

Here directiveName is the name of the directive, and directiveValue is a string value (enclosed in double quotes) that represents its value. Fusion currently implements the following compiler directives:

Data types known to Fusion
Directive Name Directive Value Description
include filePath The directive specifies that the content of the file indicated by the file path should be included textually in place at the directive. The file name can be an absolute path or a path relative to the name of file where the pragma is located. Once the file has been read completely, processing continues past the pragma in the current file.
namespace namespace path The directive specifies that the subsequent elements should be parsed within the namespace given as the value of the directive.
debug debugging flag The value of this directive can be "on" or "off". It turns the debugging flag inside the compiler on or off. When "on", the compiler will produce addition output that may be helpful to debug the provided specification until the pragma "off" is seen. The default value of this flag is "off".

Enumeration declarations

An enumeration is a set of (related) constants that can be defined together.
enumDeclaration = [ qualifierList ] ENUMERATION enumName ":" enumTypeDeclaration ";" 
enumName = elementName
enumTypeDeclaration = ( integerType / integerEnumName ) integerEnumDeclaration 
 / ( STRING / stringEnumName ) stringEnumDeclaration
integerEnumName = enumName 
stringEnumName = enumName
integerEnumDeclaration = "{" [ integerEnumElement *( "," integerEnumElement ) ] "}" 
stringEnumDeclaration = "{" [ stringEnumElement *( "," stringEnumElement ) ] "}" 
integerEnumElement = [ qualifierList ] enumLiteral "=" integerValue 
stringEnumElement = [ qualifierList ] enumLiteral [ "=" stringValue ] 
enumLiteral = identifier

Note that if values are not defined in string-valued enumerations, the string values of the corresponding element names are used as values.

Qualifier type declarations

A qualifier is a named and typed metadata element associated with a schema element, such as a class or a method, and provides information about or specifies the behavior of the qualified element. Each qualifier is defined using a qualifier type declaration, and has the name, scope, propagation policy, data type, and default value as declared in the qualifier type declaration.
qualifierTypeDeclaration = [qualifierList] QUALIFIER qualifierName ':' qualifierType qualifierScope [qualifierPolicy] ';'
qualifierName = elementName
qualifierType = primitiveQualifierType / enumQualifierType
primitiveQualifierType = primitiveTypeDefinition / primitiveArrayTypeDefinition
primitiveTypeDefinition = primitiveType ["=" literalValue]	; type definition must match value
primitiveArrayTypeDefinition = primitiveType "[" "]" ["=" arrayValue]	; type definition must match value
arrayValue = "{" *primitiveValue "}"
qualifierScope = SCOPE "(" ( ANY | scopeKindList ) ")" scopeKindList = STRUCTURE / STRUCTUREVALUE / CLASS / INSTANCE / INTERFACE / ENUMERATION / ENUMERATIONVALUE / PROPERTY / REFERENCE / METHOD / PARAMETER / QUALIFIERTYPE / INDICATION qualifierPolicy = POLICY "(" policykind ")" policyKind = RESTRICTED / DISABLEOVERRIDE / ENABLEOVERRIDE

Qualifier lists

Qualifier lists associate qualifier types with other model elements. The name of each qualifier within a qualifier list must match the name of a qualifier type with the same name. The value (but not the data type) of the qualifier can be changed from the default value when declaring it.

qualifierList = "[" qualifierValue *( "," qualifierValue ) "]"
qualifierValue = qualifierName [ qualifierValueInitializer / qualiferValueArrayInitializer ]
qualifierValueInitializer = "(" literalValue ")"	; literal value must conform to qualifier type declaration
qualiferValueArrayInitializer = "{" literalValue *( "," literalValue ) "}"

Structure declaration

A structure forms the basic modeled element in Fusion, and represents a group of properties within it.

structureDeclaration = [ qualifierList ] STRUCTURE structureName [ superstructure ] "{" *structureFeature "}" ";"
structureName = elementName
superStructure = ":" structureName
structureFeature = structureDeclaration / enumDeclaration / propertyDeclaration

Class or Interface declaration

A class is a structure that can contain both properties and methods. An interface declaration is the same as a class declaration with the exception that is uses a different keyword.

classDeclaration = [ qualifierList ] CLASS className [ superClass ]  "{" *classFeature "}" ";"
className = elementName
superClass = ":" (className / structureName)
classFeature = structureFeature / methodDeclaration

interfaceDeclaration = [qualifierList] INTERFACE interfaceName [superInterface] "{" *classFeature "}" ";"
interfaceName = elementName
superInterface = ":" interfaceName

Note that this grammar definition implies that an interface can only extend one other interface, while a class can extend either another class or a structure.

Property declaration

Properties define name value pairs within model elements.

propertyDeclaration = [ qualifierList ] ( primitivePropertyDeclaration
 / complexPropertyDeclaration
 / enumPropertyDeclaration
 / referencePropertyDeclaration ) ";"
primitivePropertyDeclaration = primitiveType ([array] propertyName / propertyName [ array ]) [ "=" primitiveTypeValue ]
complexPropertyDeclaration = structureOrClassName ([array] propertyName / propertyName [ array ])  [ "=" ( complexTypeValue / aliasIdentifier ) ] 
enumPropertyDeclaration = enumName ([array] propertyName / propertyName [ array ])  [ "=" enumTypeValue ]
referencePropertyDeclaration = classReference ([array] propertyName / propertyName [ array ])  [ "=" referenceTypeValue ]
array = "[" "]" 
propertyName = identifier
classReference = structureOrClassName REF
structureOrClassName = elementName

Method declaration

Methods can be declared as part of class or interface (but not structure) definitions.

methodDeclaration = [ qualifierList ] ( ( returnDataType [ array ] ) / VOID ) methodName "(" [ parameterList ] ")" ";" 
returnDataType = primitiveType / structureOrClassName / enumName / classReference
methodName = identifier
parameterList = parameterDeclaration *( "," parameterDeclaration )

Parameter declaration

Method parameter follow the same syntax as properties.

parameterDeclaration = [ qualifierList ] ( primitiveParamDeclaration 
 / complexParamDeclaration
 / enumParamDeclaration 
 / referenceParamDeclaration )

primitiveParamDeclaration = primitiveType ([ array ] parameterName / parameterName[ array ]) [ "=" primitiveTypeValue ]
complexParamDeclaration = structureOrClassName ([ array ] parameterName / parameterName[ array ]) [ "=" ( complexTypeValue / aliasIdentifier ) ]
enumParamDeclaration = enumName ([ array ] parameterName / parameterName[ array ]) [ "=" enumValue ]
referenceParamDeclaration = classReference ([ array ] parameterName / parameterName[ array ]) [ "=" referenceTypeValue ]
parameterName = identifier

Note: If a default value is specified for a parameter, then that value is used within the method call if the corresponding parameter is not specified during the actual method call.

Element names

Element names can either be schema qualified names (for top level elements) or local names (for names defined within a top level element).

elementName = localName / schemaQualifiedName
schemaQualifiedName = schemaName UNDERSCORE localName
schemaName = firstIdentifierCharacter *(firstIdentifierCharacter / number)
localName = identifier

Identifiers

Identifiers represent names within the grammar.

identifier = firstIdentifierCharacter *(nextIdentifierCharacter)
firstIdentifierCharacter = upperAlpha / lowerAlpha
nextIdentifierCharacter = firstIdentifierCharacter / UNDERSCORE / number

Object names

Object names provide a uniform way of representing references to other objects within the language.


aliasIdentifier = "$" identifier
namespaceName = identifier *( "/" identifier)
referenceTypeValue = referenceValue / referenceValueArray
referenceValue = aliasIdentifier / objectPathValue
objectPathValue = [namespacePath ":"] instanceId
namespacePath = [serverPath] elementType "/" namespaceName
serverPath = (host / LOCALHOST) [ ":" port] "/"
LOCALHOST = "localhost"
instanceId = className "." instanceKeyValue
instanceKeyValue = keyValue *( "," keyValue )
keyValue = propertyName "=" literalValue

Primitive data types

The grammar accepts the following primitive data types:

primitiveType = integerType / realType / STRING / DATETIME / BOOLEAN / OCTETSTRING 
integerType = unsignedInteger / signedInteger
realType = REAL32 / REAL64
unsignedInteger = UINT8 / UINT16 / UINT32 / UINT64 
signedInteger = SINT8 / SINT16 / SINT32 / SINT64

Complex values

Complex values include values of definitions (such as classes and structures) that contain more than one value. Note that the value must conform to the data type defined in the definition. The grammar below is not attempting to validate the correspondence between data types and data values.


complexTypeValue = complexValue / complexValueArray
complexValueArray = "{" [ complexValue *( "," complexValue) ] "}"
complexValue = ( INSTANCE / VALUE ) [OF] ( structureName / className / instanceName ) [ alias ] propertyValueList ";" 
propertyValueList = "{" *propertySlot "}" 
propertySlot = propertyName "=" propertyValue ";" 
propertyValue = primitiveTypeValue / complexTypeValue / referenceTypeValue / enumTypeValue 
alias = AS aliasIdentifier

Primitive values


primitiveTypeValue = literalValue / literalValueArray
literalValueArray = "{" [ literalValue *( "," literalValue ) ] "}"
literalValue = integerValue / realValue / dateTimeValue / stringValue / booleanValue / octetStringValue / nullValue

integerValue = binaryValue / octalValue / hexValue / decimalValue
binaryValue = [ "+" / "-" ] 1*binaryDigit ( "b" / "B" ) 
binaryDigit = "0" / "1" 
octalValue = [ "+" / "-" ] unsignedOctalValue 
unsignedOctalValue = "0" 1*octalDigit
octalDigit = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"
hexValue = [ "+" / "-" ] ( "0x" / "0X" ) 1*hexDigit 
hexDigit = decimalDigit / "a" / "A" / "b" / "B" / "c" / "C" / "d" / "D" / "e" / "E" / "f" / "F"
decimalValue = [ "+" / "-" ] unsignedDecimalValue 
unsignedDecimalValue = positiveDecimalDigit *decimalDigit
decimalDigit = "0" / positiveDecimalDigit
positiveDecimalDigit = 1"..."9"

realValue = [ "+" / "-" ] *decimalDigit "." 1*decimalDigit [ ( "e" / "E" ) [ "+" / "-" ] 1*decimalDigit ]

stringValue = DOUBLEQUOTE *stringChar DOUBLEQUOTE *( *WS DOUBLEQUOTE *stringChar DOUBLEQUOTE )
stringChar = stringUCSchar / stringEscapeSequence
stringUCSchar = U+0020...U+0021 / U+0023...U+D7FF / U+E000...U+FFFD / U+10000...U+10FFFF 
stringEscapeSequence = BACKSLASH ( BACKSLASH / DOUBLEQUOTE / SINGLEQUOTE / BACKSPACE_ESC 
 / TAB_ESC / LINEFEED_ESC / FORMFEED_ESC / CARRIAGERETURN_ESC / escapedUCSchar ) 

BACKSPACE_ESC = "b" ; escape for back space (U+0008)
TAB_ESC = "t" ; escape for horizontal tab (U+0009)
LINEFEED_ESC = "n" ; escape for line feed (U+000A)
FORMFEED_ESC = "f" ; escape for form feed (U+000C)
CARRIAGERETURN_ESC = "r" ; escape for carriage return (U+000D)
escapedUCSchar = ( "x" / "X" ) 1*6( hexDigit ) ; escaped UCS

octetStringValue = DOUBLEQUOTE "0x" *( octetStringElementValue ) DOUBLEQUOTE 
 *( *WS DOUBLEQUOTE *( octetStringElementValue ) DOUBLEQUOTE )
octetStringElementValue = 2(hexDigit)

booleanValue = TRUE / FALSE
nullValue = NULL

Terminals

The grammar uses the following terminals. Note that all terminal values are case-insensitive, thus "any", "Any", or "ANY" are all treated as equal.

PRAGMA = "#pragama"
ANY = "any"
SCOPE = "scope"
POLICY = "policy"
STRUCTURE = "structure"
CLASS = "class"
INSTANCE = "instance"
INTERFACE = "interface"
ENUMERATION = "enumeration"
ENUMERATIONVALUE = "enumerationvalue"
PROPERTY = "property"
REFERENCE = "reference"
METHOD = "method"
PARAMETER = "parameter"
QUALIFIERTYPE = "qualifiertype"
INDICATION = "indication"
RESTRICTED = "restricted"
DISABLEOVERRIDE = "disableoverride"
ENABLEOVERRIDE = "enableoverride"
REF = "ref"
VOID = "void"
TRUE = "true"
FALSE = "false"
NULL = "null"
AS = "as"
OF = "of"
VALUE = "value"
UINT8 = "uint8"
UINT16 = "uint16"
UINT32 = "uint32"
UINT64 = "uint64"
SINT8 = "sint8" 
SINT16 = "sint16"
SINT32 = "sint32"
SINT64 = "sint64"
REAL32 = "real32"
REAL64 = "real64"
STRING = "string"
DATETIME = "datetime"
BOOLEAN = "boolean"
OCTETSTRING = "octetstring"