IDL compiler front-end library
Public Member Functions | List of all members
AST::Builder Class Reference

The AST builder. More...

#include <Builder.h>

Inheritance diagram for AST::Builder:
BE::MessageOut

Public Member Functions

const std::filesystem::path * file () const noexcept
 Currently parsed IDL file path.
 
Location location () const
 
bool is_main_file () const noexcept
 Test if currently parsed file is main. More...
 
const std::string & prefix () const
 
void type_prefix (const ScopedName &name, const Variant &s, const Location &id_loc)
 Set repository id prefix for item. See the typeprefix IDL keyword. More...
 
void type_id (const ScopedName &name, const Variant &id, const Location &id_loc)
 Set repository id for item. See the typeid IDL keyword. More...
 
void pragma_version (const ScopedName &name, const Version &ver, const Location &loc)
 Set repository id version for item. See #pragma version. More...
 
const Itemcur_parent () const
 
void native (const SimpleDeclarator &name)
 Create native type. More...
 
void module_begin (const SimpleDeclarator &name)
 Begin module. More...
 
void module_end ()
 End module.
 
void interface_decl (const SimpleDeclarator &name, InterfaceKind ik=InterfaceKind())
 Create interface forward declaration. More...
 
void interface_begin (const SimpleDeclarator &name, InterfaceKind ik=InterfaceKind())
 Begin interface definition. More...
 
void interface_bases (const ScopedNames &bases)
 Set current interface bases. More...
 
void operation_begin (bool oneway, Type &&type, const SimpleDeclarator &name)
 Begin operation definition for the current interface or valuetype. More...
 
void parameter (Parameter::Attribute att, Type &&type, const SimpleDeclarator &name)
 Add parameter to the current operation. More...
 
void raises (const ScopedNames &names)
 Set raises for the current operation. More...
 
void operation_context (const Variants &strings)
 Set context for the current operation. More...
 
void operation_end ()
 End of the operation definition.
 
void attribute (bool readonly, Type &&type, const SimpleDeclarators &declarators)
 Add attributes to the current interface or valuetype. More...
 
void attribute_begin (bool readonly, Type &&type, const SimpleDeclarator &name)
 Begin attribute definition for the current interface or valuetype. More...
 
void getraises (const ScopedNames &names)
 Set getraises for the current attribute. More...
 
void setraises (const ScopedNames &names)
 Set setraises for the current attribute. More...
 
void attribute_end ()
 End of the attribute definition.
 
void interface_end ()
 End of the interface definition.
 
void type_def (Type &&type, const Declarators &declarators)
 Create type alias. More...
 
void struct_decl (const SimpleDeclarator &name)
 Create structure forward declaration. More...
 
void struct_begin (const SimpleDeclarator &name)
 Begin of the structure definition. More...
 
const NamedItemstruct_end ()
 End of the structure definition. More...
 
void exception_begin (const SimpleDeclarator &name)
 Begin of the exception definition. More...
 
void exception_end ()
 End of the exception definition.
 
void member (Type &&type, const Declarators &names)
 Add members to the current structure or exception. More...
 
void union_decl (const SimpleDeclarator &name)
 Create union forward declaration. More...
 
void union_begin (const SimpleDeclarator &name, const Type &switch_type, const Location &type_loc)
 Begin of the union definition. More...
 
void union_label (const Variant &label, const Location &loc)
 Create label for the current union. More...
 
void union_default (const Location &loc)
 Create default label for the current union. More...
 
void union_element (Type &&type, const Declarator &decl)
 Create union element for the current label. More...
 
const NamedItemunion_end ()
 End of the union definition. More...
 
const NamedItemenum_type (const SimpleDeclarator &name, const SimpleDeclarators &items)
 Create enum type. More...
 
void valuetype_decl (const SimpleDeclarator &name, bool is_abstract=false)
 Create valuetype forward declaration. More...
 
void valuetype_begin (const SimpleDeclarator &name, ValueType::Modifier mod=ValueType::Modifier::NONE)
 Begin valuetype definition. More...
 
void valuetype_bases (bool truncatable, const ScopedNames &bases)
 Set current valuetype bases. More...
 
void valuetype_supports (const ScopedNames &interfaces)
 Set current valuetype supported interfaces. More...
 
void state_member (bool is_public, Type &&type, const Declarators &names)
 Add members to the current valuetype. More...
 
void valuetype_factory_begin (const SimpleDeclarator &name)
 Begin valuetype factory. More...
 
void valuetype_factory_end ()
 End valuetype factory. More...
 
void valuetype_end ()
 End of the valuetype definition.
 
void valuetype_box (const SimpleDeclarator &name, Type &&type)
 Create value box definition. More...
 
void constant (Type &&t, const SimpleDeclarator &name, Variant &&val, const Location &loc)
 Create constant definition. More...
 
