Dsl syntax
caution
This doc is written manually. The implementation may differ. If it does, then either this doc is wrong or the implementation is wrong. In any case, them disagreeing is a bug. Please file an issue!
warning
While something may be valid to be parsed, it may not be valid as a construct and may generate an error deeper down.
Top-level item is Device.
- '*' is used to signal 0 or more instances.
- '?' is used to signal 0 or 1 instances.
- '|' is used as an 'or'. One of the options in the chain can be used.
- '( )' is used to group things together.
- Any
keywordor brackets in the grammar use backticks just like word 'keyword' on this line.
This doesn't map perfectly on the YAML and JSON inputs, but they should be made as close as possible.
Device:
GlobalConfigList
ObjectList
GlobalConfigList:
(
config{GlobalConfig*})?
GlobalConfig:
(
typeDefaultRegisterAccess=Access;)
| (typeDefaultFieldAccess=Access;)
| (typeDefaultBufferAccess=Access;)
| (typeDefaultByteOrder=ByteOrder;)
| (typeDefaultBitOrder=BitOrder;)
| (typeRegisterAddressType=IntegerType;)
| (typeCommandAddressType=IntegerType;)
| (typeBufferAddressType=IntegerType;)
| (typeNameWordBoundaries=NameWordBoundaries;)
| (typeDefmtFeature=String;)
NameWordBoundaries: This specifies the input, not the output. Only applies to object and field names.
[Boundary*]
| String
ObjectList:
(Object(
,Object)*,?)?
Object:
Block
| Register
| Command
| Buffer
| RefObject
RefObject: An object that is a copy of another object. Any items in the object are overrides.
AttributeList
refIDENTIFIER=Object
AttributeList:
Attribute*
Attribute: Used for documentation and conditional compilation
(
#[doc=STRING])
| (#[cfg(ConfigurationPredicate)])
Block:
AttributeList
blockIDENTIFIER{BlockItemList ObjectList}
BlockItemList:
BlockItem*
BlockItem:
(
constADDRESS_OFFSET=INTEGER;)
| (constRepeat)
Register:
AttributeList
registerIDENTIFIER{RegisterItemList FieldList}
RegisterItemList:
RegisterItem*
RegisterItem:
(
typeAccess=Access;)
| (typeByteOrder=ByteOrder;)
| (typeBitOrder=BitOrder;)
| (constADDRESS=INTEGER;)
| (constSIZE_BITS=INTEGER;)
| (constRESET_VALUE=INTEGER | U8_ARRAY;)
| (constRepeat)
| (constALLOW_BIT_OVERLAP= BOOL;)
| (constALLOW_ADDRESS_OVERLAP= BOOL;)
Access:
(
ReadWrite|RW)
| (ReadOnly|RO)
| (WriteOnly|WO)
ByteOrder:
LE|BE
BitOrder:
LSB0|MSB0
FieldList:
(Field (
,Field)*,?)
Field:
AttributeList
IDENTIFIER:Access? BaseType FieldConversion?=FieldAddress
FieldConversion:
(
astry? TYPE_PATH)
| (astry?enumIDENTIFIER{EnumVariantList})
EnumVariantList:
EnumVariant(
,EnumVariant)*,?
EnumVariant:
AttributeList
IDENTIFIER (=EnumValue)?
EnumValue:
INTEGER|
default|catch_all
FieldAddress:
INTEGER
| (INTEGER..INTEGER)
| (INTEGER..=INTEGER)
BaseType:
bool|uint|int
Command:
AttributeList
commandIDENTIFIER CommandValue?
CommandValue:
(
=INTEGER)
| ({CommandItemList (in{FieldList},?)? (out{FieldList},?)?})
CommandItemList:
CommandItem*
CommandItem: Commands have data going in and out, so they need two separate data field types. If no in fields, then no data is sent. If no out fields, then no data is returned.
(
typeByteOrder=ByteOrder;)
| (typeBitOrder=BitOrder;)
| (constADDRESS=INTEGER;)
| (constSIZE_BITS_IN=INTEGER;)
| (constSIZE_BITS_OUT=INTEGER;)
| (constRepeat)
| (constALLOW_BIT_OVERLAP= BOOL;)
| (constALLOW_ADDRESS_OVERLAP= BOOL;)
Repeat:
REPEAT={count:INTEGER,stride:INTEGER,?};
Buffer:
AttributeList
bufferIDENTIFIER(:Access)? (=INTEGER)?