10.13.5.1 Syntax of Class Definitions

The following BNF grammar gives a concise description of the syntax of class definitions. It assumes an understanding of Prolog syntax for the following items: variable, atom, compound_term, and constant. Slot types, particularly the address, class and pointer types, were discussed in an earlier section.


class_def ::= class_begin { clause | method } class_end

class_begin ::= :- class class_name opt_class_spec .

opt_class_spec ::= empty | = class_spec

class_spec ::= multi_parent_or_slots | term_class_spec

clause ::= head opt_body .

head ::= atom | compound_term .

method ::= message_head opt_body .

message_head ::= message_goal

class_end ::= :- end_class opt_class_name .
| empty /* if followed by class_begin or eof */

message ::= atom | compound_term

multi_parent_or_slots ::= parent_or_slots { + parent_or_slots }

parent_or_slots ::= class_name | [] | [ slot_def {, slot_def } ]

slot_def ::= opt_visibility slot_name : slot_type opt_init_value

opt_visibility ::= empty | private | protected | public

opt_init_value ::= empty | = constant

term_class_spec ::= term(term opt_goal_essence)

opt_goal_essence ::= empty | , goal opt_essence

opt_essence ::= empty | , essence

essence ::= [ variable : slot_type { , variable : slot_type } ]

opt_body ::= empty | :- body

body ::= message_or_goal { , message_or_goal }

message_or_goal ::= message_goal | goal

message_goal ::= variable message_operator message

message_operator ::= << | >> | <-

opt_class_name ::= empty | class_name

class_name ::= atom

slot_name ::= atom

slot_type ::= integer
| short
| char
| unsigned_short
| unsigned_char
| float
| double
| atom
| address
| term
| class_name
| pointer(atom)


Send feedback on this subject.