file 'tests/45.br': {
import statement: {
| `import`,
| `"std/result.br"`,
},
function declaration: {
| `fn`,
| `main`,
| `(`,
| `)`,
| block statement: {
| | `{`,
| | variable initialization: {
| | | base type: {
| | | | `var`,
| | | },
| | | name: `my_cat`,
| | | `=`,
| | | function call: {
| | | | identifier: `Animal..Cat`,
| | | | `(`,
| | | | | struct-init expression: {
| | | | | name: `AnimalInfo`,
| | | | | | `{`,
| | | | | | member-init: {
| | | | | | | `name`,
| | | | | | | `=`,
| | | | | | | function call: {
| | | | | | | | identifier: `String..from`,
| | | | | | | | `(`,
| | | | | | | | | literal (string literal): `"Whiskers"`,
| | | | | | | | `)`,
| | | | | | | },
| | | | | | },
| | | | | | member-init: {
| | | | | | | `age`,
| | | | | | | `=`,
| | | | | | | literal (integer literal): `4`,
| | | | | | },
| | | | | | `}`,
| | | | | },
| | | | | `,`,
| | | | | literal (integer literal): `3`,
| | | | `)`,
| | | },
| | },
| | variable initialization: {
| | | base type: {
| | | | `var`,
| | | },
| | | name: `my_dog`,
| | | `=`,
| | | function call: {
| | | | identifier: `Animal..Dog`,
| | | | `(`,
| | | | | struct-init expression: {
| | | | | name: `AnimalInfo`,
| | | | | | `{`,
| | | | | | member-init: {
| | | | | | | `name`,
| | | | | | | `=`,
| | | | | | | function call: {
| | | | | | | | identifier: `String..from`,
| | | | | | | | `(`,
| | | | | | | | | literal (string literal): `"Sparky"`,
| | | | | | | | `)`,
| | | | | | | },
| | | | | | },
| | | | | | member-init: {
| | | | | | | `age`,
| | | | | | | `=`,
| | | | | | | literal (integer literal): `2`,
| | | | | | },
| | | | | | `}`,
| | | | | },
| | | | | `,`,
| | | | | literal (integer literal): `3`,
| | | | `)`,
| | | },
| | },
| | expression-statement: {
| | | function call: {
| | | | identifier: `pet_animal`,
| | | | `(`,
| | | | | identifier: `my_cat`,
| | | | `)`,
| | | },
| | | `;`,
| | },
| | expression-statement: {
| | | function call: {
| | | | identifier: `pet_animal`,
| | | | `(`,
| | | | | identifier: `my_dog`,
| | | | `)`,
| | | },
| | | `;`,
| | },
| | expression-statement: {
| | | function call: {
| | | | identifier: `pet_animal`,
| | | | `(`,
| | | | | function call: {
| | | | | | identifier: `make_anacoda`,
| | | | | | `(`,
| | | | | | `)`,
| | | | | },
| | | | `)`,
| | | },
| | | `;`,
| | },
| | `}`,
| },
},
struct declaration: {
| `struct`,
| name: `AnimalInfo`,
| fields: {
| | variable declaration: {
| | | base type: {
| | | | `String`,
| | | },
| | | name: `name`,
| | },
| | variable declaration: {
| | | base type: {
| | | | `u8`,
| | | },
| | | name: `age`,
| | },
| },
},
deftype alias: {
| `deftype`,
| name: `Decibel`,
| `=`,
| type-expression: {
| | base type: {
| | | `i32`,
| | },
| },
},
deftype alias: {
| `deftype`,
| name: `Inch`,
| `=`,
| type-expression: {
| | base type: {
| | | `i32`,
| | },
| },
},
variant declaration: {
| `variant`,
| name: `Animal`,
| fields: {
| | variant field: {
| | | name: `Dog`,
| | | `(`,
| | | parameter: {
| | | | base type: {
| | | | | `AnimalInfo`,
| | | | },
| | | | name: `info`,
| | | },
| | | parameter: {
| | | | base type: {
| | | | | `Decibel`,
| | | | },
| | | | name: `barking_volume`,
| | | },
| | | `)`,
| | },
| | variant field: {
| | | name: `Cat`,
| | | `(`,
| | | parameter: {
| | | | base type: {
| | | | | `AnimalInfo`,
| | | | },
| | | | name: `info`,
| | | },
| | | parameter: {
| | | | base type: {
| | | | | `Inch`,
| | | | },
| | | | name: `whisker_length`,
| | | },
| | | `)`,
| | },
| | variant field: {
| | | name: `Snake`,
| | | `(`,
| | | parameter: {
| | | | base type: {
| | | | | `AnimalInfo`,
| | | | },
| | | | name: `info`,
| | | },
| | | `)`,
| | },
| | variant field: {
| | | name: `Lizard`,
| | | `(`,
| | | parameter: {
| | | | base type: {
| | | | | `AnimalInfo`,
| | | | },
| | | | name: `info`,
| | | },
| | | `)`,
| | },
| },
},
function declaration: {
| `fn`,
| `make_anacoda`,
| `(`,
| `)`,
| `->`,
| base type: {
| | `Animal..Snake`,
| },
| block statement: {
| | `{`,
| | return statement: {
| | | `return`,
| | | struct-init expression: {
| | | name: `Animal..Snake`,
| | | | `{`,
| | | | member-init: {
| | | | | `info`,
| | | | | `=`,
| | | | | struct-init expression: {
| | | | | name: `AnimalInfo`,
| | | | | | `{`,
| | | | | | member-init: {
| | | | | | | `name`,
| | | | | | | `=`,
| | | | | | | function call: {
| | | | | | | | identifier: `String..from`,
| | | | | | | | `(`,
| | | | | | | | | literal (string literal): `"Anacoda"`,
| | | | | | | | `)`,
| | | | | | | },
| | | | | | },
| | | | | | member-init: {
| | | | | | | `age`,
| | | | | | | `=`,
| | | | | | | literal (integer literal): `1`,
| | | | | | },
| | | | | | `}`,
| | | | | },
| | | | },
| | | | `}`,
| | | },
| | | `;`,
| | },
| | `}`,
| },
},
function declaration: {
| `fn`,
| `pet_animal`,
| `(`,
| parameter: {
| | base type: {
| | | `Animal`,
| | },
| | name: `animal`,
| },
| `)`,
| block statement: {
| | `{`,
| | variable initialization: {
| | | base type: {
| | | | `var`,
| | | },
| | | name: `state`,
| | | `=`,
| | | function call: {
| | | | identifier: `String..from`,
| | | | `(`,
| | | | | literal (string literal): `"Reaching to pet a "`,
| | | | `)`,
| | | },
| | },
| | expression-statement: {
| | | match-expression: {
| | | `match`,
| | | | `(`,
| | | | identifier: `animal`,
| | | | `)`,
| | | | match-branch: {
| | | | | variant decomposition: {
| | | | | | name: `Animal..Cat`,
| | | | | | `(`,
| | | | | | parameter: {
| | | | | | | base type: {
| | | | | | | | `var`,
| | | | | | | },
| | | | | | | name: `info`,
| | | | | | },
| | | | | | parameter: {
| | | | | | | base type: {
| | | | | | | | `var`,
| | | | | | | },
| | | | | | | name: `whis_len`,
| | | | | | },
| | | | | | `)`,
| | | | | },
| | | | | `=>`,
| | | | | block-expression: {
| | | | | | `{`,
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `"cat!"`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `" Its whiskers are "`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append_string`,
| | | | | | | | | `(`,
| | | | | | | | | | function call: {
| | | | | | | | | | | identifier: `String..from`,
| | | | | | | | | | | `(`,
| | | | | | | | | | | | identifier: `whis_len`,
| | | | | | | | | | | `)`,
| | | | | | | | | | },
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `" inches long!"`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | `}`,
| | | | | },
| | | | },
| | | | match-branch: {
| | | | | variant decomposition: {
| | | | | | name: `Animal..Dog`,
| | | | | | `(`,
| | | | | | parameter: {
| | | | | | | base type: {
| | | | | | | | `var`,
| | | | | | | },
| | | | | | | name: `info`,
| | | | | | },
| | | | | | parameter: {
| | | | | | | base type: {
| | | | | | | | `var`,
| | | | | | | },
| | | | | | | name: `bark_vol`,
| | | | | | },
| | | | | | `)`,
| | | | | },
| | | | | `=>`,
| | | | | block-expression: {
| | | | | | `{`,
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `"dog!"`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `" Its barks are "`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append_string`,
| | | | | | | | | `(`,
| | | | | | | | | | function call: {
| | | | | | | | | | | identifier: `String..from`,
| | | | | | | | | | | `(`,
| | | | | | | | | | | | identifier: `bark_vol`,
| | | | | | | | | | | `)`,
| | | | | | | | | | },
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `" decibels loud!"`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | `}`,
| | | | | },
| | | | },
| | | | match-branch: {
| | | | | identifier: `Animal..Snake`,
| | | | | `|`,
| | | | | identifier: `Animal..Lizard`,
| | | | | `=>`,
| | | | | block-expression: {
| | | | | | `{`,
| | | | | | expression-statement: {
| | | | | | | binary-expr: {
| | | | | | | | identifier: `state`,
| | | | | | | | `.`,
| | | | | | | | function call: {
| | | | | | | | | identifier: `append`,
| | | | | | | | | `(`,
| | | | | | | | | | literal (string literal): `" repitilian! Oh hell nah!"`,
| | | | | | | | | `)`,
| | | | | | | | },
| | | | | | | },
| | | | | | | `;`,
| | | | | | },
| | | | | | `}`,
| | | | | },
| | | | },
| | | },
| | | `;`,
| | },
| | use statement {
| | | identifier: `std`,
| | },
| | expression-statement: {
| | | function call: {
| | | | identifier: `println`,
| | | | `(`,
| | | | | identifier: `state`,
| | | | `)`,
| | | },
| | | `;`,
| | },
| | `}`,
| },
},
},