================================================================================
|
|
Module Definition
|
|
================================================================================
|
|
|
|
module mod;
|
|
--------------------------------------------------------------------------------
|
|
(translation_unit
|
|
(module_declaration
|
|
(module_name
|
|
(identifier))))
|
|
|
|
================================================================================
|
|
Module Definition with Export
|
|
================================================================================
|
|
|
|
export module mod;
|
|
--------------------------------------------------------------------------------
|
|
(translation_unit
|
|
(module_declaration
|
|
(module_name
|
|
(identifier))))
|
|
|
|
================================================================================
|
|
Module Definition with Export and Partition
|
|
================================================================================
|
|
|
|
export module mod:mod;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(module_declaration
|
|
(module_name
|
|
(identifier))
|
|
(module_partition
|
|
(module_name
|
|
(identifier)))))
|
|
|
|
================================================================================
|
|
Module Definition with Export, Partition and Attribute
|
|
================================================================================
|
|
|
|
export module mod:mod [[attribute]];
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(module_declaration
|
|
name: (module_name
|
|
(identifier))
|
|
partition: (module_partition
|
|
(module_name
|
|
(identifier)))
|
|
(attribute_declaration
|
|
(attribute
|
|
name: (identifier)))))
|
|
|
|
================================================================================
|
|
import Declaration
|
|
================================================================================
|
|
|
|
import mod;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(import_declaration
|
|
name: (module_name
|
|
(identifier))))
|
|
|
|
================================================================================
|
|
import Declaration with export
|
|
================================================================================
|
|
|
|
export import mod;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(export_declaration
|
|
(import_declaration
|
|
name: (module_name
|
|
(identifier)))))
|
|
|
|
================================================================================
|
|
import Declaration partition with export
|
|
================================================================================
|
|
|
|
export import :mod;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(export_declaration
|
|
(import_declaration
|
|
partition: (module_partition
|
|
(module_name
|
|
(identifier))))))
|
|
|
|
================================================================================
|
|
import Declaration headerunit with export
|
|
================================================================================
|
|
|
|
export import <iostream>;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(export_declaration
|
|
(import_declaration
|
|
header: (system_lib_string))))
|
|
|
|
================================================================================
|
|
global module fragment
|
|
================================================================================
|
|
|
|
module;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(global_module_fragment_declaration))
|
|
|
|
================================================================================
|
|
private module fragment
|
|
================================================================================
|
|
|
|
module :private;
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(private_module_fragment_declaration))
|
|
|
|
|
|
================================================================================
|
|
export declaration
|
|
================================================================================
|
|
|
|
export module A;
|
|
|
|
export char const* hello() { return "hello"; }
|
|
|
|
char const* world() { return "world"; }
|
|
|
|
export {
|
|
int one() { return 1; }
|
|
int zero() { return 0; }
|
|
}
|
|
|
|
export namespace hi {
|
|
char const* english() { return "Hi!"; }
|
|
char const* french() { return "Salut!"; }
|
|
}
|
|
--------------------------------------------------------------------------------
|
|
|
|
(translation_unit
|
|
(module_declaration
|
|
name: (module_name
|
|
(identifier)))
|
|
(export_declaration
|
|
(function_definition
|
|
type: (primitive_type)
|
|
(type_qualifier)
|
|
declarator: (pointer_declarator
|
|
declarator: (function_declarator
|
|
declarator: (identifier)
|
|
parameters: (parameter_list)))
|
|
body: (compound_statement
|
|
(return_statement
|
|
(string_literal
|
|
(string_content))))))
|
|
(function_definition
|
|
type: (primitive_type)
|
|
(type_qualifier)
|
|
declarator: (pointer_declarator
|
|
declarator: (function_declarator
|
|
declarator: (identifier)
|
|
parameters: (parameter_list)))
|
|
body: (compound_statement
|
|
(return_statement
|
|
(string_literal
|
|
(string_content)))))
|
|
(export_declaration
|
|
(declaration_list
|
|
(function_definition
|
|
type: (primitive_type)
|
|
declarator: (function_declarator
|
|
declarator: (identifier)
|
|
parameters: (parameter_list))
|
|
body: (compound_statement
|
|
(return_statement
|
|
(number_literal))))
|
|
(function_definition
|
|
type: (primitive_type)
|
|
declarator: (function_declarator
|
|
declarator: (identifier)
|
|
parameters: (parameter_list))
|
|
body: (compound_statement
|
|
(return_statement
|
|
(number_literal))))))
|
|
(export_declaration
|
|
(namespace_definition
|
|
name: (namespace_identifier)
|
|
body: (declaration_list
|
|
(function_definition
|
|
type: (primitive_type)
|
|
(type_qualifier)
|
|
declarator: (pointer_declarator
|
|
declarator: (function_declarator
|
|
declarator: (identifier)
|
|
parameters: (parameter_list)))
|
|
body: (compound_statement
|
|
(return_statement
|
|
(string_literal
|
|
(string_content)))))
|
|
(function_definition
|
|
type: (primitive_type)
|
|
(type_qualifier)
|
|
declarator: (pointer_declarator
|
|
declarator: (function_declarator
|
|
declarator: (identifier)
|
|
parameters: (parameter_list)))
|
|
body: (compound_statement
|
|
(return_statement
|
|
(string_literal
|
|
(string_content)))))))))
|
|
|
|
================================================================================
|
|
Modules in preprocessor sections
|
|
================================================================================
|
|
|
|
#ifdef USE_MODULES
|
|
module;
|
|
#include <vector>
|
|
export module foo;
|
|
#endif
|
|
|
|
#if USE_MODULES
|
|
import std;
|
|
#else
|
|
import <vector>;
|
|
#endif
|
|
|
|
export {
|
|
#ifdef USE_MODULE
|
|
class Foo;
|
|
#endif
|
|
}
|
|
|
|
--------
|
|
|
|
(translation_unit
|
|
(preproc_ifdef
|
|
(identifier)
|
|
(global_module_fragment_declaration)
|
|
(preproc_include
|
|
(system_lib_string))
|
|
(module_declaration
|
|
(module_name
|
|
(identifier))))
|
|
(preproc_if
|
|
(identifier)
|
|
(import_declaration
|
|
(module_name
|
|
(identifier)))
|
|
(preproc_else
|
|
(import_declaration
|
|
(system_lib_string))))
|
|
(export_declaration
|
|
(declaration_list
|
|
(preproc_ifdef
|
|
(identifier)
|
|
(class_specifier
|
|
(type_identifier))))))
|