void constant (Type &&t, const SimpleDeclarator &name)
 Create interface constant definition (Nirvana extension). More...
 
Type lookup_type (const ScopedName &scoped_name)
 Find type by name. More...
 
- Public Member Functions inherited from BE::MessageOut
 MessageOut (std::ostream &out=std::cerr, unsigned max_err_cnt=20)
 
void message (const AST::Location &l, MessageType mt, const std::string &msg)
 
void message (const std::exception &ex)
 
unsigned error_count () const noexcept
 

Additional Inherited Members

- Public Types inherited from BE::MessageOut
enum class  MessageType { ERROR , WARNING , MESSAGE }
 Message types. More...
 

Detailed Description

The AST builder.

Definition at line 59 of file Builder.h.

Member Function Documentation

◆ location()

Location AST::Builder::location ( ) const
Returns
Current location.

◆ is_main_file()

bool AST::Builder::is_main_file ( ) const
inlinenoexcept

Test if currently parsed file is main.

Returns
true if currently parsed file is compiled file. false if currently parsed file is included file.

Definition at line 75 of file Builder.h.

◆ prefix()

const std::string& AST::Builder::prefix ( ) const
Returns
Repository id prefix. See the typeprefix IDL keyword.

◆ type_prefix()

void AST::Builder::type_prefix ( const ScopedName name,
const Variant s,
const Location id_loc 
)

Set repository id prefix for item. See the typeprefix IDL keyword.

Parameters
nameItem name.
sPrefix string.
id_loctypeprefix location.

◆ type_id()

void AST::Builder::type_id ( const ScopedName name,
const Variant id,
const Location id_loc 
)
inline

Set repository id for item. See the typeid IDL keyword.

Parameters
nameItem name.
idRepository id.
id_loctypeid location.

Definition at line 95 of file Builder.h.

◆ pragma_version()

void AST::Builder::pragma_version ( const ScopedName name,
const Version &  ver,
const Location loc 
)
inline

Set repository id version for item. See #pragma version.

Parameters
nameItem name.
verItem version.
loclocation.

Definition at line 105 of file Builder.h.

◆ cur_parent()

const Item* AST::Builder::cur_parent ( ) const
Returns
Current parent item or nullptr if parent item is invalid.

◆ native()

void AST::Builder::native ( const SimpleDeclarator name)

Create native type.

Parameters
nameNative type name.

◆ module_begin()

void AST::Builder::module_begin ( const SimpleDeclarator name)

Begin module.

Parameters
nameThe module name.
Returns
Module definition.

◆ interface_decl()

void AST::Builder::interface_decl ( const SimpleDeclarator name,
InterfaceKind  ik = InterfaceKind() 
)

Create interface forward declaration.

Parameters
nameThe interface name.
ikThe interface kind.

◆ interface_begin()

void AST::Builder::interface_begin ( const SimpleDeclarator name,
InterfaceKind  ik = InterfaceKind() 
)

Begin interface definition.

Parameters
nameThe interface name.
ikThe interface kind.

◆ interface_bases()

void AST::Builder::interface_bases ( const ScopedNames bases)

Set current interface bases.

Parameters
basesBase names.

◆ operation_begin()

void AST::Builder::operation_begin ( bool  oneway,
Type &&  type,
const SimpleDeclarator name 
)

Begin operation definition for the current interface or valuetype.

Parameters
onewaytrue for oneway operations.
typeReturn type.
nameThe operation name.

◆ parameter()

void AST::Builder::parameter ( Parameter::Attribute  att,
Type &&  type,
const SimpleDeclarator name 
)

Add parameter to the current operation.

Parameters
attThe parameter attribute.
typeThe parameter type.
nameThe parameter name.

◆ raises()

void AST::Builder::raises ( const ScopedNames names)

Set raises for the current operation.

Parameters
namesException names.

◆ operation_context()

void AST::Builder::operation_context ( const Variants &  strings)

Set context for the current operation.

Parameters
stringsContext strings.

◆ attribute()

void AST::Builder::attribute ( bool  readonly,
Type &&  type,
const SimpleDeclarators declarators 
)

Add attributes to the current interface or valuetype.

Parameters
readonlytrue if attributes are read-only.
typeThe attributes type.
declaratorsThe attribute names.

◆ attribute_begin()

void AST::Builder::attribute_begin ( bool  readonly,
Type &&  type,
const SimpleDeclarator name 
)

Begin attribute definition for the current interface or valuetype.

Parameters
readonlytrue if attribute is read-only.
typeThe attribute type.
nameThe attribute name.

◆ getraises()

void AST::Builder::getraises ( const ScopedNames names)

Set getraises for the current attribute.

Parameters
namesException names.

◆ setraises()

void AST::Builder::setraises ( const ScopedNames names)

Set setraises for the current attribute.

