Difference between revisions of "Language Reference/Attributes"

From wiki.visual-prolog.com
(→‎Insertion Points: Formal arguments)
(→‎Insertion Points: Attribtes are optional)
Line 21: Line 21:


<vipbnf><InterfaceDeclaration> :
<vipbnf><InterfaceDeclaration> :
   interface <IinterfaceName> <Attributes> <ScopeQualifications> <Sections> end interface <IinterfaceName>-opt</vipbnf>
   interface <IinterfaceName> <Attributes>-opt <ScopeQualifications> <Sections> end interface <IinterfaceName>-opt</vipbnf>


<vipbnf><ClassDeclaration> :
<vipbnf><ClassDeclaration> :
   class <ClassName> <ConstructionType>-opt <Attributes> <ScopeQualifications> <Sections> end class <ClassName>-opt</vipbnf>
   class <ClassName> <ConstructionType>-opt <Attributes>-opt <ScopeQualifications> <Sections> end class <ClassName>-opt</vipbnf>


<vipbnf><ClassImplementation> :
<vipbnf><ClassImplementation> :
   implement <ClassName> <Attributes> <ScopeQualifications> <Sections> end implement <ClassName>-opt</vipbnf>
   implement <ClassName> <Attributes>-opt <ScopeQualifications> <Sections> end implement <ClassName>-opt</vipbnf>


The attributes of constants, domains, predicates, properties and facts is at the end (i.e. right before the terminating dot).
The attributes of constants, domains, predicates, properties and facts is at the end (i.e. right before the terminating dot).


<vipbnf><ConstantDefinition>: one of
<vipbnf><ConstantDefinition>: one of
     <ConstantName> = <ConstantValue> <Attributes>
     <ConstantName> = <ConstantValue> <Attributes>-opt
     <ConstantName> : <TypeName> = <ConstantValue> <Attributes></vipbnf>
     <ConstantName> : <TypeName> = <ConstantValue> <Attributes>-opt</vipbnf>


<vipbnf><DomainDefinition>:
<vipbnf><DomainDefinition>:
     <DomainName> <FormalTypeParameterList>-opt = <TypeExpression> <Attributes></vipbnf>
     <DomainName> <FormalTypeParameterList>-opt = <TypeExpression> <Attributes>-opt</vipbnf>


<vipbnf><PredicateDeclaration> :
<vipbnf><PredicateDeclaration> :
   <PredicateName> : <PredicateDomain> <LinkName>-opt <Attributes>
   <PredicateName> : <PredicateDomain> <LinkName>-opt <Attributes>-opt
   <PredicateName> : <PredicateDomainName> <LinkName>-opt <Attributes></vipbnf>
   <PredicateName> : <PredicateDomainName> <LinkName>-opt <Attributes>-opt</vipbnf>


<vipbnf><PropertyDeclaration> :
<vipbnf><PropertyDeclaration> :
     <PropertyName> : <PropertyType> <FlowPattern>-list-opt <Attributes></vipbnf>
     <PropertyName> : <PropertyType> <FlowPattern>-list-opt <Attributes>-opt</vipbnf>


<vipbnf><FactDeclaration> :
<vipbnf><FactDeclaration> :
   <FactVariableDeclaration> <Attributes>
   <FactVariableDeclaration> <Attributes>-opt
   <FactFunctorDeclaration> <Attributes></vipbnf>
   <FactFunctorDeclaration> <Attributes>-opt</vipbnf>


The attributes of formal arguments is at the end.
The attributes of formal arguments is at the end.


<vipbnf><FormalArgument> :
<vipbnf><FormalArgument> :
     <TypeExpression> <ArgumentName>-opt <Attributes></vipbnf>
     <TypeExpression> <ArgumentName>-opt <Attributes>-opt</vipbnf>


=== Specific Attributes ===
=== Specific Attributes ===

Revision as of 15:57, 17 March 2010

Template:Preliminary Documentation


Various definitions and declarations can be annotated with attributes. This section describes the general syntax of attributes and where they can be placed. It also describes the meaning of the specific attributes.

Syntax

Attributes :
    [ Attribute-comma-sep-list ]
Attribute : one of
    LowerCaseIdentifier
    LowerCaseIdentifier ( Literal-comma-sep-list )

Where the literals must either be numbers or string literals.

Insertion Points

The attributes of interfaces, classes and implementations is right before the scope qualifications.

InterfaceDeclaration :
   interface IinterfaceName Attributes-opt ScopeQualifications Sections end interface IinterfaceName-opt
ClassDeclaration :
   class ClassName ConstructionType-opt Attributes-opt ScopeQualifications Sections end class ClassName-opt
ClassImplementation :
   implement ClassName Attributes-opt ScopeQualifications Sections end implement ClassName-opt

The attributes of constants, domains, predicates, properties and facts is at the end (i.e. right before the terminating dot).

ConstantDefinition: one of
    ConstantName = ConstantValue Attributes-opt
    ConstantName : TypeName = ConstantValue Attributes-opt
DomainDefinition:
    DomainName FormalTypeParameterList-opt = TypeExpression Attributes-opt
PredicateDeclaration :
   PredicateName : PredicateDomain LinkName-opt Attributes-opt
   PredicateName : PredicateDomainName LinkName-opt Attributes-opt
PropertyDeclaration :
    PropertyName : PropertyType FlowPattern-list-opt Attributes-opt
FactDeclaration :
   FactVariableDeclaration Attributes-opt
   FactFunctorDeclaration Attributes-opt

The attributes of formal arguments is at the end.

FormalArgument :
    TypeExpression ArgumentName-opt Attributes-opt

Specific Attributes

deprecated

The declared entity is deprecated the string literal describes how to migrate from it. The entity still exist, but usage will cause a warning. The entity will not exist in future versions of Visual Prolog.

Example
predicates
    oldFasioned : (string Arg) [deprecated("Use newFasion instead")].

retired

The declared entity is retired the string literal describes how to migrate from it. The entity does not exist anymore.

Example
predicates
    veryOldFasioned : (string Arg) [retired("Use newFasion instead")].

inline

inline alters the memory layout of a struct (i.e. a single alternative functor domain with an align qualification). The corresponding field is inlined instead of being pointed to.

Example
domains
    point = align 4 
        p(integer X, integer Y).
 
domains
    rectangle = align 4
        r(
            point UpperLeft [inline],
            point LowerRight [inline]
        ).


It is also possible to inline fixed size string and string8 fields in structs:

Example
domains
    device = align 4
        device(
            integer Id,
            string DeviceName [inline(32)]
        ).