Types
cifflow.types
Core types shared across all cifflow layers.
CifVersion
Bases: Enum
CIF specification version indicated by the #\CIF_x.x magic header.
Attributes:
| Name | Type | Description |
|---|---|---|
CIF_1_1 |
CIF 1.1 specification. |
|
CIF_2_0 |
CIF 2.0 specification. |
Source code in src/cifflow/types.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |
ValueType
Bases: Enum
Lexer-assigned encoding category for a CIF value.
Assigned by the lexer only; never modified downstream.
Attributes:
| Name | Type | Description |
|---|---|---|
MULTILINE_STRING |
Semicolon-delimited multi-line text field. |
|
TRIPLE_DOUBLE_QUOTED |
Triple double-quoted string (CIF 2.0). |
|
TRIPLE_SINGLE_QUOTED |
Triple single-quoted string (CIF 2.0). |
|
DOUBLE_QUOTED |
Double-quoted string. |
|
SINGLE_QUOTED |
Single-quoted string. |
|
STRING |
Bare (unquoted) string. |
|
PLACEHOLDER |
Bare |
Source code in src/cifflow/types.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
TokenType
Bases: Enum
Lexer token classification used in parser trace events.
Source code in src/cifflow/types.py
55 56 57 58 59 60 | |
ParseError
dataclass
Parse error event emitted when the parser encounters malformed input.
Attributes:
| Name | Type | Description |
|---|---|---|
error_type |
Literal['lexical', 'syntactic', 'semantic']
|
Category of error: |
message |
str
|
Human-readable description of the error. |
line |
int
|
1-based line number where the error was detected. |
column |
int
|
1-based column number where the error was detected. |
context |
str
|
Raw source text surrounding the error location. |
recovery_action |
str
|
Description of how the parser recovered and continued. |
Source code in src/cifflow/types.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
CifParserEvents
Bases: Protocol
Protocol that a CIF event handler must implement.
The parser calls these methods in file order as tokens are consumed. Implement this protocol to accumulate CIF content from a stream of events.
Source code in src/cifflow/types.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
on_data_block(name)
Begin a new data block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The data block name (without the |
required |
Source code in src/cifflow/types.py
98 99 100 101 102 103 104 105 106 | |
on_save_frame_start(name)
Begin a save frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The save frame name (without the |
required |
Source code in src/cifflow/types.py
108 109 110 111 112 113 114 115 116 | |
on_save_frame_end()
Close the current save frame.
Source code in src/cifflow/types.py
118 119 120 | |
add_tag(tag_name)
Register a tag name; the next add_value call supplies its value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag_name
|
str
|
Fully qualified CIF tag, e.g. |
required |
Source code in src/cifflow/types.py
122 123 124 125 126 127 128 129 130 | |
add_value(value, value_type)
Supply the value for the most recently registered tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw string value exactly as it appeared in the source file. |
required |
value_type
|
ValueType
|
Lexer-assigned encoding category for the value. |
required |
Source code in src/cifflow/types.py
132 133 134 135 136 137 138 139 140 141 142 | |
on_list_start()
Begin a CIF 2.0 list value.
Source code in src/cifflow/types.py
144 145 146 | |
on_list_end()
Close the current CIF 2.0 list value.
Source code in src/cifflow/types.py
148 149 150 | |
on_table_start()
Begin a CIF 2.0 table value.
Source code in src/cifflow/types.py
152 153 154 | |
on_table_end()
Close the current CIF 2.0 table value.
Source code in src/cifflow/types.py
156 157 158 | |
on_table_key(key, value_type)
Supply the current table key; the next add_value call is its value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Raw key string as it appeared in the source file. |
required |
value_type
|
ValueType
|
Lexer-assigned encoding category for the key. |
required |
Source code in src/cifflow/types.py
160 161 162 163 164 165 166 167 168 169 170 | |
on_loop_start(tags)
Begin a loop with the given ordered tag names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
List[str]
|
Ordered list of fully qualified tag names in the loop header. |
required |
Source code in src/cifflow/types.py
172 173 174 175 176 177 178 179 180 | |
on_loop_end()
Close the current loop.
Source code in src/cifflow/types.py
182 183 184 | |
on_error(error)
Deliver a parse error; the parser continues after recovery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
ParseError
|
Details of the error and the recovery action taken. |
required |
Source code in src/cifflow/types.py
186 187 188 189 190 191 192 193 194 | |