Difference between revisions of "V4 DB Record Instance Syntax"
(Start of rework using grammar) |
|||
Line 1: | Line 1: | ||
: '''This page still being written...''' | : '''This page still being written...''' | ||
Line 7: | Line 5: | ||
This syntax is presented below in the form of a grammar. The conventions I'm using are as follows: | This syntax is presented below in the form of a grammar. The conventions I'm using are as follows: | ||
; symbolBeingDefined: | ;''symbolBeingDefined'': | ||
: otherSymbol | : ''otherSymbol'' | ||
: alternateSymbol 'literal' | : ''alternateSymbol'' 'literal' | ||
= General Symbols = | = General Symbols = | ||
Line 15: | Line 13: | ||
These symbols are used but not defined in the grammar: | These symbols are used but not defined in the grammar: | ||
;integerConstant | ;''integerConstant'' | ||
;floatingConstant | ;''floatingConstant'' | ||
;identifier | ;''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. | : 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 | ;''stringConstant'' | ||
: A sequence of characters within double-quotes, using the C99 escape sequence syntax defined below | : A sequence of characters within double-quotes, using the C99 escape sequence syntax defined below | ||
;escapeSequence | ;''escapeSequence'' | ||
: simpleEscapeSequence | : ''simpleEscapeSequence'' | ||
: octalEscapeSequence | : ''octalEscapeSequence'' | ||
: hexadecimalEscapeSequence | : ''hexadecimalEscapeSequence'' | ||
: universalCharacterName | : ''universalCharacterName'' | ||
;simpleEscapeSequence | ;''simpleEscapeSequence'' | ||
: ''one of:'' \' \" \? \\ \a \b \f \n \r \t \v | : ''one of:'' \' \" \? \\ \a \b \f \n \r \t \v | ||
;octalEscapeSequence | ;''octalEscapeSequence'' | ||
: \''d'' | : \''d'' | ||
: \''dd'' | : \''dd'' | ||
Line 37: | Line 35: | ||
where ''d'' is an octal digit. | where ''d'' is an octal digit. | ||
;hexadecimalEscapeSequence | ;''hexadecimalEscapeSequence'' | ||
: \x''hex-digits'' | : \x''hex-digits'' | ||
;universalCharacterName | ;''universalCharacterName'' | ||
: \u''hhhh'' | : \u''hhhh'' | ||
: \U''hhhhhhhh'' | : \U''hhhhhhhh'' | ||
Line 47: | Line 45: | ||
The following symbols are like identifier, but may have a different set of legal characters TBD (but which cannot include space). | The following symbols are like identifier, but may have a different set of legal characters TBD (but which cannot include space). | ||
;recordName | ;''recordName'' | ||
: ''Currently record names may contain <tt>A-Z a-z _ - ; : < > [ ]</tt>. We should probably extend that to include non-ASCII Unicode/UTF-8 characters, but no new ASCII characters'' | : '''Currently record names may contain <tt>A-Z a-z _ - ; : < > [ ]</tt>. We should probably extend that to include non-ASCII Unicode/UTF-8 characters, but no new ASCII characters''' | ||
;linkType | ;''linkType'' | ||
;deviceType | ;''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.'' | : '''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: | We can be generous in what we accept as a boolean value: | ||
;booleanConstant | ;''booleanConstant'' | ||
: booleanTrue | : ''booleanTrue'' | ||
: '"' booleanTrue '"' | : '"' ''booleanTrue'' '"' | ||
: booleanFalse | : ''booleanFalse'' | ||
: '"' booleanFalse '"' | : '"' ''booleanFalse'' '"' | ||
;booleanTrue | ;''booleanTrue'' | ||
: ''any of'' 1 T TRUE True t true Y YES Yes y yes | : ''any of'' '1' 'T' 'TRUE' 'True' 't' 'true' 'Y' 'YES' 'Yes' 'y' 'yes' | ||
: booleanFalse | : ''booleanFalse'' | ||
: ''any of'' 0 F FALSE False f false N NO No n no | : ''any of'' '0' 'F' 'FALSE' 'False' 'f' 'false' 'N' 'NO' 'No' 'n' 'no' | ||
Line 77: | Line 75: | ||
= Record Instances = | = Record Instances = | ||
;recordDefinition | ;''recordDefinition'' | ||
: recordType recordName '=' '{' recordBody '}' | : ''recordType'' ''recordName'' '=' '{' ''recordBody'' '}' | ||
;recordType | ;''recordType'' | ||
: identifier | : ''identifier'' | ||
;recordBody | ;''recordBody'' | ||
: recordBodyItem | : ''recordBodyItem'' | ||
: recordBody recordBodyItem | : ''recordBody'' ''recordBodyItem'' | ||
Record definitions will look very similar to a C99 structure definition with initialization in EPICS V4. For example: | Record definitions will look very similar to a C99 structure definition with initialization in EPICS V4. For example: | ||
Line 95: | Line 93: | ||
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). | 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 | ;''recordBodyItem'' | ||
: 'info' infoName '=' stringConstant ';' | : 'info' ''infoName'' '=' ''stringConstant'' ';' | ||
: fieldName '=' initializer ';' | : ''fieldName'' '=' ''initializer'' ';' | ||
: extraField '=' extraInitializer ';' | : ''extraField'' '=' ''extraInitializer'' ';' | ||
;infoName | ;''infoName'' | ||
: identifier | : ''identifier'' | ||
: stringConstant | : ''stringConstant'' | ||
Info items provide additional configuration data about this record that can be accessed by other software running on the IOC. | Info items provide additional configuration data about this record that can be accessed by other software running on the IOC. | ||
Line 110: | Line 108: | ||
info "my favourite things" = "raindrops on roses"; | info "my favourite things" = "raindrops on roses"; | ||
;fieldName | ;''fieldName'' | ||
: identifier | : ''identifier'' | ||
;initializer | ;''initializer'' | ||
: constant | : ''constant'' | ||
: '{' structAssignmentList '}' | : '{' ''structAssignmentList'' '}' | ||
: '{' arrayAssignmentList '}' | : '{' ''arrayAssignmentList'' '}' | ||
: arrayType '{' arrayAssignmentList '}' | : ''arrayType'' '{' ''arrayAssignmentList'' '}' | ||
: '[' arrayCapacity ']' '{' arrayAssignmentList '}' | : '[' ''arrayCapacity'' ']' '{' ''arrayAssignmentList'' '}' | ||
: arrayType '[' arrayCapacity ']' '{' arrayAssignmentList '}' | : ''arrayType'' '[' ''arrayCapacity'' ']' '{' ''arrayAssignmentList'' '}' | ||
: linkType '{' structAssignmentList '}' | : ''linkType'' '{' ''structAssignmentList'' '}' | ||
: deviceType '{' structAssignmentList '}' | : ''deviceType'' '{' ''structAssignmentList'' '}' | ||
;constant | ;''constant'' | ||
: booleanConstant | : ''booleanConstant'' | ||
: integerConstant | : ''integerConstant'' | ||
: floatingConstant | : ''floatingConstant'' | ||
: stringConstant | : ''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: | 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: | ||
Line 138: | Line 136: | ||
} | } | ||
;structAssignmentList | ;''structAssignmentList'' | ||
: initializerList | : ''initializerList'' | ||
: fieldName '=' initializerList | : ''fieldName'' '=' ''initializerList'' | ||
: structAssignmentList ';' fieldName '=' initializerList | : ''structAssignmentList'' ';' ''fieldName'' '=' ''initializerList'' | ||
;initializerList | ;''initializerList'' | ||
: initializer | : ''initializer'' | ||
: initializerList ',' initializer | : ''initializerList'' ',' ''initializer'' | ||
Initializers for a structure field look similar to a nested record body, but the rules are slightly different: | Initializers for a structure field look similar to a nested record body, but the rules are slightly different: | ||
Line 163: | Line 161: | ||
;arrayAssignmentList | ;''arrayAssignmentList'' | ||
: initializerList | : ''initializerList'' | ||
: '[' integerConstant ']' '=' initializerList | : '[' ''integerConstant'' ']' '=' ''initializerList'' | ||
: arrayAssignmentList ';' '[' integerConstant ']' '=' initializerList | : ''arrayAssignmentList'' ';' '[' ''integerConstant'' ']' '=' ''initializerList'' | ||
;arrayType | ;''arrayType'' | ||
: 'bool' | : 'bool' | ||
: 'int16' | : 'int16' | ||
Line 179: | Line 177: | ||
: 'string' | : 'string' | ||
;arrayCapacity | ;''arrayCapacity'' | ||
: integerConstant | : ''integerConstant'' | ||
: integerConstant ',' arrayCapacity | : ''integerConstant'' ',' ''arrayCapacity'' |
Revision as of 17:40, 20 May 2005
- 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