Chapter 3. Obix's EBNF

Root Software Elements (RSE)

Table 3.1. Root Software Elements EBNF

ProductionSyntaxLinks
root_software_element (RSE)

-> type
-> factory
-> service

 
/* types */
type

"type" ( "id" ":" ) ? type_id ( "default_factory" ":" ( "yes" | "no" ) ) ?
   RSE_java_code ?
   inherited_type_list ?
   attribute_list ?
   attribute_list_check ?
   command_list ?
   event_list ?
   RSE_test_script ?
"end" "type" ?

the section called “Type”
inherited_type_list 
simple_inherited_type_list"inherit" type_selector ( ";" type_selector ) * "end"Chapter 15, Type inheritance
redefined_inherited_type

"inherit" type_selector
   redefined_attribute_list ?
   redefined_command_list ?
   redefined_event_list ?
"end" "inherit" ?

Chapter 18, Feature redefinition
.
enumerated_type

"type" ( "id" ":" ) ? type_id
   "enumerated" enumerated_id ( ";" enumerated_id ) * "end"
"end" "type" ?

Chapter 11, Enumerated type
.
generic_type

"generic" "type" ( "id" ":" ) ? generic_type_id
   generic_parameter +
   type
"end" "generic" ?

Remarks:

  • properties id and default_factory must not be specified for type
  • each time a generic_parameter is used in the source code of type, it must be enclosed between { and }
Chapter 19, Generic types
generified_type

"type" ( "id" ":" ) ? type_id
   generic_type_selector
"end" "type" ?

Chapter 19, Generic types
/* factory */
factory

"factory" ( "id" ":" ) ? factory_id "type" ":" type_selector
   RSE_java_code ?
   attribute_list ?
   command_list ?
   creator_list
   RSE_test_script ?
"end" "factory" ?

the section called “Factory”
.
generic_factory

"generic" "factory" ( "id" ":" ) ? generic_factory_id
   generic_parameter *
   factory
"end" "generic" ?

Remark: property 'id' must not be specified for 'factory'

Chapter 19, Generic types
generified_factory

"factory" ( "id" ":" ) ? factory_id "type" ":" type_selector
   generic_factory_selector
"end" "factory" ?

Chapter 19, Generic types
/* service */
service

"service" ( "id" ":" ) ? service_id
   RSE_java_code ?
   attribute_list ?
   attribute_list_check ?
   command_list ?
   event_list ?
   RSE_test_script ?
"end" "service" ?

the section called “Service”
/* common RSE components */
RSE_java_code

"java"
   // any valid Java source code
"end java"

 
generic_parameter

"param" ( "id" ":" ) ? generic_parameter_id "end"

 
/* source code template */
source_code_template

"template" ( "id" ":" ) ? source_code_template_id
   template_parameter *
   ( fixed_source_source | variable_template_source_code ) +
"end" "template" ?

Chapter 20, Source code templates
template_parameter

"param" ( "id" ":" ) ? template_parameter_id "end"

 
variable_template_source_code  

Features

Table 3.2. Features EBNF

ProductionSyntaxLinks
/* attributes */
attribute_list( attribute | attributes_with_common_properties ) + 
attribute

"attribute" ( "id" ":" ) ? attribute_id attribute_properties
   check_script ?
   default_script ?
   get_script ?
   set_script ?
"end" "attribute" ?

the section called “Attribute”
attributes_with_common_properties

"attribute_list" common_attribute_properties
   attribute +
"end" "attribute_list" ?

 
attribute_list_check

-> "attribute_check" check_property "end"

-> "attribute_check"
      script
   "end" "attribute_check" ?

the section called “Property attribute_check
/* commands */
command_list( command | commands_with_common_properties ) + 
command

"command" ( "id" ":" ) ? command_id command_properties
   input_argument *
   in_check ?
   output_argument *
   out_check ?
   script ?
"end" "command" ?

the section called “Command”
commands_with_common_properties

"command_list" common_command_properties
   command +
"end" "command_list" ?

 
/* creators */
creator_list( creator | creators_with_common_properties ) + 
creator

"creator" ( "id" ":" ) ? command_id command_properties
   input_argument *
   in_check ?
   output_argument *
   out_check ?
   script
"end" "creator" ?

the section called “Creator”
creators_with_common_properties

"creator_list" common_command_properties
   creator +
"end" "creator_list" ?

 
/* command/creator input/output */
input_argument

"in" ( "id" ":" ) ? input_argument_id &
   object_type_selector_property &
   voidable_property ? &
   check_property ? &
   default_property ?

   check_script ?
   default_script ?
"end" "in" ?

the section called “Input and output arguments”
output_argument

"out" ( "id" ":" ) ? output_argument_id &
   object_type_selector_property &
   voidable_property ? &
   check_property ?

   check_script ?
"end" "out" ?

the section called “Input and output arguments”
in_check

-> "in_check" check_property "end"

-> "in_check"
      script
   "end" "in_check" ?

out_check

-> "out_check" check_property "end"

-> "out_check"
      script
   "end" "out_check" ?

/* events */
event_list( event | events_with_common_properties ) + 
event

"event" ( "id" ":" ) ? event_id event_properties "end"

the section called “Event”
events_with_common_properties

"event_list" common_event_properties
   event +
"end" "event_list" ?

 

Feature properties

Table 3.3. Feature properties EBNF

ProductionSyntaxLinks
attribute_propertiesTable 6.2, “Attribute properties”
command_propertiesTable 6.8, “Command properties”
event_propertiesthe section called “Event declaration instruction”
.
object_type_selector_property"type" ":" object_type_selector
voidable_property"voidable" ":" ( "yes" | "no" )
check_property"check" ":" condition error_info ?
default_property"default" ":" expression
private_property"private" ":" ( "yes" | "no" )
attribute_kind_property"kind" ":" ( "constant" | "variable" | "readonly_constant" | "readonly_variable" )the section called “Attribute property kind
setable_property"setable" ":" ( "all" | "factory" | "service" | "creator" | "none" )the section called “Attribute property setable
obsolete_property"obsolete" ":" ( "yes" | "no" )
creator_kind_property"kind" ":" ( "standard" | "in_all" )the section called “Creator”

Scripts

Table 3.4. Scripts EBNF

ProductionSyntaxLinks
check_script

"check"
   script
"end" "check" ?

the section called “Check scripts”
default_script

"default"
   script
"end" "default" ?

the section called “Default scripts”
get_script

"get"
   script
"end" "get" ?

the section called “Attribute get script”
set_script

"set"
   script
"end" "set" ?

the section called “Attribute set script”
.
script

"script"
   script_instruction *
"end" "script" ?
test_script ?

Chapter 7, Scripts
.
test_script

"test"
   "script"
      script_instruction *
   "end" "script" ?
"end" "test" ?

the section called “test script”

Script instructions

Table 3.5. Script instructions EBNF

ProductionSyntaxLinks
script_instruction

/* assignments */
-> variable_declaration
-> constant_declaration
-> assignment

/* script execution */
-> object_command_execution
-> script_execution

/* flow control */
-> if_then_else
-> case_type_of
-> exit_script

/* loops */
-> repeat_while
-> repeat_for_each
-> repeat_from_to
-> repeat_times
-> repeat_forever
-> exit_repeat
-> next_repeat

/* events */
-> generate_event
-> on_event
-> stop_event_handler

/* error handling */
-> check
-> check_script_instruction
-> error

/* testing */
-> test
-> verify
-> verify_error

/* embedded Java */
-> java

Chapter 8, Script instructions
/* assignments */
variable_declaration_instruction "var" object_type_selector variable_id ( ";" variable_id ) * ( "=" expression assignment_tail ? ) ? the section called “Variable declaration instruction”
constant_declaration_instruction "const" object_type_selector constant_id "=" expression assignment_tail ? the section called “Constant declaration instruction”
assignment_instruction assignable_object_reference_selector "=" expression assignment_tail ? the section called “Assignment instruction”
assignment_tail type_check_clause ? on_error_clause ? the section called “Assignment tail”
/* script execution */
object_command_execution_instruction object_reference_selector "." command_id input_assignment_list ? output_assignment_list ? script_execution_tail ? the section called “Object command execution instruction”
script_execution_instruction RSE_script_selector input_assignment_list ? output_assignment_list ? script_execution_tail ? the section called “Script execution instruction”
script_execution_tail on_error_clause ? the section called “Script execution tail”
/* flow control */
if_then_else_instruction

"if" expression "then"
   script_instruction *
( "else" "if" expression "then"
   script_instruction * ) *
( "else"
   script_instruction * ) ?
"end" "if" ?

the section called “if then else instruction”
case_type_of_instruction

"case" "type" "of" expression
   case_type_of_when_clause +
   ( "otherwise"
      script_instruction * ) ?
"end" "case" ?

the section called “case type of instruction”
case_type_of_when_clause

-> "when" type_selector constant_id "then"
      script_instruction *

-> "when" type_selector ( ";" type_selector ) * "then"
      script_instruction *

the section called “case type of instruction”
exit_script_instruction "exit" "script" the section called “exit script instruction”
/* loops */
repeat_while_instruction

"repeat" "while" expression repeat_tail ?
   script_instruction *
"end" "repeat" ?

remark: expression must be of type yes_no

the section called “repeat while instruction”
repeat_for_each_instruction

"repeat" "for" "each" ( "item" ? | "key" | "value" ) object_type_selector variable_id "in" expression repeat_tail ?
   script_instruction *
"end" "repeat" ?

remarks:

  • expression must be of type iteratable
  • object_type_selector must denote the type of the items in the iteratable object
  • "key" and "value" can be used to specify the iteration over keys or values in a map

the section called “repeat for each instruction”
repeat_from_to_instruction

"repeat" "from" object_type_selector ? variable_id "=" expression "down" ? "to" expression ( "step" step_expression ) ? repeat_tail ?
   script_instruction *
"end" "repeat" ?

remarks:

  • expression must be of type signed_integer32 (or any sub-type)
  • the default value for object_type_selector is ty_positive32
  • step_expression must be of type positive32 (or any sub-type)
  • the default value for step is 1

the section called “repeat from to instruction”
repeat_times_instruction

"repeat" expression "times" repeat_tail ?
   script_instruction *
"end" "repeat" ?

remark: expression must be of type positive32

the section called “repeat times instruction”
repeat_forever_instruction

"repeat" "forever" repeat_tail ?
   script_instruction *
"end" "repeat" ?

the section called “repeat forever instruction”
repeat_tail( "counter" ":" variable_id ) ? ( "id" ":" identifier ) ?the section called “repeat tail”
exit_repeat_instruction "exit" "repeat" identifier ?

remarks:

  • if identifier is omitted then the innermost repeat loop is exited in case of several nested repeat loops
  • if identifier is specified, then the repeat loop identified by identifier is exited

the section called “exit repeat instruction”
next_repeat_instruction "next" "repeat" identifier ?

remarks:

  • if identifier is omitted then the innermost repeat loop is concerned in case of several nested repeat loops
  • if identifier is specified, then the repeat loop identified by identifier is concerned

the section called “next repeat instruction”
/* events */
generate_event_instruction"generate" "event" event_id "from" expressionthe section called “generate event instruction”
on_event_instruction"on" "event" event_id_list ( "in" event_source ) ? "execute" event_handler ( "handler" ":" variable_id ) ?the section called “on event instruction”
stop_event_handler_instruction"stop" "event" "handler" expressionthe section called “stop event handler instruction”
event_source

-> "object" ? expression
-> "service" service_selector

 
event_id_list

-> event_id ( ; event_id ) *
-> "*"

 
event_handler

-> "command" ? command_id ( "in" expression ) ?
-> "script" RSE_script_selector

 
/* error handling */
check_instruction "check" condition error_info ? the section called “check instruction”
check_script_instruction "check" "script" condition error_info ? the section called “check script instruction”
error_instruction "error" expression ( "id" ":" identifier ) ? ( "data" ":" expression ) ? the section called “error instruction”
/* testing */
test_instruction "test" input_assignment * the section called “test instruction”
verify_instruction "verify" condition error_info ? the section called “verify instruction”
verify_error_instruction "verify" "error" error_info ? the section called “verify error instruction”
/* embedded Java */
java_instruction

"java"
   // any Java source code
"end java"

the section called “java instruction”

Script instruction components

Table 3.6. Script instruction components EBNF

ProductionSyntaxLinks
object_reference_selectorobject_reference ( "." attribute_id ) * 
assignable_object_reference_selectorassignable_object_reference ( "." attribute_id ) * 
object_reference  
assignable_object_reference  
object_type_selector

-> type_selector
-> type_selector "." "enumerated"
-> type_selector "." "factory_instance"
-> generic_type_selector
-> generic_type_selector "." "factory_instance"

 
type_check_clause "type_check" ":" ( "yes" | "no" )

"remark: default value is yes

 
on_error_clause "on_error" ":" ( "exit_script" | "continue" )

"remark: default value is exit_script

 
input_assignment_list"(" input_assignment ( ";" ? input_assignment ) * ")" 
output_assignment_list "(" output_assignment ( ";" ? output_assignment ) * ")"

remark: if there are no input arguments assigned then the output argument assignment list must be preceded by () to indicate an empty input argument assignment list

 
input_assignment ( input_argument_id "=" ) ? expression

remark: input_argument_id = can only be omitted if the called script has exactly one input argument

 
output_assignmentassignable_object_reference_selector "=" output_argument_id 
condition the section called “condition
error_info ( "error_message" ":" expression ) ? ( "error_id" ":" identifier ) ? ( "error_data" ":" expression ) ? the section called “error info

Expressions

Table 3.7. Expressions EBNF

ProductionSyntaxLinks
expressionand_expression ( ( "or" | "xor" ) and_expression ) *Chapter 9, Expressions and operators
and_expressioncompare_expression ( "and" compare_expression ) * 
compare_expressionadd_expression comparison_operator add_expression 
comparison_operator"=r" | "=v" | "#r" | "#v" | ">" | ">=" | "<" | "<=" 
add_expressionmultiply_expression ( ( "+" | "-" | "&" ) multiply_expression ) * 
multiply_expressionsign_expression ( ( "*" | "/" ) sign_expression ) * 
sign_expression( "not" | "-" | "+" ) ? expression_path 
expression_pathexpression_value ( "." attribute_id_or_command_output ) * 
expression_value

-> literal
-> object_reference
-> script_output
-> "(" expression ")"
-> "iif" expression "then" expression "else" expression "end" "if" ?
-> "this"

 
attribute_id_or_command_output 
script_outputRSE_script_selector ( "." output_argument_id ) ? input_assignment_list ? 

Selectors

Table 3.8. Selectors EBNF

ProductionSyntaxLinks
/* RSE selectors */
RSE_selector 
type_selector( library_selector "." ) ? type_id 
factory_selector( library_selector "." ) ? factory_id 
service_selector( library_selector "." ) ? service_id 
library_selectorlibrary_id ( "." library_id ) * 
/* generic type selector */
generic_type_selector"!" ( library_selector "." ) ? generic_type_id generic_type_parameter_assignments ?Chapter 19, Generic types
generic_type_parameter_assignments"<" generic_type_parameter_assignment ( ";" ? generic_type_parameter_assignment ) * ">" 
generic_type_parameter_assignment ( generic_type_parameter_id ":" ) ? object_type_selector

remark: generic_type_parameter_id : can only be omitted if the generic_type has exactly one parameter

 
/* generic factory selector */
generic_factory_selector"!" ( library_selector "." ) ? generic_factory_id generic_type_parameter_assignments ?Chapter 19, Generic types
/* source code template selector */
template_selector"%" ( library_selector "." ) ? source_code_template_id template_parameter_assignments ?Chapter 20, Source code templates
template_parameter_assignments"<" template_parameter_assignment ( ";" ? template_parameter_assignment ) * ">" 
template_parameter_assignment ( template_parameter_id ":" ) ? quoted_string_literal

