Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | |||
| 11 | * <@ Input Files > | 11 | * <@ Input Files > |
| 12 | * <@ BNF Notation > | 12 | * <@ BNF Notation > |
| 13 | * <@ Sigils > | 13 | * <@ Sigils > |
| 14 | * <@ Spaces > | ||
| 14 | 2. <@ Types > | 15 | 2. <@ Types > |
| 15 | * <@ Simple Types > | 16 | * <@ Simple Types > |
| 16 | * <@ Subtyping > | 17 | * <@ Subtyping > |
| @@ -105,6 +106,16 @@ scope and nature of identifiers. · 88 unmodified lines | |||
| 105 | In this BNF syntax, we use `?IDENT` to designate an identifier | 106 | In this BNF syntax, we use `?IDENT` to designate an identifier |
| 106 | starting with the sigil `?`. | 107 | starting with the sigil `?`. |
| 107 | 108 | ||
| 109 | ~ Spaces | ||
| 110 | ~~~~~~~~ | ||
| 111 | |||
| 112 | Individual tokens in IL files must be separated by one or | ||
| 113 | more spacing characters. Both spaces and tabs are recognized | ||
| 114 | as spacing characters. In data and type definitions, newlines | ||
| 115 | can also be used as spaces to prevent overly long lines. When | ||
| 116 | exactly one of two consecutive tokens is a symbol (for example | ||
| 117 | `,` or `=` or `{`), space may be omitted. | ||
| 118 | |||
| 108 | - 2. Types | 119 | - 2. Types |
| 109 | ---------- | 120 | ---------- |
| 110 | 121 | ||
| @@ -202,9 +213,9 @@ constants by the linker. · 91 unmodified lines | |||
| 202 | 213 | ||
| 203 | `bnf | 214 | `bnf |
| 204 | LINKAGE := | 215 | LINKAGE := |
| 205 | 'export' | 216 | 'export' '\n'* |
| 206 | | 'section' SECNAME | 217 | | 'section' SECNAME '\n'* |
| 207 | | 'section' SECNAME SECFLAGS | 218 | | 'section' SECNAME SECFLAGS '\n'* |
| 208 | 219 | ||
| 209 | SECNAME := '"' .... '"' | 220 | SECNAME := '"' .... '"' |
| 210 | SECFLAGS := '"' .... '"' | 221 | SECFLAGS := '"' .... '"' |
| @@ -296,7 +307,8 @@ their size between curly braces. · 85 unmodified lines | |||
| 296 | 307 | ||
| 297 | `bnf | 308 | `bnf |
| 298 | DATADEF := | 309 | DATADEF := |
| 299 | LINKAGE* 'data' $IDENT '=' ['align' NUMBER] | 310 | LINKAGE* |
| 311 | 'data' $IDENT '=' ['align' NUMBER] | ||
| 300 | '{' | 312 | '{' |
| 301 | ( EXTTY DATAITEM+ | 313 | ( EXTTY DATAITEM+ |
| 302 | | 'z' NUMBER ), | 314 | | 'z' NUMBER ), |
| @@ -354,8 +366,9 @@ Here are various examples of data definitions. · 51 unmodified lines | |||
| 354 | 366 | ||
| 355 | `bnf | 367 | `bnf |
| 356 | FUNCDEF := | 368 | FUNCDEF := |
| 357 | LINKAGE* 'function' [ABITY] $IDENT '(' (PARAM), ')' | 369 | LINKAGE* |
| 358 | '{' | 370 | 'function' [ABITY] $IDENT '(' (PARAM), ')' '\n'* |
| 371 | '{' '\n'+ | ||
| 359 | BLOCK+ | 372 | BLOCK+ |
| 360 | '}' | 373 | '}' |
| 361 | 374 | ||
| @@ -440,25 +453,28 @@ connected using jump instructions. · 78 unmodified lines | |||
| 440 | 453 | ||
| 441 | `bnf | 454 | `bnf |
| 442 | BLOCK := | 455 | BLOCK := |
| 443 | @IDENT # Block label | 456 | @IDENT '\n'+ # Block label |
| 444 | PHI* # Phi instructions | 457 | PHILINE* # Phi instructions |
| 445 | INST* # Regular instructions | 458 | INSTLINE* # Regular instructions |
| 446 | JUMP # Jump or return | 459 | JUMP '\n'+ # Jump or return |
| 460 | |||
| 461 | PHILINE := PHI '\n'+ | ||
| 462 | INSTLINE := INST '\n'+ | ||
| 447 | 463 | ||
| 448 | All blocks have a name that is specified by a label at | 464 | All blocks have a name that is specified by a label at |
| 449 | their beginning. Then follows a sequence of instructions | 465 | their beginning. Then follows a sequence of instructions |
| 450 | that have "fall-through" flow. Finally one jump terminates | 466 | that have "fall-through" flow. Finally one jump terminates |
| 451 | the block. The jump can either transfer control to another | 467 | the block. The jump can either transfer control to another |
| 452 | block of the same function or return; they are described | 468 | block of the same function or return; jumps are described |
| 453 | further below. | 469 | further below. |
| 454 | 470 | ||
| 455 | The first block in a function must not be the target of | 471 | The first block in a function must not be the target of |
| 456 | any jump in the program. If this is really needed, | 472 | any jump in the program. If a jump to the function start |
| 457 | the frontend could insert an empty prelude block | 473 | is needed, the frontend must insert an empty prelude block |
| 458 | at the beginning of the function. | 474 | at the beginning of the function. |
| 459 | 475 | ||
| 460 | When one block jumps to the next block in the IL file, | 476 | When one block jumps to the next block in the IL file, |
| 461 | it is not necessary to give the jump instruction, it | 477 | it is not necessary to write the jump instruction, it |
| 462 | will be automatically added by the parser. For example | 478 | will be automatically added by the parser. For example |
| 463 | the start block in the example below jumps directly | 479 | the start block in the example below jumps directly |
| 464 | to the loop block. | 480 | to the loop block. |