MOF BNF Syntax

[This is preliminary documentation and subject to change.]

//
// Start symbol.
//
<Parse> ::= <top_level_decl><Parse>;
<Parse> ::= <qualifier_default><Parse>;
<Parse> ::= <preprocessor_command><Parse>;
<Parse> ::= <>;

//
// Preprocessor commands
//
<preprocessor_command> ::= <pound_include>;
<preprocessor_command> ::= <pound_define>;
<preprocessor_command> ::= TOK_PRAGMA <pound_pragma>;

<pound_include> ::= TOK_INCLUDE <const_string>;

<pound_define> ::= TOK_DEFINE TOK_SIMPLE_IDENT <const_value>;

<pound_pragma> ::= TOK_NAMESPACE 
                    TOK_OPEN_PAREN TOK_LPWSTR TOK_CLOSE_PAREN;

<pound_pragma> ::= TOK_CLASSFLAGS 
                    TOK_OPEN_PAREN TOK_LPWSTR TOK_CLOSE_PAREN;

<pound_pragma> ::= TOK_INSTANCEFLAGS 
                    TOK_OPEN_PAREN TOK_LPWSTR TOK_CLOSE_PAREN;



<top_level_decl> ::= <qualifier_decl> <decl_type>;   

<decl_type> ::= <typedef>;
<decl_type> ::= <instance_decl>TOK_SEMI;
<decl_type> ::= <class_decl>;

//
//  Typedef support
//

<typedef> ::= TOK_TYPEDEF <complete_type> 
                TOK_SIMPLE_IDENT <opt_subrange> TOK_SEMI;
<complete_type> ::= <type> <opt_ref>;
<complete_type> ::= <enum>;

<enum> ::= TOK_ENUM TOK_OPEN_BRACE <enum_data> TOK_CLOSE_BRACE;

<enum_data> ::= <opt_name><enum_data_rest>;

<enum_data_rest> ::= <const_int> <int_enum_data_rest>;
<enum_data_rest> ::= TOK_LPWSTR <string_enum_data_rest>;

<int_enum_data_rest> ::= <>;
<int_enum_data_rest> ::= TOK_COMMA <int_enum_datum> <int_enum_data_rest>;

<int_enum_datum> ::= <opt_name><const_int>;

<string_enum_data_rest> ::= <>;
<string_enum_data_rest> ::= TOK_COMMA <string_enum_datum> 
                                <string_enum_data_rest>;

<string_enum_datum> ::= <opt_name>TOK_LPWSTR;

<opt_name> ::= <>;
<opt_name> ::= TOK_SIMPLE_IDENT TOK_EQUALS;

<opt_subrange> ::= <>;
<opt_subrange> ::= TOK_SUBRANGE TOK_OPEN_PAREN <const_value> TOK_DOT TOK_DOT 
                        <const_value> TOK_CLOSE_PAREN;

//
//  Class declaration
//
<class_decl> ::= 
    TOK_CLASS
    TOK_SIMPLE_IDENT        // Class name
    <class_def>;
    
<class_def> ::=
    <as_alias>
    <opt_parent_class>
    TOK_OPEN_BRACE
    <property_decl_list>
    TOK_CLOSE_BRACE
    TOK_SEMI;
<class_def> ::= TOK_SEMI;


<property_decl_list> ::= <PropOrMeth_decl> <property_decl_list>;
<property_decl_list> ::= <>;

<opt_parent_class> ::= TOK_COLON TOK_SIMPLE_IDENT;
<opt_parent_class> ::= <>;

//
// Property/Method declarations.
//
<PropOrMeth_decl> ::= <qualifier_decl><PropOrMeth_decl2>;

<PropOrMeth_decl2> ::= <TypeAndName> <finish_PropOrMeth>;
<PropOrMeth_decl2> ::= TOK_VOID TOK_SIMPLE_IDENT <finish_meth>;
 
<finish_PropOrMeth> ::= <finish_prop>;
<finish_PropOrMeth> ::= <finish_meth>;

<finish_prop> ::=    
    <opt_array> 
    <default_value> 
    TOK_SEMI;

<finish_meth> ::=    
    TOK_OPEN_PAREN 
    <arg_list>
    TOK_CLOSE_PAREN 
    TOK_SEMI;

<TypeAndName> ::= <type> <opt_ref> TOK_SIMPLE_IDENT;

<arg_list> ::= <arg_decl> <rest_of_args>;
<arg_list> ::= <>;

<arg_decl> ::= <qualifier_decl><TypeAndName><opt_array><default_value>;