remark: template_parameter_id : can only be omitted if the source code template has exactly one parameter

 
/* script selectors */
RSE_script_selector( RSE_selector "." ) ? script_selector 
script_selectorthe section called “Introduction to scripts”
command_script_selectorcommand_idthe section called “Command script”
attribute_get_script_selectorattribute_idthe section called “Attribute get script”
attribute_set_script_selectorattribute_id "=" expressionthe section called “Attribute set script”
command_in_check_script_selectorcommand_id "." "in_check"the section called “Command in_check script”
command_out_check_script_selectorcommand_id "." "out_check"the section called “Command out_check script”
attribute_list_check_script_selector"attribute_check"the section called “attribute_check script”
input_argument_check_script_selectorcommand_id "." input_argument_id "." "check"the section called “Input argument check script”
output_argument_check_script_selectorcommand_id "." output_argument_id "." "check"the section called “Output argument check script”
attribute_check_script_selectorattribute_id "." "check"the section called “Attribute check script”
input_argument_default_script_selectorcommand_id "." input_argument_id "." "default"the section called “Input argument default script”
attribute_default_script_selectorattribute_id "." "default"the section called “Attribute default script”
test_script_selectorthe section called “test script”
script_test_script_selectorRSE_script_selector "." "co_test_" 
RSE_test_script_selectorRSE_selector "." "co_test_" 

Identifiers

Table 3.9. Identifiers EBNF

ProductionSyntaxLinks
   
library_id"li_" ? identifier 
type_id"ty_" ? identifier 
factory_id"fa_" ? identifier 
service_id"se_" ? identifier 
command_id"co_" ? identifier 
event_id"ev_" ? identifier 
enumerated_id"en_" ? identifier 
attribute_id"a_" ? identifier 
input_argument_id"i_" ? identifier 
output_argument_id"o_" ? identifier 
variable_id"v_" ? identifier 
constant_id"c_" ? identifier 
generic_type_id"ge_" ? identifier 
generic_factory_id"ge_" ? identifier 
generic_parameter_id"pa_" ? identifier 
source_code_template_id"te_" ? identifier 
template_parameter_id"pa_" ? identifier 
.
prefixed_identifier identifier_prefix identifier_prefix_terminator identifier the section called “Prefixed identifier”
identifier_prefix letter *  
identifier_prefix_terminator "_"  
.
identifier letter ( letter | digit | "_" ) * the section called “Simple identifier”

Literals

Table 3.10. Literals EBNF

ProductionSyntaxLinks
literal 
/* strings */
string_literalthe section called “String literal”
quoted_string_literal '"' ( Unicode_character | escape_character ) * '"'

remark: Unicode_character cannot be '"' or '\' or <carriage_return> or <line_feed>

the section called “Quoted string literal”
triple_apostrophed_string_literal "'''" Unicode_character * "'''"

remark: characters are never escaped (e.g. '''\\''' yields \\)

the section called “Triple apostrophed string literal”
triple_quoted_string_literal '"""' ( Unicode_character | embedded_string_literal_expression ) * '"""'

remark: characters are never escaped (e.g. """\\""" yields \\)

the section called “Triple quoted string literal”
embedded_string_literal_expression "{{" expression "}}"

remark: expression must be of type string

the section called “Triple quoted string literal”
configurable_string_literalremark: not yet availablethe section called “Configurable string literal”
.
character_literal "'" ( Unicode_character | escape_character ) "'"

remark: Unicode_character cannot be "'" or "\" or <carriage_return> or <line_feed>

the section called “Character literal”
.
integer_literalunary_minus ? digit +the section called “Integer literal”
unary_minus"-" 
.
yes_no_literal"yes" | "no"the section called “Yes_no literal”
.
void_literal"void"the section called “Void literal”
.
Unicode_characterany Unicode_character, like A, B, C, 1, 2, 3, +, -, %, and so on 
escape_character

-> "\b"   /* backspace */
-> "\f"   /* form feed */
-> "\n"   /* line feed */
-> "\r"   /* carriage return */
-> "\t"   /* horizontal tab */
-> '\"'   /* quote (double quote) */
-> "\'"   /* apostrophe (single quote) */
-> "\\"   /* backslash */
-> "\u" hex_digit hex_digit hex_digit hex_digit   /* hexadecimal Unicode character definition */

 
.
letterlowercase_letter | uppercase_letter 
lowercase_letter"a" | "b" | "c" | ... | "x" | "y" | "z" 
uppercase_letter"A" | "B" | "C" | ... | "X" | "Y" | "Z" 
.
hex_digit

-> digit 
-> "a" | "b" | "c" | "d" | "e" | "f"
-> "A" | "B" | "C" | "D" | "E" | "F"

 
digit"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"