Parameters
namesException names.

◆ type_def()

void AST::Builder::type_def ( Type &&  type,
const Declarators declarators 
)

Create type alias.

Parameters
typeThe type.
declaratorsType aliases.

◆ struct_decl()

void AST::Builder::struct_decl ( const SimpleDeclarator name)

Create structure forward declaration.

Parameters
nameThe structure name.

◆ struct_begin()

void AST::Builder::struct_begin ( const SimpleDeclarator name)

Begin of the structure definition.

Parameters
nameThe structure name.

◆ struct_end()

const NamedItem* AST::Builder::struct_end ( )
inline

End of the structure definition.

Returns
The pointer to definition.

Definition at line 235 of file Builder.h.

◆ exception_begin()

void AST::Builder::exception_begin ( const SimpleDeclarator name)

Begin of the exception definition.

Parameters
nameThe exception name.

◆ member()

void AST::Builder::member ( Type &&  type,
const Declarators names 
)

Add members to the current structure or exception.

Parameters
typeThe members type.
namesThe member names.

◆ union_decl()

void AST::Builder::union_decl ( const SimpleDeclarator name)

Create union forward declaration.

Parameters
nameThe union name.

◆ union_begin()

void AST::Builder::union_begin ( const SimpleDeclarator name,
const Type switch_type,
const Location type_loc 
)

Begin of the union definition.

Parameters
nameThe union name.
switch_typeThe union discriminator type.
type_locDiscriminator type location.

◆ union_label()

void AST::Builder::union_label ( const Variant label,
const Location loc 
)

Create label for the current union.

Parameters
labelThe constant.
locThe label location.

◆ union_default()

void AST::Builder::union_default ( const Location loc)

Create default label for the current union.

Parameters
locThe label location.

◆ union_element()

void AST::Builder::union_element ( Type &&  type,
const Declarator decl 
)

Create union element for the current label.

Parameters
typeThe element type.
declThe element name.

◆ union_end()

const NamedItem* AST::Builder::union_end ( )

End of the union definition.

Returns
The pointer to definition.

◆ enum_type()

const NamedItem* AST::Builder::enum_type ( const SimpleDeclarator name,
const SimpleDeclarators items 
)

Create enum type.

Parameters
nameThe enum type name.
itemsThe enum items.
Returns
The pointer to definition.

◆ valuetype_decl()

void AST::Builder::valuetype_decl ( const SimpleDeclarator name,
bool  is_abstract = false 
)

Create valuetype forward declaration.

Parameters
nameThe valuetype name.
is_abstracttrue for abstract valuetype.

◆ valuetype_begin()

void AST::Builder::valuetype_begin ( const SimpleDeclarator name,
ValueType::Modifier  mod = ValueType::Modifier::NONE 
)

Begin valuetype definition.

Parameters
nameThe valuetype name.
modThe valuetype modifier.

◆ valuetype_bases()

void AST::Builder::valuetype_bases ( bool  truncatable,
const ScopedNames bases 
)

Set current valuetype bases.

Parameters
truncatabletrue if valuetype is truncatable.
basesBase names.

◆ valuetype_supports()

void AST::Builder::valuetype_supports ( const ScopedNames interfaces)

Set current valuetype supported interfaces.

Parameters
interfacesSupported interface names.

◆ state_member()

void AST::Builder::state_member ( bool  is_public,
Type &&  type,
const Declarators names 
)

Add members to the current valuetype.

Parameters
is_publictrue for public members.
typeThe members type.
namesThe member names.

◆ valuetype_factory_begin()

void AST::Builder::valuetype_factory_begin ( const SimpleDeclarator name)

Begin valuetype factory.

Parameters
nameThe valuetype factory name.

◆ valuetype_factory_end()

void AST::Builder::valuetype_factory_end ( )
inline

End valuetype factory.

Parameters
nameThe valuetype factory name.

Definition at line 335 of file Builder.h.

◆ valuetype_box()

void AST::Builder::valuetype_box ( const SimpleDeclarator name,
Type &&  type 
)

Create value box definition.

Parameters
nameThe value box name.
typeBoxed type.

◆ constant() [1/2]

void AST::Builder::constant ( Type &&  t,
const SimpleDeclarator name,
Variant &&  val,
const Location loc 
)

Create constant definition.

Parameters
tThe constant type.
nameThe constant name.
valThe constant value.
locThe constant value location.

◆ constant() [2/2]

void AST::Builder::constant ( Type &&  t,
const SimpleDeclarator name 
)

Create interface constant definition (Nirvana extension).

Parameters
tThe constant type.
nameThe constant name.

◆ lookup_type()

Type AST::Builder::lookup_type ( const ScopedName scoped_name)

Find type by name.

Parameters
scoped_nameThe scoped name.
Returns
Type.

The documentation for this class was generated from the following file: