Parser ReferenceΒΆ
Data types, fields and formats can all be constructed from strings; in fact this is how the default constructors for these types work - taking a string and parsing it to create the right instance.
The Dtype and FieldType base classes also return the correct type based on the parsed string, for example Dtype('[u4; 10]') will give a DtypeArray instance, and FieldType('a: f32') will return a Field.
All of these types can be created more explicitly using their from_params methods, but this quickly becomes unwieldly, especially for things like formats. They are still very useful if you need to create data types and fields programmatically though.
The source of truth for the string parsing is contained in the Lark grammar file. A less exact, but easier to read summary is given in the table below. Optional elements are indicated with angle brackets <like_this>.
Class |
String Syntax |
|---|---|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|
e.g. |
|
|
|