V4 DB Record Instance Syntax

From EPICSWIKI
This page still being written...

The syntax used for record instances has to change in EPICS V4, since we now have to support structured data. While it would have been possible to modify the V3 syntax to allow for this, a complete redesign of the syntax has been done to help improve parsing, and to provide commonality between the syntax of a DB file and the string representation of structured data values passed through Channel Access.

This syntax is presented below in the form of a grammar. The conventions I'm using are as follows:

symbolBeingDefined
otherSymbol
alternateSymbol 'literal'

General Symbols

These symbols are used but not defined in the grammar:

integerConstant
floatingConstant
identifier
A legal C99 identifier. Note that C99 permits implementations to allow extended characters to be used in identifiers, but does not require it, so the use of extended characters may reduce portability and is not recommended.
stringConstant
A sequence of characters within double-quotes, using the C99 escape sequence syntax defined below
escapeSequence
simpleEscapeSequence
octalEscapeSequence
hexadecimalEscapeSequence
universalCharacterName
simpleEscapeSequence
one of: \' \" \? \\ \a \b \f \n \r \t \v
octalEscapeSequence
\d
\dd
\ddd

where d is an octal digit.

hexadecimalEscapeSequence
\xhex-digits
universalCharacterName
\uhhhh
\Uhhhhhhhh

where h is a hex digit

The following symbols are like identifier, but may have a different set of legal characters TBD (but which cannot include space).

recordName
Currently record names may contain A-Z a-z _ - ; : < > [ ]. We should probably extend that to include non-ASCII Unicode/UTF-8 characters, but no new ASCII characters
linkType
deviceType
I'd like these two to have to be valid C99 identifiers, but we could probably expand that to add some other ASCII characters if desired. No spaces, brackets or braces though, for syntax reasons.

We can be generous in what we accept as a boolean value:

booleanConstant
booleanTrue
'"' booleanTrue '"'
booleanFalse
'"' booleanFalse '"'
booleanTrue
any of '1' 'T' 'TRUE' 'True' 't' 'true' 'Y' 'YES' 'Yes' 'y' 'yes'
booleanFalse
any of '0' 'F' 'FALSE' 'False' 'f' 'false' 'N' 'NO' 'No' 'n' 'no'


Database File

I need to define these, which are really preprocessor objects:

  • comments
  • substitution macros
  • templates and ports


Record Instances

recordDefinition
recordType recordName '=' '{' recordBody '}'
recordType
identifier
recordBody
recordBodyItem
recordBody recordBodyItem

Record definitions will look very similar to a C99 structure definition with initialization in EPICS V4. For example:

ai foo:bar:temperature = {
    ...
}

Inside the body of the record definition, there are three possible kinds of statements, similar to a C assignment statement. Note these statements must all be terminated with a semi-colon (which is different from inside a struct).

recordBodyItem
'info' infoName '=' stringConstant ';'
fieldName '=' initializer ';'
extraField '=' extraInitializer ';'
infoName
identifier
stringConstant

Info items provide additional configuration data about this record that can be accessed by other software running on the IOC.

info savePeriod = "30.0";
info restorePhase = "1";
info "my favourite things" = "raindrops on roses";
fieldName
identifier
initializer
constant
'{' structAssignmentList '}'
'{' arrayAssignmentList '}'
arrayType '{' arrayAssignmentList '}'
'[' arrayCapacity ']' '{' arrayAssignmentList '}'
arrayType '[' arrayCapacity ']' '{' arrayAssignmentList '}'
linkType '{' structAssignmentList '}'
deviceType '{' structAssignmentList '}'
constant
booleanConstant
integerConstant
floatingConstant
stringConstant

The syntax for setting field values depends on the data type represented by fieldName. Basic types (numeric or string) should need no comment other than to note that numeric values should not be given inside quotes:

ai foo:bar:temperature = {
    inputSmoothing = 0.98;
    invalidValue = 1000;
    units = "Celcius";
    ...
}
structAssignmentList
initializerList
fieldName '=' initializerList
structAssignmentList ';' fieldName '=' initializerList
initializerList
initializer
initializerList ',' initializer

Initializers for a structure field look similar to a nested record body, but the rules are slightly different:

  • You can give a series of values for adjacent items using a simple comma-separated list (for a record body, you must name each field)
  • Semi-colons are required between a value and a following named item.

For example:

ai foo:bar:temperature = {
    linearConvert = {
        mode = "Linear";
        low = -12.5, 133.5
    };
    displayLimit = { 0, 100 };
    ...
}


arrayAssignmentList
initializerList
'[' integerConstant ']' '=' initializerList
arrayAssignmentList ';' '[' integerConstant ']' '=' initializerList
arrayType
'bool'
'int16'
'uint16'
'int32'
'uint32'
'float32'
'float64'
'octet'
'string'
arrayCapacity
integerConstant
integerConstant ',' arrayCapacity