<rest_of_args> ::= TOK_COMMA <arg_decl> <rest_of_args>;
<rest_of_args> ::= <>;


<opt_ref> ::= TOK_REF;
<opt_ref> ::= <>;

<opt_array> ::= TOK_OPEN_BRACKET <opt_array_detail>;
<opt_array> ::= <>;

<opt_array_detail> ::= TOK_UNSIGNED_NUMERIC_CONST TOK_CLOSE_BRACKET;
<opt_array_detail> ::= TOK_CLOSE_BRACKET;


<default_value> ::= <>;
<default_value> ::= TOK_EQUALS <initializer>;


//
//  Instances.
//

<instance_decl> ::=
    TOK_INSTANCE TOK_OF
    <type>                      
    <as_alias>
    TOK_OPEN_BRACE
    <prop_init_list>
    TOK_CLOSE_BRACE;
    
<prop_init_list> ::= <prop_init><prop_init_list>;
<prop_init_list> ::= <>;
<prop_init> ::= <qualifier_decl> TOK_SIMPLE_IDENT TOK_EQUALS <initializer> TOK_SEMI;

<as_alias> ::= TOK_AS <alias>;
<as_alias> ::= <>;

//
// Qualifiers
//
// This allows comma delimited identifiers, or identifiers
// in functional notation with a const parm list. 
//

<qualifier_decl>   ::= TOK_OPEN_BRACKET <qualifier_list> TOK_CLOSE_BRACKET;
<qualifier_decl>   ::= <>;

<qualifier_list>   ::= <qualifier><qualifier_list_rest>;

<qualifier_list_rest> ::= TOK_COMMA <qualifier><qualifier_list_rest>;
<qualifier_list_rest> ::= <>;

<qualifier>        ::= TOK_SIMPLE_IDENT <qualifier_parm>;
<qualifier>        ::= TOK_EXTERNAL;

<qualifier_parm>  ::= TOK_OPEN_PAREN <initializer_list> TOK_CLOSE_PAREN <flavor_param>;
<qualifier_parm>  ::= <flavor_param>;

<flavor_param>    ::= TOK_COLON  <flavor_list> ;
<flavor_param>    ::= <>;

<flavor_list> ::= <flavor_value> <flavor_list_rest>;

<flavor_list_rest> ::=  <FLAVOR_VALUE> <flavor_list_rest>;
<flavor_list_rest> ::= <>;

<flavor_value> ::= TOK_TOINSTANCE;
<flavor_value> ::= TOK_NOTTOINSTANCE;
<flavor_value> ::= TOK_TOSUBCLASS;
<flavor_value> ::= TOK_NOTTOSUBCLASS;
<flavor_value> ::= TOK_ENABLEOVERRIDE;
<flavor_value> ::= TOK_DISABLEOVERRIDE;
<flavor_value> ::= TOK_RESTRICTED;

/////////////////////////////////////////////////////////////////////////////
//

<type> ::= TOK_SIMPLE_IDENT;

<const_int> ::= TOK_SIGNED_NUMERIC_CONST;
<const_int> ::= TOK_UNSIGNED_NUMERIC_CONST;
<const_int> ::= TOK_SIGNED64_NUMERIC_CONST;
<const_int> ::= TOK_UNSIGNED64_NUMERIC_CONST;

<const_string> ::= TOK_LPSTR;
<const_string> ::= TOK_LPWSTR;

<const_char> ::= TOK_CHAR;
<const_char> ::= TOK_WCHAR;

<const_value> ::= <const_string>;
<const_value> ::= <const_int>;
<const_value> ::= <const_char>;
<const_value> ::= TOK_UUID;
<const_value> ::= TOK_KEYWORD_NULL;
                   
<initializer> ::= <simple_initializer>;
<initializer> ::= TOK_EXTERNAL;
<initializer> ::= TOK_OPEN_BRACE <initializer_list> TOK_CLOSE_BRACE;
<initializer> ::= <class_decl>;

<simple_initializer> ::= <qualifier_decl><instance_decl>;
<simple_initializer> ::= <const_value>;
<simple_initializer> ::= <alias>;

<initializer_list> ::= <simple_initializer><initializer_list>;
<initializer_list> ::= TOK_COMMA <simple_initializer><initializer_list>;
<initializer_list> ::= <>;

<alias> ::= TOK_DOLLAR_SIGN TOK_SIMPLE_IDENT;

/////////////////////////////////////////////////////////////////////////
//
//  Qualifier defaults
//

<qualifier_default> ::= TOK_QUALIFIER TOK_SIMPLE_IDENT <flavor_param>;