Appearance
| 1 | namespace Syntax.Process is | |
| 2 | // Recognises an empty list literal that nothing around it has said | |
| 3 | // the element type of: no elements, no written type and no expected | |
| 4 | // type. Such a literal takes its type from its siblings - the other | |
| 5 | // elements of an enclosing literal, or the other arms of an if or | |
| 6 | // case - so it stays out of their join and is walked again at the | |
| 7 | // type they settle on. | |
| 8 | class CONTEXTLESS_EMPTY_LITERAL is | |
| 9 | is_expression(expression: Trees.Expressions.Expression) -> bool static is | |
| 10 | if let literal: Trees.Expressions.SEQUENCE = expression then | |
| 11 | return | |
| 12 | literal.elements.expressions.count == 0 /\ | |
| 13 | isa Trees.TypeExpressions.INFER(literal.type_expression) /\ | |
| 14 | !literal.expected_type? | |
| 15 | fi | |
| 16 | ||
| 17 | return false | |
| 18 | si | |
| 19 | ||
| 20 | // An arm counts only when the literal is everything it holds: | |
| 21 | // walking the arm again then repeats no other statement. | |
| 22 | is_arm(arm: Trees.Statements.LIST) -> bool static is | |
| 23 | let only: Trees.Statements.Statement? mut = null | |
| 24 | let count mut = 0 | |
| 25 | ||
| 26 | for s in arm.statements do | |
| 27 | only = s | |
| 28 | count = count + 1 | |
| 29 | od | |
| 30 | ||
| 31 | if count != 1 then | |
| 32 | return false | |
| 33 | fi | |
| 34 | ||
| 35 | if let statement: Trees.Statements.EXPRESSION = only then | |
| 36 | return is_expression(statement.expression) | |
| 37 | fi | |
| 38 | ||
| 39 | return false | |
| 40 | si | |
| 41 | si | |
| 42 | si |