tree-sitter-omega
aien-dev/tree-sitter-omega
Brought by drakestapleton
tree-sitter-omega / test / corpus / om2.txt
| 1 | ================================================================================ |
| 2 | OM-2 profile, layout, abstract, holds, hex, unroll, unsized views |
| 3 | ================================================================================ |
| 4 | |
| 5 | note OM-2 tour |
| 6 | om2 |
| 7 | layout blk 8 |
| 8 | field lo uint at 0 little |
| 9 | note fields may be separated by note lines |
| 10 | field hi uint at 4 little |
| 11 | end |
| 12 | abstract v32 ulong |
| 13 | holds v32 dup32 |
| 14 | fn v32mk x uint to v32 |
| 15 | ret seal v32 or shl ulong x 32 ulong x |
| 16 | end |
| 17 | fn seed s edit uint 8 fresh to uint |
| 18 | for i uint 8 unroll |
| 19 | put s i add i 0x9e3779b9 |
| 20 | end |
| 21 | ret get s 7 |
| 22 | end |
| 23 | fn fold a view uint * to uint |
| 24 | ret get a 0 |
| 25 | end |
| 26 | |
| 27 | -------------------------------------------------------------------------------- |
| 28 | |
| 29 | (source_file |
| 30 | (comment) |
| 31 | (profile) |
| 32 | (layout_declaration |
| 33 | (identifier) |
| 34 | (integer) |
| 35 | (field_declaration |
| 36 | (identifier) |
| 37 | (identifier) |
| 38 | (identifier) |
| 39 | (integer) |
| 40 | (identifier)) |
| 41 | (comment) |
| 42 | (field_declaration |
| 43 | (identifier) |
| 44 | (identifier) |
| 45 | (identifier) |
| 46 | (integer) |
| 47 | (identifier))) |
| 48 | (abstract_declaration |
| 49 | (identifier) |
| 50 | (identifier)) |
| 51 | (holds_declaration |
| 52 | (identifier) |
| 53 | (identifier)) |
| 54 | (function_definition |
| 55 | (identifier) |
| 56 | (parameter_list |
| 57 | (identifier) |
| 58 | (identifier)) |
| 59 | (return_type |
| 60 | (identifier)) |
| 61 | (block |
| 62 | (return_statement |
| 63 | (expression |
| 64 | (identifier) |
| 65 | (identifier) |
| 66 | (identifier) |
| 67 | (identifier) |
| 68 | (identifier) |
| 69 | (identifier) |
| 70 | (integer) |
| 71 | (identifier) |
| 72 | (identifier))))) |
| 73 | (function_definition |
| 74 | (identifier) |
| 75 | (parameter_list |
| 76 | (identifier) |
| 77 | (identifier) |
| 78 | (identifier) |
| 79 | (integer) |
| 80 | (identifier)) |
| 81 | (return_type |
| 82 | (identifier)) |
| 83 | (block |
| 84 | (for_statement |
| 85 | (identifier) |
| 86 | (expression |
| 87 | (identifier) |
| 88 | (integer) |
| 89 | (identifier)) |
| 90 | (block |
| 91 | (put_statement |
| 92 | (expression |
| 93 | (identifier) |
| 94 | (identifier) |
| 95 | (identifier) |
| 96 | (identifier) |
| 97 | (integer))))) |
| 98 | (return_statement |
| 99 | (expression |
| 100 | (identifier) |
| 101 | (identifier) |
| 102 | (integer))))) |
| 103 | (function_definition |
| 104 | (identifier) |
| 105 | (parameter_list |
| 106 | (identifier) |
| 107 | (identifier) |
| 108 | (identifier) |
| 109 | (unsized)) |
| 110 | (return_type |
| 111 | (identifier)) |
| 112 | (block |
| 113 | (return_statement |
| 114 | (expression |
| 115 | (identifier) |
| 116 | (identifier) |
| 117 | (integer)))))) |
| 118 | |
| 119 | ================================================================================ |
| 120 | Export, out parameters and diag options |
| 121 | ================================================================================ |
| 122 | |
| 123 | om2 diag release |
| 124 | export fn put32 o out uchar 4 v uint to void |
| 125 | put o 0 uchar and v 255 |
| 126 | end |
| 127 | |
| 128 | -------------------------------------------------------------------------------- |
| 129 | |
| 130 | (source_file |
| 131 | (profile |
| 132 | (identifier) |
| 133 | (identifier)) |
| 134 | (function_definition |
| 135 | (identifier) |
| 136 | (parameter_list |
| 137 | (identifier) |
| 138 | (identifier) |
| 139 | (identifier) |
| 140 | (integer) |
| 141 | (identifier) |
| 142 | (identifier)) |
| 143 | (return_type |
| 144 | (identifier)) |
| 145 | (block |
| 146 | (put_statement |
| 147 | (expression |
| 148 | (identifier) |
| 149 | (integer) |
| 150 | (identifier) |
| 151 | (identifier) |
| 152 | (identifier) |
| 153 | (integer)))))) |
| 154 | |
| 155 | ================================================================================ |
| 156 | Contracts |
| 157 | ================================================================================ |
| 158 | |
| 159 | om2 |
| 160 | fn step x uint to uint |
| 161 | requires lt x 10 |
| 162 | ensures eq result add x 1 |
| 163 | ret add x 1 |
| 164 | end |
| 165 | fn main to int |
| 166 | i = uint 0 |
| 167 | while lt i 3 |
| 168 | invariant le i 3 |
| 169 | i = step i |
| 170 | end |
| 171 | ret int sub i 3 |
| 172 | end |
| 173 | |
| 174 | -------------------------------------------------------------------------------- |
| 175 | |
| 176 | (source_file |
| 177 | (profile) |
| 178 | (function_definition |
| 179 | (identifier) |
| 180 | (parameter_list |
| 181 | (identifier) |
| 182 | (identifier)) |
| 183 | (return_type |
| 184 | (identifier)) |
| 185 | (block |
| 186 | (expression_statement |
| 187 | (expression |
| 188 | (identifier) |
| 189 | (identifier) |
| 190 | (identifier) |
| 191 | (integer))) |
| 192 | (expression_statement |
| 193 | (expression |
| 194 | (identifier) |
| 195 | (identifier) |
| 196 | (identifier) |
| 197 | (identifier) |
| 198 | (identifier) |
| 199 | (integer))) |
| 200 | (return_statement |
| 201 | (expression |
| 202 | (identifier) |
| 203 | (identifier) |
| 204 | (integer))))) |
| 205 | (function_definition |
| 206 | (identifier) |
| 207 | (return_type |
| 208 | (identifier)) |
| 209 | (block |
| 210 | (assignment |
| 211 | (identifier) |
| 212 | (expression |
| 213 | (identifier) |
| 214 | (integer))) |
| 215 | (while_statement |
| 216 | (expression |
| 217 | (identifier) |
| 218 | (identifier) |
| 219 | (integer)) |
| 220 | (block |
| 221 | (expression_statement |
| 222 | (expression |
| 223 | (identifier) |
| 224 | (identifier) |
| 225 | (identifier) |
| 226 | (integer))) |
| 227 | (assignment |
| 228 | (identifier) |
| 229 | (expression |
| 230 | (identifier) |
| 231 | (identifier))))) |
| 232 | (return_statement |
| 233 | (expression |
| 234 | (identifier) |
| 235 | (identifier) |
| 236 | (identifier) |
| 237 | (integer)))))) |