From 5c234f4727b134f5e9b7d7fe74889db6c2e98c01 Mon Sep 17 00:00:00 2001 From: Rosco Kalis Date: Thu, 30 Jul 2026 16:44:34 +0200 Subject: [PATCH] Allow for simple arithmetic in global constant definitions --- packages/cashc/src/Errors.ts | 20 +++ packages/cashc/src/ast/AST.ts | 2 +- packages/cashc/src/ast/AstBuilder.ts | 2 +- packages/cashc/src/ast/AstTraversal.ts | 4 +- packages/cashc/src/compiler.ts | 2 + packages/cashc/src/dependency-resolution.ts | 15 +- packages/cashc/src/grammar/CashScript.g4 | 2 +- packages/cashc/src/grammar/CashScript.interp | 2 +- .../cashc/src/grammar/CashScriptParser.ts | 8 +- .../src/print/OutputSourceCodeTraversal.ts | 3 +- .../semantic/FoldGlobalConstantsTraversal.ts | 149 ++++++++++++++++++ .../semantic/LowerGlobalConstantsTraversal.ts | 17 +- .../cashc/src/semantic/TypeCheckTraversal.ts | 1 + .../global_constant_division_by_zero.cash | 7 + ...lobal_constant_unsupported_expression.cash | 7 + .../global_constant_non_literal.cash | 7 - .../global_constant_forward_reference.cash | 8 + .../global_constant_mixed_operands.cash | 7 + .../cashc/test/global-definitions.test.ts | 52 +++++- packages/cashc/test/imports.test.ts | 10 +- .../global_constant_arithmetic.cash | 17 ++ website/docs/compiler/grammar.md | 2 +- website/docs/language/contracts.md | 61 +++---- 23 files changed, 331 insertions(+), 74 deletions(-) create mode 100644 packages/cashc/src/semantic/FoldGlobalConstantsTraversal.ts create mode 100644 packages/cashc/test/compiler/DivisionByZeroError/global_constant_division_by_zero.cash create mode 100644 packages/cashc/test/compiler/InvalidConstantExpressionError/global_constant_unsupported_expression.cash delete mode 100644 packages/cashc/test/compiler/ParseError/global_constant_non_literal.cash create mode 100644 packages/cashc/test/compiler/UndefinedReferenceError/global_constant_forward_reference.cash create mode 100644 packages/cashc/test/compiler/UnequalTypeError/global_constant_mixed_operands.cash create mode 100644 packages/cashc/test/valid-contract-files/global_constant_arithmetic.cash diff --git a/packages/cashc/src/Errors.ts b/packages/cashc/src/Errors.ts index 04bf0808..a667677e 100644 --- a/packages/cashc/src/Errors.ts +++ b/packages/cashc/src/Errors.ts @@ -263,6 +263,26 @@ export class AssignTypeError extends TypeError { } } +export class InvalidConstantExpressionError extends CashScriptError { + constructor( + public node: Node, + ) { + super( + node, + 'Global constant definitions only support literals, references to other constants, ' + + 'integer arithmetic and concatenation', + ); + } +} + +export class DivisionByZeroError extends CashScriptError { + constructor( + public node: BinaryOpNode, + ) { + super(node, 'Division by zero'); + } +} + export class ConstantModificationError extends CashScriptError { constructor(node: VariableDefinitionNode | ConstantDefinitionNode); constructor(node: Node, name: string); diff --git a/packages/cashc/src/ast/AST.ts b/packages/cashc/src/ast/AST.ts index 4b222d15..d9ffcb7c 100644 --- a/packages/cashc/src/ast/AST.ts +++ b/packages/cashc/src/ast/AST.ts @@ -53,7 +53,7 @@ export class ConstantDefinitionNode extends Node implements Named, Typed { constructor( public type: Type, public name: string, - public value: LiteralNode, + public value: ExpressionNode, ) { super(); } diff --git a/packages/cashc/src/ast/AstBuilder.ts b/packages/cashc/src/ast/AstBuilder.ts index 07a7e99d..05046b8b 100644 --- a/packages/cashc/src/ast/AstBuilder.ts +++ b/packages/cashc/src/ast/AstBuilder.ts @@ -143,7 +143,7 @@ export default class AstBuilder visitConstantDefinition(ctx: ConstantDefinitionContext): ConstantDefinitionNode { const type = parseType(ctx.typeName().getText()); const name = ctx.Identifier().getText(); - const value = this.createLiteral(ctx.literal()); + const value = this.visit(ctx.expression()) as ExpressionNode; const constantDefinition = new ConstantDefinitionNode(type, name, value); constantDefinition.location = Location.fromCtx(ctx); return constantDefinition; diff --git a/packages/cashc/src/ast/AstTraversal.ts b/packages/cashc/src/ast/AstTraversal.ts index b671528e..0dca299e 100644 --- a/packages/cashc/src/ast/AstTraversal.ts +++ b/packages/cashc/src/ast/AstTraversal.ts @@ -30,7 +30,7 @@ import { NullaryOpNode, ConsoleStatementNode, ConsoleParameterNode, - LiteralNode, + ExpressionNode, FunctionCallStatementNode, SliceNode, DoWhileNode, @@ -64,7 +64,7 @@ export default class AstTraversal extends AstVisitor { } visitConstantDefinition(node: ConstantDefinitionNode): Node { - node.value = this.visit(node.value) as LiteralNode; + node.value = this.visit(node.value) as ExpressionNode; return node; } diff --git a/packages/cashc/src/compiler.ts b/packages/cashc/src/compiler.ts index 3a6b538c..29e5b505 100644 --- a/packages/cashc/src/compiler.ts +++ b/packages/cashc/src/compiler.ts @@ -28,6 +28,7 @@ import { resolveDependencies, } from './dependency-resolution.js'; import GenerateTargetTraversal from './generation/GenerateTargetTraversal.js'; +import { FoldGlobalConstantsTraversal } from './semantic/FoldGlobalConstantsTraversal.js'; import SymbolTableTraversal from './semantic/SymbolTableTraversal.js'; import TypeCheckTraversal from './semantic/TypeCheckTraversal.js'; import EnsureFinalRequireTraversal from './semantic/EnsureFinalRequireTraversal.js'; @@ -115,6 +116,7 @@ function compileCode( const constructorParamLength = ast.contract.parameters.length; // Semantic analysis + ast = ast.accept(new FoldGlobalConstantsTraversal()) as Ast; ast = ast.accept(new SymbolTableTraversal()) as Ast; ast = ast.accept(new TypeCheckTraversal()) as Ast; ast = ast.accept(new EnsureFunctionsSafeTraversal()) as Ast; diff --git a/packages/cashc/src/dependency-resolution.ts b/packages/cashc/src/dependency-resolution.ts index 36393898..7ce8a985 100644 --- a/packages/cashc/src/dependency-resolution.ts +++ b/packages/cashc/src/dependency-resolution.ts @@ -81,19 +81,22 @@ interface ImportedDefinitions { } // Depth-first walk of the import graph, returning every global definition it reaches. `visitedPaths` -// is internal bookkeeping that de-duplicates files by canonical path — collapsing diamonds (a file -// reached through two paths is read once) and guaranteeing termination for mutual or cyclic imports — -// so this function stays pure with respect to its arguments. +// de-duplicates files by canonical path so a diamond's shared leaf is read once, while `activePaths` +// tracks the files currently being resolved so cyclic imports are rejected. function collectImports( imports: ImportNode[], resolver: ImportResolver, errorListener?: CashScriptErrorListener, ): ImportedDefinitions { const visitedPaths = new Set(); + const activePaths = new Set(); const collect = (currentImports: ImportNode[], currentDir: string): ImportedDefinitions[] => currentImports.flatMap((importNode) => { const canonicalPath = resolver.resolve(currentDir, importNode.path); + if (activePaths.has(canonicalPath)) { + throw new ImportResolutionError(importNode, `Cyclic import of '${importNode.path}'`); + } if (visitedPaths.has(canonicalPath)) return []; visitedPaths.add(canonicalPath); @@ -118,8 +121,12 @@ function collectImports( constant.sourceFile = resolver.sourceName(canonicalPath); }); + activePaths.add(canonicalPath); + const transitiveDefinitions = collect(importedAst.imports, resolver.dirname(canonicalPath)); + activePaths.delete(canonicalPath); + return [ - ...collect(importedAst.imports, resolver.dirname(canonicalPath)), + ...transitiveDefinitions, { functions: importedAst.functions, constants: importedAst.constants }, ]; }); diff --git a/packages/cashc/src/grammar/CashScript.g4 b/packages/cashc/src/grammar/CashScript.g4 index d3733ca9..25ed5ca7 100644 --- a/packages/cashc/src/grammar/CashScript.g4 +++ b/packages/cashc/src/grammar/CashScript.g4 @@ -39,7 +39,7 @@ globalFunctionDefinition ; constantDefinition - : typeName 'constant' Identifier '=' literal ';' + : typeName 'constant' Identifier '=' expression ';' ; contractDefinition diff --git a/packages/cashc/src/grammar/CashScript.interp b/packages/cashc/src/grammar/CashScript.interp index ddd92038..298c790d 100644 --- a/packages/cashc/src/grammar/CashScript.interp +++ b/packages/cashc/src/grammar/CashScript.interp @@ -220,4 +220,4 @@ typeCast atn: -[4, 1, 84, 509, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 1, 0, 5, 0, 90, 8, 0, 10, 0, 12, 0, 93, 9, 0, 1, 0, 5, 0, 96, 8, 0, 10, 0, 12, 0, 99, 9, 0, 1, 0, 5, 0, 102, 8, 0, 10, 0, 12, 0, 105, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 3, 3, 118, 8, 3, 1, 4, 3, 4, 121, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 3, 7, 134, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 5, 8, 144, 8, 8, 10, 8, 12, 8, 147, 9, 8, 1, 8, 1, 8, 3, 8, 151, 8, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 167, 8, 10, 10, 10, 12, 10, 170, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 5, 12, 181, 8, 12, 10, 12, 12, 12, 184, 9, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 192, 8, 13, 10, 13, 12, 13, 195, 9, 13, 1, 13, 3, 13, 198, 8, 13, 3, 13, 200, 8, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 5, 15, 209, 8, 15, 10, 15, 12, 15, 212, 9, 15, 1, 15, 1, 15, 3, 15, 216, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 222, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 232, 8, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 5, 19, 240, 8, 19, 10, 19, 12, 19, 243, 9, 19, 1, 20, 1, 20, 3, 20, 247, 8, 20, 1, 21, 1, 21, 5, 21, 251, 8, 21, 10, 21, 12, 21, 254, 9, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 4, 22, 266, 8, 22, 11, 22, 12, 22, 267, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 278, 8, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 3, 24, 287, 8, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 296, 8, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 3, 27, 310, 8, 27, 1, 28, 1, 28, 1, 28, 3, 28, 315, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 3, 32, 343, 8, 32, 1, 33, 1, 33, 1, 34, 1, 34, 3, 34, 349, 8, 34, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 355, 8, 35, 10, 35, 12, 35, 358, 9, 35, 1, 35, 3, 35, 361, 8, 35, 3, 35, 363, 8, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 5, 37, 374, 8, 37, 10, 37, 12, 37, 377, 9, 37, 1, 37, 3, 37, 380, 8, 37, 3, 37, 382, 8, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 395, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 5, 38, 421, 8, 38, 10, 38, 12, 38, 424, 9, 38, 1, 38, 3, 38, 427, 8, 38, 3, 38, 429, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 435, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 5, 38, 487, 8, 38, 10, 38, 12, 38, 490, 9, 38, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 3, 40, 499, 8, 40, 1, 41, 1, 41, 3, 41, 503, 8, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 0, 1, 76, 44, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 0, 14, 1, 0, 4, 10, 2, 0, 10, 10, 22, 23, 1, 0, 24, 25, 1, 0, 37, 41, 2, 0, 37, 41, 43, 46, 2, 0, 5, 5, 51, 52, 1, 0, 53, 55, 2, 0, 52, 52, 56, 56, 1, 0, 57, 58, 1, 0, 6, 9, 1, 0, 59, 60, 1, 0, 47, 48, 1, 0, 71, 73, 2, 0, 71, 72, 79, 79, 539, 0, 91, 1, 0, 0, 0, 2, 108, 1, 0, 0, 0, 4, 113, 1, 0, 0, 0, 6, 115, 1, 0, 0, 0, 8, 120, 1, 0, 0, 0, 10, 124, 1, 0, 0, 0, 12, 126, 1, 0, 0, 0, 14, 133, 1, 0, 0, 0, 16, 135, 1, 0, 0, 0, 18, 154, 1, 0, 0, 0, 20, 161, 1, 0, 0, 0, 22, 173, 1, 0, 0, 0, 24, 178, 1, 0, 0, 0, 26, 187, 1, 0, 0, 0, 28, 203, 1, 0, 0, 0, 30, 215, 1, 0, 0, 0, 32, 221, 1, 0, 0, 0, 34, 231, 1, 0, 0, 0, 36, 233, 1, 0, 0, 0, 38, 235, 1, 0, 0, 0, 40, 246, 1, 0, 0, 0, 42, 248, 1, 0, 0, 0, 44, 259, 1, 0, 0, 0, 46, 277, 1, 0, 0, 0, 48, 279, 1, 0, 0, 0, 50, 290, 1, 0, 0, 0, 52, 299, 1, 0, 0, 0, 54, 302, 1, 0, 0, 0, 56, 314, 1, 0, 0, 0, 58, 316, 1, 0, 0, 0, 60, 324, 1, 0, 0, 0, 62, 330, 1, 0, 0, 0, 64, 342, 1, 0, 0, 0, 66, 344, 1, 0, 0, 0, 68, 348, 1, 0, 0, 0, 70, 350, 1, 0, 0, 0, 72, 366, 1, 0, 0, 0, 74, 369, 1, 0, 0, 0, 76, 434, 1, 0, 0, 0, 78, 491, 1, 0, 0, 0, 80, 498, 1, 0, 0, 0, 82, 500, 1, 0, 0, 0, 84, 504, 1, 0, 0, 0, 86, 506, 1, 0, 0, 0, 88, 90, 3, 2, 1, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 97, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 96, 3, 12, 6, 0, 95, 94, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 103, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 100, 102, 3, 14, 7, 0, 101, 100, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 104, 106, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 107, 5, 0, 0, 1, 107, 1, 1, 0, 0, 0, 108, 109, 5, 1, 0, 0, 109, 110, 3, 4, 2, 0, 110, 111, 3, 6, 3, 0, 111, 112, 5, 2, 0, 0, 112, 3, 1, 0, 0, 0, 113, 114, 5, 3, 0, 0, 114, 5, 1, 0, 0, 0, 115, 117, 3, 8, 4, 0, 116, 118, 3, 8, 4, 0, 117, 116, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 7, 1, 0, 0, 0, 119, 121, 3, 10, 5, 0, 120, 119, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 123, 5, 65, 0, 0, 123, 9, 1, 0, 0, 0, 124, 125, 7, 0, 0, 0, 125, 11, 1, 0, 0, 0, 126, 127, 5, 11, 0, 0, 127, 128, 5, 75, 0, 0, 128, 129, 5, 2, 0, 0, 129, 13, 1, 0, 0, 0, 130, 134, 3, 16, 8, 0, 131, 134, 3, 18, 9, 0, 132, 134, 3, 20, 10, 0, 133, 130, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 133, 132, 1, 0, 0, 0, 134, 15, 1, 0, 0, 0, 135, 136, 5, 12, 0, 0, 136, 137, 5, 81, 0, 0, 137, 150, 3, 26, 13, 0, 138, 139, 5, 13, 0, 0, 139, 140, 5, 14, 0, 0, 140, 145, 3, 84, 42, 0, 141, 142, 5, 15, 0, 0, 142, 144, 3, 84, 42, 0, 143, 141, 1, 0, 0, 0, 144, 147, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 148, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 148, 149, 5, 16, 0, 0, 149, 151, 1, 0, 0, 0, 150, 138, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 153, 3, 24, 12, 0, 153, 17, 1, 0, 0, 0, 154, 155, 3, 84, 42, 0, 155, 156, 5, 17, 0, 0, 156, 157, 5, 81, 0, 0, 157, 158, 5, 10, 0, 0, 158, 159, 3, 80, 40, 0, 159, 160, 5, 2, 0, 0, 160, 19, 1, 0, 0, 0, 161, 162, 5, 18, 0, 0, 162, 163, 5, 81, 0, 0, 163, 164, 3, 26, 13, 0, 164, 168, 5, 19, 0, 0, 165, 167, 3, 22, 11, 0, 166, 165, 1, 0, 0, 0, 167, 170, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 172, 5, 20, 0, 0, 172, 21, 1, 0, 0, 0, 173, 174, 5, 12, 0, 0, 174, 175, 5, 81, 0, 0, 175, 176, 3, 26, 13, 0, 176, 177, 3, 24, 12, 0, 177, 23, 1, 0, 0, 0, 178, 182, 5, 19, 0, 0, 179, 181, 3, 32, 16, 0, 180, 179, 1, 0, 0, 0, 181, 184, 1, 0, 0, 0, 182, 180, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 185, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 186, 5, 20, 0, 0, 186, 25, 1, 0, 0, 0, 187, 199, 5, 14, 0, 0, 188, 193, 3, 28, 14, 0, 189, 190, 5, 15, 0, 0, 190, 192, 3, 28, 14, 0, 191, 189, 1, 0, 0, 0, 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 198, 5, 15, 0, 0, 197, 196, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 200, 1, 0, 0, 0, 199, 188, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 202, 5, 16, 0, 0, 202, 27, 1, 0, 0, 0, 203, 204, 3, 84, 42, 0, 204, 205, 5, 81, 0, 0, 205, 29, 1, 0, 0, 0, 206, 210, 5, 19, 0, 0, 207, 209, 3, 32, 16, 0, 208, 207, 1, 0, 0, 0, 209, 212, 1, 0, 0, 0, 210, 208, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 213, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, 213, 216, 5, 20, 0, 0, 214, 216, 3, 32, 16, 0, 215, 206, 1, 0, 0, 0, 215, 214, 1, 0, 0, 0, 216, 31, 1, 0, 0, 0, 217, 222, 3, 40, 20, 0, 218, 219, 3, 34, 17, 0, 219, 220, 5, 2, 0, 0, 220, 222, 1, 0, 0, 0, 221, 217, 1, 0, 0, 0, 221, 218, 1, 0, 0, 0, 222, 33, 1, 0, 0, 0, 223, 232, 3, 42, 21, 0, 224, 232, 3, 44, 22, 0, 225, 232, 3, 46, 23, 0, 226, 232, 3, 48, 24, 0, 227, 232, 3, 50, 25, 0, 228, 232, 3, 36, 18, 0, 229, 232, 3, 52, 26, 0, 230, 232, 3, 38, 19, 0, 231, 223, 1, 0, 0, 0, 231, 224, 1, 0, 0, 0, 231, 225, 1, 0, 0, 0, 231, 226, 1, 0, 0, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 35, 1, 0, 0, 0, 233, 234, 3, 72, 36, 0, 234, 37, 1, 0, 0, 0, 235, 236, 5, 21, 0, 0, 236, 241, 3, 76, 38, 0, 237, 238, 5, 15, 0, 0, 238, 240, 3, 76, 38, 0, 239, 237, 1, 0, 0, 0, 240, 243, 1, 0, 0, 0, 241, 239, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 39, 1, 0, 0, 0, 243, 241, 1, 0, 0, 0, 244, 247, 3, 54, 27, 0, 245, 247, 3, 56, 28, 0, 246, 244, 1, 0, 0, 0, 246, 245, 1, 0, 0, 0, 247, 41, 1, 0, 0, 0, 248, 252, 3, 84, 42, 0, 249, 251, 3, 78, 39, 0, 250, 249, 1, 0, 0, 0, 251, 254, 1, 0, 0, 0, 252, 250, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, 253, 255, 1, 0, 0, 0, 254, 252, 1, 0, 0, 0, 255, 256, 5, 81, 0, 0, 256, 257, 5, 10, 0, 0, 257, 258, 3, 76, 38, 0, 258, 43, 1, 0, 0, 0, 259, 260, 3, 84, 42, 0, 260, 265, 5, 81, 0, 0, 261, 262, 5, 15, 0, 0, 262, 263, 3, 84, 42, 0, 263, 264, 5, 81, 0, 0, 264, 266, 1, 0, 0, 0, 265, 261, 1, 0, 0, 0, 266, 267, 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 270, 5, 10, 0, 0, 270, 271, 3, 76, 38, 0, 271, 45, 1, 0, 0, 0, 272, 273, 5, 81, 0, 0, 273, 274, 7, 1, 0, 0, 274, 278, 3, 76, 38, 0, 275, 276, 5, 81, 0, 0, 276, 278, 7, 2, 0, 0, 277, 272, 1, 0, 0, 0, 277, 275, 1, 0, 0, 0, 278, 47, 1, 0, 0, 0, 279, 280, 5, 26, 0, 0, 280, 281, 5, 14, 0, 0, 281, 282, 5, 78, 0, 0, 282, 283, 5, 6, 0, 0, 283, 286, 3, 76, 38, 0, 284, 285, 5, 15, 0, 0, 285, 287, 3, 66, 33, 0, 286, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 289, 5, 16, 0, 0, 289, 49, 1, 0, 0, 0, 290, 291, 5, 26, 0, 0, 291, 292, 5, 14, 0, 0, 292, 295, 3, 76, 38, 0, 293, 294, 5, 15, 0, 0, 294, 296, 3, 66, 33, 0, 295, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 297, 1, 0, 0, 0, 297, 298, 5, 16, 0, 0, 298, 51, 1, 0, 0, 0, 299, 300, 5, 27, 0, 0, 300, 301, 3, 70, 35, 0, 301, 53, 1, 0, 0, 0, 302, 303, 5, 28, 0, 0, 303, 304, 5, 14, 0, 0, 304, 305, 3, 76, 38, 0, 305, 306, 5, 16, 0, 0, 306, 309, 3, 30, 15, 0, 307, 308, 5, 29, 0, 0, 308, 310, 3, 30, 15, 0, 309, 307, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 55, 1, 0, 0, 0, 311, 315, 3, 58, 29, 0, 312, 315, 3, 60, 30, 0, 313, 315, 3, 62, 31, 0, 314, 311, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 314, 313, 1, 0, 0, 0, 315, 57, 1, 0, 0, 0, 316, 317, 5, 30, 0, 0, 317, 318, 3, 30, 15, 0, 318, 319, 5, 31, 0, 0, 319, 320, 5, 14, 0, 0, 320, 321, 3, 76, 38, 0, 321, 322, 5, 16, 0, 0, 322, 323, 5, 2, 0, 0, 323, 59, 1, 0, 0, 0, 324, 325, 5, 31, 0, 0, 325, 326, 5, 14, 0, 0, 326, 327, 3, 76, 38, 0, 327, 328, 5, 16, 0, 0, 328, 329, 3, 30, 15, 0, 329, 61, 1, 0, 0, 0, 330, 331, 5, 32, 0, 0, 331, 332, 5, 14, 0, 0, 332, 333, 3, 64, 32, 0, 333, 334, 5, 2, 0, 0, 334, 335, 3, 76, 38, 0, 335, 336, 5, 2, 0, 0, 336, 337, 3, 46, 23, 0, 337, 338, 5, 16, 0, 0, 338, 339, 3, 30, 15, 0, 339, 63, 1, 0, 0, 0, 340, 343, 3, 42, 21, 0, 341, 343, 3, 46, 23, 0, 342, 340, 1, 0, 0, 0, 342, 341, 1, 0, 0, 0, 343, 65, 1, 0, 0, 0, 344, 345, 5, 75, 0, 0, 345, 67, 1, 0, 0, 0, 346, 349, 5, 81, 0, 0, 347, 349, 3, 80, 40, 0, 348, 346, 1, 0, 0, 0, 348, 347, 1, 0, 0, 0, 349, 69, 1, 0, 0, 0, 350, 362, 5, 14, 0, 0, 351, 356, 3, 68, 34, 0, 352, 353, 5, 15, 0, 0, 353, 355, 3, 68, 34, 0, 354, 352, 1, 0, 0, 0, 355, 358, 1, 0, 0, 0, 356, 354, 1, 0, 0, 0, 356, 357, 1, 0, 0, 0, 357, 360, 1, 0, 0, 0, 358, 356, 1, 0, 0, 0, 359, 361, 5, 15, 0, 0, 360, 359, 1, 0, 0, 0, 360, 361, 1, 0, 0, 0, 361, 363, 1, 0, 0, 0, 362, 351, 1, 0, 0, 0, 362, 363, 1, 0, 0, 0, 363, 364, 1, 0, 0, 0, 364, 365, 5, 16, 0, 0, 365, 71, 1, 0, 0, 0, 366, 367, 5, 81, 0, 0, 367, 368, 3, 74, 37, 0, 368, 73, 1, 0, 0, 0, 369, 381, 5, 14, 0, 0, 370, 375, 3, 76, 38, 0, 371, 372, 5, 15, 0, 0, 372, 374, 3, 76, 38, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 379, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 5, 15, 0, 0, 379, 378, 1, 0, 0, 0, 379, 380, 1, 0, 0, 0, 380, 382, 1, 0, 0, 0, 381, 370, 1, 0, 0, 0, 381, 382, 1, 0, 0, 0, 382, 383, 1, 0, 0, 0, 383, 384, 5, 16, 0, 0, 384, 75, 1, 0, 0, 0, 385, 386, 6, 38, -1, 0, 386, 387, 5, 14, 0, 0, 387, 388, 3, 76, 38, 0, 388, 389, 5, 16, 0, 0, 389, 435, 1, 0, 0, 0, 390, 391, 3, 86, 43, 0, 391, 392, 5, 14, 0, 0, 392, 394, 3, 76, 38, 0, 393, 395, 5, 15, 0, 0, 394, 393, 1, 0, 0, 0, 394, 395, 1, 0, 0, 0, 395, 396, 1, 0, 0, 0, 396, 397, 5, 16, 0, 0, 397, 435, 1, 0, 0, 0, 398, 435, 3, 72, 36, 0, 399, 400, 5, 33, 0, 0, 400, 401, 5, 81, 0, 0, 401, 435, 3, 74, 37, 0, 402, 403, 5, 36, 0, 0, 403, 404, 5, 34, 0, 0, 404, 405, 3, 76, 38, 0, 405, 406, 5, 35, 0, 0, 406, 407, 7, 3, 0, 0, 407, 435, 1, 0, 0, 0, 408, 409, 5, 42, 0, 0, 409, 410, 5, 34, 0, 0, 410, 411, 3, 76, 38, 0, 411, 412, 5, 35, 0, 0, 412, 413, 7, 4, 0, 0, 413, 435, 1, 0, 0, 0, 414, 415, 7, 5, 0, 0, 415, 435, 3, 76, 38, 15, 416, 428, 5, 34, 0, 0, 417, 422, 3, 76, 38, 0, 418, 419, 5, 15, 0, 0, 419, 421, 3, 76, 38, 0, 420, 418, 1, 0, 0, 0, 421, 424, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 422, 423, 1, 0, 0, 0, 423, 426, 1, 0, 0, 0, 424, 422, 1, 0, 0, 0, 425, 427, 5, 15, 0, 0, 426, 425, 1, 0, 0, 0, 426, 427, 1, 0, 0, 0, 427, 429, 1, 0, 0, 0, 428, 417, 1, 0, 0, 0, 428, 429, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 435, 5, 35, 0, 0, 431, 435, 5, 80, 0, 0, 432, 435, 5, 81, 0, 0, 433, 435, 3, 80, 40, 0, 434, 385, 1, 0, 0, 0, 434, 390, 1, 0, 0, 0, 434, 398, 1, 0, 0, 0, 434, 399, 1, 0, 0, 0, 434, 402, 1, 0, 0, 0, 434, 408, 1, 0, 0, 0, 434, 414, 1, 0, 0, 0, 434, 416, 1, 0, 0, 0, 434, 431, 1, 0, 0, 0, 434, 432, 1, 0, 0, 0, 434, 433, 1, 0, 0, 0, 435, 488, 1, 0, 0, 0, 436, 437, 10, 14, 0, 0, 437, 438, 7, 6, 0, 0, 438, 487, 3, 76, 38, 15, 439, 440, 10, 13, 0, 0, 440, 441, 7, 7, 0, 0, 441, 487, 3, 76, 38, 14, 442, 443, 10, 12, 0, 0, 443, 444, 7, 8, 0, 0, 444, 487, 3, 76, 38, 13, 445, 446, 10, 11, 0, 0, 446, 447, 7, 9, 0, 0, 447, 487, 3, 76, 38, 12, 448, 449, 10, 10, 0, 0, 449, 450, 7, 10, 0, 0, 450, 487, 3, 76, 38, 11, 451, 452, 10, 9, 0, 0, 452, 453, 5, 61, 0, 0, 453, 487, 3, 76, 38, 10, 454, 455, 10, 8, 0, 0, 455, 456, 5, 4, 0, 0, 456, 487, 3, 76, 38, 9, 457, 458, 10, 7, 0, 0, 458, 459, 5, 62, 0, 0, 459, 487, 3, 76, 38, 8, 460, 461, 10, 6, 0, 0, 461, 462, 5, 63, 0, 0, 462, 487, 3, 76, 38, 7, 463, 464, 10, 5, 0, 0, 464, 465, 5, 64, 0, 0, 465, 487, 3, 76, 38, 6, 466, 467, 10, 21, 0, 0, 467, 468, 5, 34, 0, 0, 468, 469, 5, 68, 0, 0, 469, 487, 5, 35, 0, 0, 470, 471, 10, 18, 0, 0, 471, 487, 7, 11, 0, 0, 472, 473, 10, 17, 0, 0, 473, 474, 5, 49, 0, 0, 474, 475, 5, 14, 0, 0, 475, 476, 3, 76, 38, 0, 476, 477, 5, 16, 0, 0, 477, 487, 1, 0, 0, 0, 478, 479, 10, 16, 0, 0, 479, 480, 5, 50, 0, 0, 480, 481, 5, 14, 0, 0, 481, 482, 3, 76, 38, 0, 482, 483, 5, 15, 0, 0, 483, 484, 3, 76, 38, 0, 484, 485, 5, 16, 0, 0, 485, 487, 1, 0, 0, 0, 486, 436, 1, 0, 0, 0, 486, 439, 1, 0, 0, 0, 486, 442, 1, 0, 0, 0, 486, 445, 1, 0, 0, 0, 486, 448, 1, 0, 0, 0, 486, 451, 1, 0, 0, 0, 486, 454, 1, 0, 0, 0, 486, 457, 1, 0, 0, 0, 486, 460, 1, 0, 0, 0, 486, 463, 1, 0, 0, 0, 486, 466, 1, 0, 0, 0, 486, 470, 1, 0, 0, 0, 486, 472, 1, 0, 0, 0, 486, 478, 1, 0, 0, 0, 487, 490, 1, 0, 0, 0, 488, 486, 1, 0, 0, 0, 488, 489, 1, 0, 0, 0, 489, 77, 1, 0, 0, 0, 490, 488, 1, 0, 0, 0, 491, 492, 5, 17, 0, 0, 492, 79, 1, 0, 0, 0, 493, 499, 5, 66, 0, 0, 494, 499, 3, 82, 41, 0, 495, 499, 5, 75, 0, 0, 496, 499, 5, 76, 0, 0, 497, 499, 5, 77, 0, 0, 498, 493, 1, 0, 0, 0, 498, 494, 1, 0, 0, 0, 498, 495, 1, 0, 0, 0, 498, 496, 1, 0, 0, 0, 498, 497, 1, 0, 0, 0, 499, 81, 1, 0, 0, 0, 500, 502, 5, 68, 0, 0, 501, 503, 5, 67, 0, 0, 502, 501, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 83, 1, 0, 0, 0, 504, 505, 7, 12, 0, 0, 505, 85, 1, 0, 0, 0, 506, 507, 7, 13, 0, 0, 507, 87, 1, 0, 0, 0, 43, 91, 97, 103, 117, 120, 133, 145, 150, 168, 182, 193, 197, 199, 210, 215, 221, 231, 241, 246, 252, 267, 277, 286, 295, 309, 314, 342, 348, 356, 360, 362, 375, 379, 381, 394, 422, 426, 428, 434, 486, 488, 498, 502] \ No newline at end of file +[4, 1, 84, 509, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 1, 0, 5, 0, 90, 8, 0, 10, 0, 12, 0, 93, 9, 0, 1, 0, 5, 0, 96, 8, 0, 10, 0, 12, 0, 99, 9, 0, 1, 0, 5, 0, 102, 8, 0, 10, 0, 12, 0, 105, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 3, 3, 118, 8, 3, 1, 4, 3, 4, 121, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 3, 7, 134, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 5, 8, 144, 8, 8, 10, 8, 12, 8, 147, 9, 8, 1, 8, 1, 8, 3, 8, 151, 8, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 167, 8, 10, 10, 10, 12, 10, 170, 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 5, 12, 181, 8, 12, 10, 12, 12, 12, 184, 9, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 192, 8, 13, 10, 13, 12, 13, 195, 9, 13, 1, 13, 3, 13, 198, 8, 13, 3, 13, 200, 8, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 5, 15, 209, 8, 15, 10, 15, 12, 15, 212, 9, 15, 1, 15, 1, 15, 3, 15, 216, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 222, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 232, 8, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 5, 19, 240, 8, 19, 10, 19, 12, 19, 243, 9, 19, 1, 20, 1, 20, 3, 20, 247, 8, 20, 1, 21, 1, 21, 5, 21, 251, 8, 21, 10, 21, 12, 21, 254, 9, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 4, 22, 266, 8, 22, 11, 22, 12, 22, 267, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 278, 8, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 3, 24, 287, 8, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 296, 8, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 3, 27, 310, 8, 27, 1, 28, 1, 28, 1, 28, 3, 28, 315, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 3, 32, 343, 8, 32, 1, 33, 1, 33, 1, 34, 1, 34, 3, 34, 349, 8, 34, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 355, 8, 35, 10, 35, 12, 35, 358, 9, 35, 1, 35, 3, 35, 361, 8, 35, 3, 35, 363, 8, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 5, 37, 374, 8, 37, 10, 37, 12, 37, 377, 9, 37, 1, 37, 3, 37, 380, 8, 37, 3, 37, 382, 8, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 395, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 5, 38, 421, 8, 38, 10, 38, 12, 38, 424, 9, 38, 1, 38, 3, 38, 427, 8, 38, 3, 38, 429, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 435, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 5, 38, 487, 8, 38, 10, 38, 12, 38, 490, 9, 38, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 3, 40, 499, 8, 40, 1, 41, 1, 41, 3, 41, 503, 8, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 0, 1, 76, 44, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 0, 14, 1, 0, 4, 10, 2, 0, 10, 10, 22, 23, 1, 0, 24, 25, 1, 0, 37, 41, 2, 0, 37, 41, 43, 46, 2, 0, 5, 5, 51, 52, 1, 0, 53, 55, 2, 0, 52, 52, 56, 56, 1, 0, 57, 58, 1, 0, 6, 9, 1, 0, 59, 60, 1, 0, 47, 48, 1, 0, 71, 73, 2, 0, 71, 72, 79, 79, 539, 0, 91, 1, 0, 0, 0, 2, 108, 1, 0, 0, 0, 4, 113, 1, 0, 0, 0, 6, 115, 1, 0, 0, 0, 8, 120, 1, 0, 0, 0, 10, 124, 1, 0, 0, 0, 12, 126, 1, 0, 0, 0, 14, 133, 1, 0, 0, 0, 16, 135, 1, 0, 0, 0, 18, 154, 1, 0, 0, 0, 20, 161, 1, 0, 0, 0, 22, 173, 1, 0, 0, 0, 24, 178, 1, 0, 0, 0, 26, 187, 1, 0, 0, 0, 28, 203, 1, 0, 0, 0, 30, 215, 1, 0, 0, 0, 32, 221, 1, 0, 0, 0, 34, 231, 1, 0, 0, 0, 36, 233, 1, 0, 0, 0, 38, 235, 1, 0, 0, 0, 40, 246, 1, 0, 0, 0, 42, 248, 1, 0, 0, 0, 44, 259, 1, 0, 0, 0, 46, 277, 1, 0, 0, 0, 48, 279, 1, 0, 0, 0, 50, 290, 1, 0, 0, 0, 52, 299, 1, 0, 0, 0, 54, 302, 1, 0, 0, 0, 56, 314, 1, 0, 0, 0, 58, 316, 1, 0, 0, 0, 60, 324, 1, 0, 0, 0, 62, 330, 1, 0, 0, 0, 64, 342, 1, 0, 0, 0, 66, 344, 1, 0, 0, 0, 68, 348, 1, 0, 0, 0, 70, 350, 1, 0, 0, 0, 72, 366, 1, 0, 0, 0, 74, 369, 1, 0, 0, 0, 76, 434, 1, 0, 0, 0, 78, 491, 1, 0, 0, 0, 80, 498, 1, 0, 0, 0, 82, 500, 1, 0, 0, 0, 84, 504, 1, 0, 0, 0, 86, 506, 1, 0, 0, 0, 88, 90, 3, 2, 1, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 97, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 96, 3, 12, 6, 0, 95, 94, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 103, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 100, 102, 3, 14, 7, 0, 101, 100, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 104, 106, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 107, 5, 0, 0, 1, 107, 1, 1, 0, 0, 0, 108, 109, 5, 1, 0, 0, 109, 110, 3, 4, 2, 0, 110, 111, 3, 6, 3, 0, 111, 112, 5, 2, 0, 0, 112, 3, 1, 0, 0, 0, 113, 114, 5, 3, 0, 0, 114, 5, 1, 0, 0, 0, 115, 117, 3, 8, 4, 0, 116, 118, 3, 8, 4, 0, 117, 116, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 7, 1, 0, 0, 0, 119, 121, 3, 10, 5, 0, 120, 119, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 123, 5, 65, 0, 0, 123, 9, 1, 0, 0, 0, 124, 125, 7, 0, 0, 0, 125, 11, 1, 0, 0, 0, 126, 127, 5, 11, 0, 0, 127, 128, 5, 75, 0, 0, 128, 129, 5, 2, 0, 0, 129, 13, 1, 0, 0, 0, 130, 134, 3, 16, 8, 0, 131, 134, 3, 18, 9, 0, 132, 134, 3, 20, 10, 0, 133, 130, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 133, 132, 1, 0, 0, 0, 134, 15, 1, 0, 0, 0, 135, 136, 5, 12, 0, 0, 136, 137, 5, 81, 0, 0, 137, 150, 3, 26, 13, 0, 138, 139, 5, 13, 0, 0, 139, 140, 5, 14, 0, 0, 140, 145, 3, 84, 42, 0, 141, 142, 5, 15, 0, 0, 142, 144, 3, 84, 42, 0, 143, 141, 1, 0, 0, 0, 144, 147, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 148, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 148, 149, 5, 16, 0, 0, 149, 151, 1, 0, 0, 0, 150, 138, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 153, 3, 24, 12, 0, 153, 17, 1, 0, 0, 0, 154, 155, 3, 84, 42, 0, 155, 156, 5, 17, 0, 0, 156, 157, 5, 81, 0, 0, 157, 158, 5, 10, 0, 0, 158, 159, 3, 76, 38, 0, 159, 160, 5, 2, 0, 0, 160, 19, 1, 0, 0, 0, 161, 162, 5, 18, 0, 0, 162, 163, 5, 81, 0, 0, 163, 164, 3, 26, 13, 0, 164, 168, 5, 19, 0, 0, 165, 167, 3, 22, 11, 0, 166, 165, 1, 0, 0, 0, 167, 170, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 172, 5, 20, 0, 0, 172, 21, 1, 0, 0, 0, 173, 174, 5, 12, 0, 0, 174, 175, 5, 81, 0, 0, 175, 176, 3, 26, 13, 0, 176, 177, 3, 24, 12, 0, 177, 23, 1, 0, 0, 0, 178, 182, 5, 19, 0, 0, 179, 181, 3, 32, 16, 0, 180, 179, 1, 0, 0, 0, 181, 184, 1, 0, 0, 0, 182, 180, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 185, 1, 0, 0, 0, 184, 182, 1, 0, 0, 0, 185, 186, 5, 20, 0, 0, 186, 25, 1, 0, 0, 0, 187, 199, 5, 14, 0, 0, 188, 193, 3, 28, 14, 0, 189, 190, 5, 15, 0, 0, 190, 192, 3, 28, 14, 0, 191, 189, 1, 0, 0, 0, 192, 195, 1, 0, 0, 0, 193, 191, 1, 0, 0, 0, 193, 194, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 198, 5, 15, 0, 0, 197, 196, 1, 0, 0, 0, 197, 198, 1, 0, 0, 0, 198, 200, 1, 0, 0, 0, 199, 188, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 202, 5, 16, 0, 0, 202, 27, 1, 0, 0, 0, 203, 204, 3, 84, 42, 0, 204, 205, 5, 81, 0, 0, 205, 29, 1, 0, 0, 0, 206, 210, 5, 19, 0, 0, 207, 209, 3, 32, 16, 0, 208, 207, 1, 0, 0, 0, 209, 212, 1, 0, 0, 0, 210, 208, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 213, 1, 0, 0, 0, 212, 210, 1, 0, 0, 0, 213, 216, 5, 20, 0, 0, 214, 216, 3, 32, 16, 0, 215, 206, 1, 0, 0, 0, 215, 214, 1, 0, 0, 0, 216, 31, 1, 0, 0, 0, 217, 222, 3, 40, 20, 0, 218, 219, 3, 34, 17, 0, 219, 220, 5, 2, 0, 0, 220, 222, 1, 0, 0, 0, 221, 217, 1, 0, 0, 0, 221, 218, 1, 0, 0, 0, 222, 33, 1, 0, 0, 0, 223, 232, 3, 42, 21, 0, 224, 232, 3, 44, 22, 0, 225, 232, 3, 46, 23, 0, 226, 232, 3, 48, 24, 0, 227, 232, 3, 50, 25, 0, 228, 232, 3, 36, 18, 0, 229, 232, 3, 52, 26, 0, 230, 232, 3, 38, 19, 0, 231, 223, 1, 0, 0, 0, 231, 224, 1, 0, 0, 0, 231, 225, 1, 0, 0, 0, 231, 226, 1, 0, 0, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 35, 1, 0, 0, 0, 233, 234, 3, 72, 36, 0, 234, 37, 1, 0, 0, 0, 235, 236, 5, 21, 0, 0, 236, 241, 3, 76, 38, 0, 237, 238, 5, 15, 0, 0, 238, 240, 3, 76, 38, 0, 239, 237, 1, 0, 0, 0, 240, 243, 1, 0, 0, 0, 241, 239, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 39, 1, 0, 0, 0, 243, 241, 1, 0, 0, 0, 244, 247, 3, 54, 27, 0, 245, 247, 3, 56, 28, 0, 246, 244, 1, 0, 0, 0, 246, 245, 1, 0, 0, 0, 247, 41, 1, 0, 0, 0, 248, 252, 3, 84, 42, 0, 249, 251, 3, 78, 39, 0, 250, 249, 1, 0, 0, 0, 251, 254, 1, 0, 0, 0, 252, 250, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, 253, 255, 1, 0, 0, 0, 254, 252, 1, 0, 0, 0, 255, 256, 5, 81, 0, 0, 256, 257, 5, 10, 0, 0, 257, 258, 3, 76, 38, 0, 258, 43, 1, 0, 0, 0, 259, 260, 3, 84, 42, 0, 260, 265, 5, 81, 0, 0, 261, 262, 5, 15, 0, 0, 262, 263, 3, 84, 42, 0, 263, 264, 5, 81, 0, 0, 264, 266, 1, 0, 0, 0, 265, 261, 1, 0, 0, 0, 266, 267, 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 270, 5, 10, 0, 0, 270, 271, 3, 76, 38, 0, 271, 45, 1, 0, 0, 0, 272, 273, 5, 81, 0, 0, 273, 274, 7, 1, 0, 0, 274, 278, 3, 76, 38, 0, 275, 276, 5, 81, 0, 0, 276, 278, 7, 2, 0, 0, 277, 272, 1, 0, 0, 0, 277, 275, 1, 0, 0, 0, 278, 47, 1, 0, 0, 0, 279, 280, 5, 26, 0, 0, 280, 281, 5, 14, 0, 0, 281, 282, 5, 78, 0, 0, 282, 283, 5, 6, 0, 0, 283, 286, 3, 76, 38, 0, 284, 285, 5, 15, 0, 0, 285, 287, 3, 66, 33, 0, 286, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 289, 5, 16, 0, 0, 289, 49, 1, 0, 0, 0, 290, 291, 5, 26, 0, 0, 291, 292, 5, 14, 0, 0, 292, 295, 3, 76, 38, 0, 293, 294, 5, 15, 0, 0, 294, 296, 3, 66, 33, 0, 295, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 297, 1, 0, 0, 0, 297, 298, 5, 16, 0, 0, 298, 51, 1, 0, 0, 0, 299, 300, 5, 27, 0, 0, 300, 301, 3, 70, 35, 0, 301, 53, 1, 0, 0, 0, 302, 303, 5, 28, 0, 0, 303, 304, 5, 14, 0, 0, 304, 305, 3, 76, 38, 0, 305, 306, 5, 16, 0, 0, 306, 309, 3, 30, 15, 0, 307, 308, 5, 29, 0, 0, 308, 310, 3, 30, 15, 0, 309, 307, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 55, 1, 0, 0, 0, 311, 315, 3, 58, 29, 0, 312, 315, 3, 60, 30, 0, 313, 315, 3, 62, 31, 0, 314, 311, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 314, 313, 1, 0, 0, 0, 315, 57, 1, 0, 0, 0, 316, 317, 5, 30, 0, 0, 317, 318, 3, 30, 15, 0, 318, 319, 5, 31, 0, 0, 319, 320, 5, 14, 0, 0, 320, 321, 3, 76, 38, 0, 321, 322, 5, 16, 0, 0, 322, 323, 5, 2, 0, 0, 323, 59, 1, 0, 0, 0, 324, 325, 5, 31, 0, 0, 325, 326, 5, 14, 0, 0, 326, 327, 3, 76, 38, 0, 327, 328, 5, 16, 0, 0, 328, 329, 3, 30, 15, 0, 329, 61, 1, 0, 0, 0, 330, 331, 5, 32, 0, 0, 331, 332, 5, 14, 0, 0, 332, 333, 3, 64, 32, 0, 333, 334, 5, 2, 0, 0, 334, 335, 3, 76, 38, 0, 335, 336, 5, 2, 0, 0, 336, 337, 3, 46, 23, 0, 337, 338, 5, 16, 0, 0, 338, 339, 3, 30, 15, 0, 339, 63, 1, 0, 0, 0, 340, 343, 3, 42, 21, 0, 341, 343, 3, 46, 23, 0, 342, 340, 1, 0, 0, 0, 342, 341, 1, 0, 0, 0, 343, 65, 1, 0, 0, 0, 344, 345, 5, 75, 0, 0, 345, 67, 1, 0, 0, 0, 346, 349, 5, 81, 0, 0, 347, 349, 3, 80, 40, 0, 348, 346, 1, 0, 0, 0, 348, 347, 1, 0, 0, 0, 349, 69, 1, 0, 0, 0, 350, 362, 5, 14, 0, 0, 351, 356, 3, 68, 34, 0, 352, 353, 5, 15, 0, 0, 353, 355, 3, 68, 34, 0, 354, 352, 1, 0, 0, 0, 355, 358, 1, 0, 0, 0, 356, 354, 1, 0, 0, 0, 356, 357, 1, 0, 0, 0, 357, 360, 1, 0, 0, 0, 358, 356, 1, 0, 0, 0, 359, 361, 5, 15, 0, 0, 360, 359, 1, 0, 0, 0, 360, 361, 1, 0, 0, 0, 361, 363, 1, 0, 0, 0, 362, 351, 1, 0, 0, 0, 362, 363, 1, 0, 0, 0, 363, 364, 1, 0, 0, 0, 364, 365, 5, 16, 0, 0, 365, 71, 1, 0, 0, 0, 366, 367, 5, 81, 0, 0, 367, 368, 3, 74, 37, 0, 368, 73, 1, 0, 0, 0, 369, 381, 5, 14, 0, 0, 370, 375, 3, 76, 38, 0, 371, 372, 5, 15, 0, 0, 372, 374, 3, 76, 38, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 379, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 5, 15, 0, 0, 379, 378, 1, 0, 0, 0, 379, 380, 1, 0, 0, 0, 380, 382, 1, 0, 0, 0, 381, 370, 1, 0, 0, 0, 381, 382, 1, 0, 0, 0, 382, 383, 1, 0, 0, 0, 383, 384, 5, 16, 0, 0, 384, 75, 1, 0, 0, 0, 385, 386, 6, 38, -1, 0, 386, 387, 5, 14, 0, 0, 387, 388, 3, 76, 38, 0, 388, 389, 5, 16, 0, 0, 389, 435, 1, 0, 0, 0, 390, 391, 3, 86, 43, 0, 391, 392, 5, 14, 0, 0, 392, 394, 3, 76, 38, 0, 393, 395, 5, 15, 0, 0, 394, 393, 1, 0, 0, 0, 394, 395, 1, 0, 0, 0, 395, 396, 1, 0, 0, 0, 396, 397, 5, 16, 0, 0, 397, 435, 1, 0, 0, 0, 398, 435, 3, 72, 36, 0, 399, 400, 5, 33, 0, 0, 400, 401, 5, 81, 0, 0, 401, 435, 3, 74, 37, 0, 402, 403, 5, 36, 0, 0, 403, 404, 5, 34, 0, 0, 404, 405, 3, 76, 38, 0, 405, 406, 5, 35, 0, 0, 406, 407, 7, 3, 0, 0, 407, 435, 1, 0, 0, 0, 408, 409, 5, 42, 0, 0, 409, 410, 5, 34, 0, 0, 410, 411, 3, 76, 38, 0, 411, 412, 5, 35, 0, 0, 412, 413, 7, 4, 0, 0, 413, 435, 1, 0, 0, 0, 414, 415, 7, 5, 0, 0, 415, 435, 3, 76, 38, 15, 416, 428, 5, 34, 0, 0, 417, 422, 3, 76, 38, 0, 418, 419, 5, 15, 0, 0, 419, 421, 3, 76, 38, 0, 420, 418, 1, 0, 0, 0, 421, 424, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 422, 423, 1, 0, 0, 0, 423, 426, 1, 0, 0, 0, 424, 422, 1, 0, 0, 0, 425, 427, 5, 15, 0, 0, 426, 425, 1, 0, 0, 0, 426, 427, 1, 0, 0, 0, 427, 429, 1, 0, 0, 0, 428, 417, 1, 0, 0, 0, 428, 429, 1, 0, 0, 0, 429, 430, 1, 0, 0, 0, 430, 435, 5, 35, 0, 0, 431, 435, 5, 80, 0, 0, 432, 435, 5, 81, 0, 0, 433, 435, 3, 80, 40, 0, 434, 385, 1, 0, 0, 0, 434, 390, 1, 0, 0, 0, 434, 398, 1, 0, 0, 0, 434, 399, 1, 0, 0, 0, 434, 402, 1, 0, 0, 0, 434, 408, 1, 0, 0, 0, 434, 414, 1, 0, 0, 0, 434, 416, 1, 0, 0, 0, 434, 431, 1, 0, 0, 0, 434, 432, 1, 0, 0, 0, 434, 433, 1, 0, 0, 0, 435, 488, 1, 0, 0, 0, 436, 437, 10, 14, 0, 0, 437, 438, 7, 6, 0, 0, 438, 487, 3, 76, 38, 15, 439, 440, 10, 13, 0, 0, 440, 441, 7, 7, 0, 0, 441, 487, 3, 76, 38, 14, 442, 443, 10, 12, 0, 0, 443, 444, 7, 8, 0, 0, 444, 487, 3, 76, 38, 13, 445, 446, 10, 11, 0, 0, 446, 447, 7, 9, 0, 0, 447, 487, 3, 76, 38, 12, 448, 449, 10, 10, 0, 0, 449, 450, 7, 10, 0, 0, 450, 487, 3, 76, 38, 11, 451, 452, 10, 9, 0, 0, 452, 453, 5, 61, 0, 0, 453, 487, 3, 76, 38, 10, 454, 455, 10, 8, 0, 0, 455, 456, 5, 4, 0, 0, 456, 487, 3, 76, 38, 9, 457, 458, 10, 7, 0, 0, 458, 459, 5, 62, 0, 0, 459, 487, 3, 76, 38, 8, 460, 461, 10, 6, 0, 0, 461, 462, 5, 63, 0, 0, 462, 487, 3, 76, 38, 7, 463, 464, 10, 5, 0, 0, 464, 465, 5, 64, 0, 0, 465, 487, 3, 76, 38, 6, 466, 467, 10, 21, 0, 0, 467, 468, 5, 34, 0, 0, 468, 469, 5, 68, 0, 0, 469, 487, 5, 35, 0, 0, 470, 471, 10, 18, 0, 0, 471, 487, 7, 11, 0, 0, 472, 473, 10, 17, 0, 0, 473, 474, 5, 49, 0, 0, 474, 475, 5, 14, 0, 0, 475, 476, 3, 76, 38, 0, 476, 477, 5, 16, 0, 0, 477, 487, 1, 0, 0, 0, 478, 479, 10, 16, 0, 0, 479, 480, 5, 50, 0, 0, 480, 481, 5, 14, 0, 0, 481, 482, 3, 76, 38, 0, 482, 483, 5, 15, 0, 0, 483, 484, 3, 76, 38, 0, 484, 485, 5, 16, 0, 0, 485, 487, 1, 0, 0, 0, 486, 436, 1, 0, 0, 0, 486, 439, 1, 0, 0, 0, 486, 442, 1, 0, 0, 0, 486, 445, 1, 0, 0, 0, 486, 448, 1, 0, 0, 0, 486, 451, 1, 0, 0, 0, 486, 454, 1, 0, 0, 0, 486, 457, 1, 0, 0, 0, 486, 460, 1, 0, 0, 0, 486, 463, 1, 0, 0, 0, 486, 466, 1, 0, 0, 0, 486, 470, 1, 0, 0, 0, 486, 472, 1, 0, 0, 0, 486, 478, 1, 0, 0, 0, 487, 490, 1, 0, 0, 0, 488, 486, 1, 0, 0, 0, 488, 489, 1, 0, 0, 0, 489, 77, 1, 0, 0, 0, 490, 488, 1, 0, 0, 0, 491, 492, 5, 17, 0, 0, 492, 79, 1, 0, 0, 0, 493, 499, 5, 66, 0, 0, 494, 499, 3, 82, 41, 0, 495, 499, 5, 75, 0, 0, 496, 499, 5, 76, 0, 0, 497, 499, 5, 77, 0, 0, 498, 493, 1, 0, 0, 0, 498, 494, 1, 0, 0, 0, 498, 495, 1, 0, 0, 0, 498, 496, 1, 0, 0, 0, 498, 497, 1, 0, 0, 0, 499, 81, 1, 0, 0, 0, 500, 502, 5, 68, 0, 0, 501, 503, 5, 67, 0, 0, 502, 501, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 83, 1, 0, 0, 0, 504, 505, 7, 12, 0, 0, 505, 85, 1, 0, 0, 0, 506, 507, 7, 13, 0, 0, 507, 87, 1, 0, 0, 0, 43, 91, 97, 103, 117, 120, 133, 145, 150, 168, 182, 193, 197, 199, 210, 215, 221, 231, 241, 246, 252, 267, 277, 286, 295, 309, 314, 342, 348, 356, 360, 362, 375, 379, 381, 394, 422, 426, 428, 434, 486, 488, 498, 502] \ No newline at end of file diff --git a/packages/cashc/src/grammar/CashScriptParser.ts b/packages/cashc/src/grammar/CashScriptParser.ts index f78d4031..f36f72bb 100644 --- a/packages/cashc/src/grammar/CashScriptParser.ts +++ b/packages/cashc/src/grammar/CashScriptParser.ts @@ -658,7 +658,7 @@ export default class CashScriptParser extends Parser { this.state = 157; this.match(CashScriptParser.T__9); this.state = 158; - this.literal(); + this.expression(0); this.state = 159; this.match(CashScriptParser.T__1); } @@ -2785,7 +2785,7 @@ export default class CashScriptParser extends Parser { 146,1,0,0,0,146,148,1,0,0,0,147,145,1,0,0,0,148,149,5,16,0,0,149,151,1, 0,0,0,150,138,1,0,0,0,150,151,1,0,0,0,151,152,1,0,0,0,152,153,3,24,12,0, 153,17,1,0,0,0,154,155,3,84,42,0,155,156,5,17,0,0,156,157,5,81,0,0,157, - 158,5,10,0,0,158,159,3,80,40,0,159,160,5,2,0,0,160,19,1,0,0,0,161,162,5, + 158,5,10,0,0,158,159,3,76,38,0,159,160,5,2,0,0,160,19,1,0,0,0,161,162,5, 18,0,0,162,163,5,81,0,0,163,164,3,26,13,0,164,168,5,19,0,0,165,167,3,22, 11,0,166,165,1,0,0,0,167,170,1,0,0,0,168,166,1,0,0,0,168,169,1,0,0,0,169, 171,1,0,0,0,170,168,1,0,0,0,171,172,5,20,0,0,172,21,1,0,0,0,173,174,5,12, @@ -3147,8 +3147,8 @@ export class ConstantDefinitionContext extends ParserRuleContext { public Identifier(): TerminalNode { return this.getToken(CashScriptParser.Identifier, 0); } - public literal(): LiteralContext { - return this.getTypedRuleContext(LiteralContext, 0) as LiteralContext; + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } public get ruleIndex(): number { return CashScriptParser.RULE_constantDefinition; diff --git a/packages/cashc/src/print/OutputSourceCodeTraversal.ts b/packages/cashc/src/print/OutputSourceCodeTraversal.ts index b9440612..982f7a0b 100644 --- a/packages/cashc/src/print/OutputSourceCodeTraversal.ts +++ b/packages/cashc/src/print/OutputSourceCodeTraversal.ts @@ -38,7 +38,6 @@ import { ForNode, NonControlStatementNode, ExpressionNode, - LiteralNode, } from '../ast/AST.js'; import AstTraversal from '../ast/AstTraversal.js'; @@ -112,7 +111,7 @@ export default class OutputSourceCodeTraversal extends AstTraversal { visitConstantDefinition(node: ConstantDefinitionNode): Node { this.addOutput(`${node.type} constant ${node.name} = `, true); - node.value = this.visit(node.value) as LiteralNode; + node.value = this.visit(node.value) as ExpressionNode; this.addOutput(';\n'); return node; } diff --git a/packages/cashc/src/semantic/FoldGlobalConstantsTraversal.ts b/packages/cashc/src/semantic/FoldGlobalConstantsTraversal.ts new file mode 100644 index 00000000..a7589007 --- /dev/null +++ b/packages/cashc/src/semantic/FoldGlobalConstantsTraversal.ts @@ -0,0 +1,149 @@ +import { PrimitiveType } from '@cashscript/utils'; +import { + BinaryOpNode, + ConstantDefinitionNode, + ExpressionNode, + HexLiteralNode, + IdentifierNode, + IntLiteralNode, + LiteralNode, + Node, + SourceFileNode, + StringLiteralNode, + UnaryOpNode, +} from '../ast/AST.js'; +import AstTraversal from '../ast/AstTraversal.js'; +import { GLOBAL_SYMBOL_TABLE } from '../ast/Globals.js'; +import { BinaryOperator, UnaryOperator } from '../ast/Operator.js'; +import { cloneConstantValue } from './LowerGlobalConstantsTraversal.js'; +import { resultingTypeForBinaryOp } from '../utils.js'; +import { + CashScriptError, + DivisionByZeroError, + InvalidConstantExpressionError, + UndefinedReferenceError, + UnequalTypeError, + UnsupportedTypeError, +} from '../Errors.js'; + +// Supports literals, references to other constants, integer arithmetic (+, -, *, /, %, unary -) and concatenation (+) +export class FoldGlobalConstantsTraversal extends AstTraversal { + private foldedConstants: Map = new Map(); + private functionNames: Set = new Set(); + + visitSourceFile(node: SourceFileNode): Node { + this.functionNames = new Set(node.functions.map((func) => func.name)); + node.constants = this.visitList(node.constants) as ConstantDefinitionNode[]; + return node; + } + + visitConstantDefinition(node: ConstantDefinitionNode): Node { + node.value = this.visitExpression(node.value); + this.foldedConstants.set(node.name, node); + return node; + } + + // Folds an expression through the regular visitor dispatch and rejects any expression kind + // that did not fold down to a single literal + private visitExpression(node: ExpressionNode): LiteralNode { + const folded = this.visit(node); + if (!(folded instanceof LiteralNode)) throw new InvalidConstantExpressionError(node); + return folded; + } + + visitIdentifier(node: IdentifierNode): Node { + const constant = this.foldedConstants.get(node.name); + if (constant) return cloneConstantValue(constant, node); + + // Existing names (except previously declared constants) are invalid in a constant initialiser + if (this.functionNames.has(node.name) || GLOBAL_SYMBOL_TABLE.get(node.name)) { + throw new InvalidConstantExpressionError(node); + } + + throw new UndefinedReferenceError(node); + } + + visitUnaryOp(node: UnaryOpNode): Node { + if (!FOLDABLE_UNARY_OPERATORS.includes(node.operator)) throw new InvalidConstantExpressionError(node); + + node.expression = this.visitExpression(node.expression); + if (!(node.expression instanceof IntLiteralNode)) { + throw new UnsupportedTypeError(node, node.expression.type, PrimitiveType.INT); + } + + return withLocation(new IntLiteralNode(-node.expression.value), node); + } + + visitBinaryOp(node: BinaryOpNode): Node { + if (!FOLDABLE_BINARY_OPERATORS.includes(node.operator)) throw new InvalidConstantExpressionError(node); + + // The folded operands are written back so the type errors below report the resolved operand types + node.left = this.visitExpression(node.left); + node.right = this.visitExpression(node.right); + + if (node.operator === BinaryOperator.PLUS) return foldPlus(node); + return foldIntArithmetic(node); + } +} + +const FOLDABLE_UNARY_OPERATORS = [ + UnaryOperator.NEGATE, +]; + +const FOLDABLE_BINARY_OPERATORS = [ + BinaryOperator.PLUS, + BinaryOperator.MINUS, + BinaryOperator.MUL, + BinaryOperator.DIV, + BinaryOperator.MOD, +]; + +function foldPlus(node: BinaryOpNode): LiteralNode { + const { left, right } = node; + + if (left instanceof IntLiteralNode && right instanceof IntLiteralNode) { + return withLocation(new IntLiteralNode(left.value + right.value), node); + } + + if (left instanceof StringLiteralNode && right instanceof StringLiteralNode) { + return withLocation(new StringLiteralNode(left.value + right.value, left.quote), node); + } + + if (left instanceof HexLiteralNode && right instanceof HexLiteralNode) { + return withLocation(new HexLiteralNode(new Uint8Array([...left.value, ...right.value])), node); + } + + throw typeMismatchError(node, PrimitiveType.INT); +} + +function foldIntArithmetic(node: BinaryOpNode): LiteralNode { + const { left, right, operator } = node; + + if (!(left instanceof IntLiteralNode) || !(right instanceof IntLiteralNode)) { + throw typeMismatchError(node, PrimitiveType.INT); + } + + if ((operator === BinaryOperator.DIV || operator === BinaryOperator.MOD) && right.value === 0n) { + throw new DivisionByZeroError(node); + } + + switch (operator) { + case BinaryOperator.MINUS: return withLocation(new IntLiteralNode(left.value - right.value), node); + case BinaryOperator.MUL: return withLocation(new IntLiteralNode(left.value * right.value), node); + // Note: BigInt division and modulo truncate towards zero, matching OP_DIV / OP_MOD semantics + case BinaryOperator.DIV: return withLocation(new IntLiteralNode(left.value / right.value), node); + case BinaryOperator.MOD: return withLocation(new IntLiteralNode(left.value % right.value), node); + default: throw new InvalidConstantExpressionError(node); + } +} + +function typeMismatchError(node: BinaryOpNode, expected: PrimitiveType): CashScriptError { + const resultingType = resultingTypeForBinaryOp(node.operator, node.left.type!, node.right.type!); + if (resultingType) return new UnsupportedTypeError(node, resultingType, expected); + return new UnequalTypeError(node); +} + +function withLocation(literal: T, source: Node): T { + literal.location = source.location; + return literal; +} diff --git a/packages/cashc/src/semantic/LowerGlobalConstantsTraversal.ts b/packages/cashc/src/semantic/LowerGlobalConstantsTraversal.ts index 56845d1b..c6f4e68f 100644 --- a/packages/cashc/src/semantic/LowerGlobalConstantsTraversal.ts +++ b/packages/cashc/src/semantic/LowerGlobalConstantsTraversal.ts @@ -4,6 +4,7 @@ import { ConsoleStatementNode, ConstantDefinitionNode, ContractNode, + ExpressionNode, FunctionCallNode, FunctionDefinitionNode, FunctionKind, @@ -96,17 +97,25 @@ function createConstantFunction(constant: ConstantDefinitionNode): FunctionDefin return definition; } -// Create a synthetic LiteralNode that represents a reference to a lowered constant function, -// so later passes can treat it as a literal -export function createConstantLiteral(constant: ConstantDefinitionNode, reference: IdentifierNode): LiteralNode { +// Clone a constant's literal value, adopting the reference's location and the constant's declared type +export function cloneConstantValue(constant: ConstantDefinitionNode, reference: IdentifierNode): LiteralNode { const literal = cloneLiteral(constant.value); literal.location = reference.location; literal.type = constant.type; + return literal; +} + +// Create a synthetic LiteralNode that represents a reference to a lowered constant function, +// so later passes can treat it as a literal +export function createConstantLiteral(constant: ConstantDefinitionNode, reference: IdentifierNode): LiteralNode { + const literal = cloneConstantValue(constant, reference); literal.constant = constant; return literal; } -function cloneLiteral(node: LiteralNode): LiteralNode { +// SymbolTableTraversal folds every constant's value to a literal before constants are lowered or referenced +function cloneLiteral(node: ExpressionNode): LiteralNode { + if (!(node instanceof LiteralNode)) throw new Error('Expected constant value to be folded to a literal'); // Shouldn't happen const clone: LiteralNode = Object.assign(Object.create(Object.getPrototypeOf(node)), node); if (clone instanceof HexLiteralNode) clone.value = clone.value.slice(); return clone; diff --git a/packages/cashc/src/semantic/TypeCheckTraversal.ts b/packages/cashc/src/semantic/TypeCheckTraversal.ts index f0b89b2a..8a5af663 100644 --- a/packages/cashc/src/semantic/TypeCheckTraversal.ts +++ b/packages/cashc/src/semantic/TypeCheckTraversal.ts @@ -64,6 +64,7 @@ export default class TypeCheckTraversal extends AstTraversal { private currentFunctionReturnTypes: Type[] = []; visitConstantDefinition(node: ConstantDefinitionNode): Node { + // The constant's value has already been folded to a literal by SymbolTableTraversal node.value = this.visit(node.value) as LiteralNode; expectAssignable(node, node.value.type, node.type); return node; diff --git a/packages/cashc/test/compiler/DivisionByZeroError/global_constant_division_by_zero.cash b/packages/cashc/test/compiler/DivisionByZeroError/global_constant_division_by_zero.cash new file mode 100644 index 00000000..464478aa --- /dev/null +++ b/packages/cashc/test/compiler/DivisionByZeroError/global_constant_division_by_zero.cash @@ -0,0 +1,7 @@ +int constant DIVIDED = 10 / 0; + +contract GlobalConstantDivisionByZero() { + function spend() { + require(DIVIDED == 0); + } +} diff --git a/packages/cashc/test/compiler/InvalidConstantExpressionError/global_constant_unsupported_expression.cash b/packages/cashc/test/compiler/InvalidConstantExpressionError/global_constant_unsupported_expression.cash new file mode 100644 index 00000000..cd8f91ff --- /dev/null +++ b/packages/cashc/test/compiler/InvalidConstantExpressionError/global_constant_unsupported_expression.cash @@ -0,0 +1,7 @@ +int constant LOCKTIME = tx.locktime; + +contract GlobalConstantUnsupportedExpression() { + function spend() { + require(LOCKTIME == 0); + } +} diff --git a/packages/cashc/test/compiler/ParseError/global_constant_non_literal.cash b/packages/cashc/test/compiler/ParseError/global_constant_non_literal.cash deleted file mode 100644 index c9ee4ec4..00000000 --- a/packages/cashc/test/compiler/ParseError/global_constant_non_literal.cash +++ /dev/null @@ -1,7 +0,0 @@ -int constant VALUE = 4 + 9; - -contract GlobalConstantNonLiteral() { - function spend() { - require(VALUE == 13); - } -} diff --git a/packages/cashc/test/compiler/UndefinedReferenceError/global_constant_forward_reference.cash b/packages/cashc/test/compiler/UndefinedReferenceError/global_constant_forward_reference.cash new file mode 100644 index 00000000..15b8d7c4 --- /dev/null +++ b/packages/cashc/test/compiler/UndefinedReferenceError/global_constant_forward_reference.cash @@ -0,0 +1,8 @@ +int constant DERIVED = BASE + 1; +int constant BASE = 41; + +contract GlobalConstantForwardReference() { + function spend() { + require(DERIVED == 42); + } +} diff --git a/packages/cashc/test/compiler/UnequalTypeError/global_constant_mixed_operands.cash b/packages/cashc/test/compiler/UnequalTypeError/global_constant_mixed_operands.cash new file mode 100644 index 00000000..b297cb48 --- /dev/null +++ b/packages/cashc/test/compiler/UnequalTypeError/global_constant_mixed_operands.cash @@ -0,0 +1,7 @@ +int constant MIXED = 10 + true; + +contract GlobalConstantMixedOperands() { + function spend() { + require(MIXED == 0); + } +} diff --git a/packages/cashc/test/global-definitions.test.ts b/packages/cashc/test/global-definitions.test.ts index bbb735de..27a4a0e2 100644 --- a/packages/cashc/test/global-definitions.test.ts +++ b/packages/cashc/test/global-definitions.test.ts @@ -143,7 +143,7 @@ describe('Dead-code elimination', () => { } }`; - const withConstant = compileString(`string constant MESSAGE = "debug only";\n${contract('MESSAGE')}`); + const withConstant = compileString(`string constant MESSAGE = "debug" + " only";\n${contract('MESSAGE')}`); expect(withConstant.bytecode).toEqual(compileString(contract('"debug only"')).bytecode); }); }); @@ -372,6 +372,56 @@ describe('Global constants', () => { sourceFile: 'constants.cash', }); }); + + it('folds constant definitions to literals at compile time', () => { + const contract = ` + contract Computed(int number, int derived, string text, bytes4 data) { + function spend() { + require(number == NUMBER); + require(derived == DERIVED); + require(text == TEXT); + require(data == DATA); + } + }`; + + const computed = compileString(` + int constant NUMBER = (10 + 10) * 5 - 30 / 4 % 5; + int constant DERIVED = -NUMBER * 2 + 4; + string constant TEXT = "debug" + " " + "only"; + bytes4 constant DATA = 0x0102 + 0x0304; + ${contract}`); + + const literal = compileString(` + int constant NUMBER = 98; + int constant DERIVED = -192; + string constant TEXT = "debug only"; + bytes4 constant DATA = 0x01020304; + ${contract}`); + + expect(computed.bytecode).toEqual(literal.bytecode); + }); + + it('folds references to imported constants', () => { + const importedSource = 'int constant BASE = 20 + 1;'; + const source = ` + import "./constants.cash"; + int constant DERIVED = BASE * 2; + contract Imported(int number) { + function spend() { + require(number == DERIVED); + } + }`; + + const contract = ` + contract Imported(int number) { + function spend() { + require(number == 42); + } + }`; + + const artifact = compileString(source, { files: { './constants.cash': importedSource } }); + expect(artifact.bytecode).toEqual(compileString(contract).bytecode); + }); }); describe('Stable function ID assignment', () => { diff --git a/packages/cashc/test/imports.test.ts b/packages/cashc/test/imports.test.ts index d0c1c167..01f59394 100644 --- a/packages/cashc/test/imports.test.ts +++ b/packages/cashc/test/imports.test.ts @@ -44,12 +44,10 @@ describe('Imports from the filesystem (compileFile)', () => { expect(() => compileFile(fixture('duplicate_import_main.cash'))).toThrow(RedefinitionError); }); - it('resolves a cyclic import without infinite looping', () => { - // cycle_a imports cycle_b which imports cycle_a back; de-duplication by canonical path breaks the - // cycle, and both functions (a and b) end up defined exactly once. - const artifact = compileFile(fixture('cycle_main.cash'), { disableInlining: true }); - expect(artifact.contractName).toEqual('Cycle'); - expect(countOpDefines(artifact.bytecode)).toEqual(2); + it('throws on cyclic imports', () => { + // cycle_a imports cycle_b which imports cycle_a back + expect(() => compileFile(fixture('cycle_main.cash'))).toThrow(ImportResolutionError); + expect(() => compileFile(fixture('cycle_main.cash'))).toThrow(/Cyclic import of '\.\/cycle_a\.cash'/); }); it('records provenance as the path relative to the main file', () => { diff --git a/packages/cashc/test/valid-contract-files/global_constant_arithmetic.cash b/packages/cashc/test/valid-contract-files/global_constant_arithmetic.cash new file mode 100644 index 00000000..be41fe11 --- /dev/null +++ b/packages/cashc/test/valid-contract-files/global_constant_arithmetic.cash @@ -0,0 +1,17 @@ +int constant BASE = 10 + 10; +int constant DERIVED = BASE - 5; +int constant NEGATED = -DERIVED * 2; +int constant COMPLEX = (BASE * 100 + 50) / 4 % 1000; +string constant GREETING = "hello" + " " + "world"; +bytes4 constant MAGIC = 0x0102 + 0x0304; + +contract GlobalConstantArithmetic() { + function spend(int base, int derived, int negated, int complex, string greeting, bytes4 magic) { + require(base == BASE); + require(derived == DERIVED); + require(negated == NEGATED); + require(complex == COMPLEX); + require(greeting == GREETING); + require(magic == MAGIC); + } +} diff --git a/website/docs/compiler/grammar.md b/website/docs/compiler/grammar.md index 6d28bb80..5a2ce2fb 100644 --- a/website/docs/compiler/grammar.md +++ b/website/docs/compiler/grammar.md @@ -228,7 +228,7 @@ typeCast ; constantDefinition - : typeName 'constant' Identifier '=' literal ';' + : typeName 'constant' Identifier '=' expression ';' ; VersionLiteral diff --git a/website/docs/language/contracts.md b/website/docs/language/contracts.md index 3baba574..45caffc5 100644 --- a/website/docs/language/contracts.md +++ b/website/docs/language/contracts.md @@ -41,26 +41,6 @@ The typings for the constructor arguments are only semantic and used when initia Upon initialization of the contract, constructor parameters are encoded and added to the contract's bytecode in the reversed order of their declaration. This can be important when manually constructing the contract locking script for debugging or optimization purposes. ::: -## Global constants -Global constants are declared at the **top level** of a `.cash` file, outside the contract, and can be used by contract functions and user-defined functions. Their initialiser must currently be a literal; expressions and casts are not supported. - -```solidity -int constant MAX_ATTEMPTS = 3; -int constant TIMEOUT = 12; // 12 blocks -bytes32 constant EMPTY_HASH = 0x0000000000000000000000000000000000000000000000000000000000000000; - -contract Example() { - function spend(int attempts) { - require(attempts < MAX_ATTEMPTS); - require(this.age >= TIMEOUT); - } -} -``` - -The literal must be assignable to the declared type. Global constants are immutable, and their names share the global namespace with user-defined functions and built-in symbols. Parameters and local variables cannot shadow them. - -Global constants do not become constructor arguments or mutable stack variables. The compiler treats them like zero-argument value-returning functions internally: small values and one-use constants are generally inlined, while larger values used repeatedly can be shared with `OP_DEFINE`/`OP_INVOKE`. - ## Functions The main construct in a CashScript contract is the function. A contract can contain one or multiple functions that can be executed to trigger transactions that spend money from the contract. At its core, the result of a function is just a yes or no answer to the question 'Can money be sent out of this contract?'. However, by using 'covenants it's possible to specify additional conditions — like restricting *where* money can be sent. To learn more about covenants, refer to the [CashScript Covenants Guide](/docs/guides/covenants). @@ -153,26 +133,43 @@ contract Example() { } ``` +:::info +`checkSig`, `checkMultiSig` and `this.activeBytecode` cannot be used inside a user-defined function, since they would apply to the function body rather than the contract. Use them in a contract function instead (`checkDataSig` is allowed). +::: + +### Limitations +This first version of user-defined functions is intentionally limited in scope: + +- A value-returning function must end with a single `return` statement (no early or conditional returns — compute into a variable and return it at the end). +- A void function must end with a `require` statement, just like contract functions (when it ends with an if-statement or loop, every branch must end with a `require`). + +:::note +Recursive and mutually recursive functions are allowed and compile fine. At runtime the VM control stack is limited to 100 entries, shared between recursion depth and nested `if` and loop blocks, so excessively deep recursion will fail when the contract gets spent. +::: + ## Global constants -Global constants are declared at the **top level** of a `.cash` file, outside the contract, and can be used by contract functions and user-defined functions. Their initialiser must be a literal: expressions and casts are not supported. +Global constants are declared at the **top level** of a `.cash` file, outside the contract, and can be used by contract functions and user-defined functions. Their initialiser is evaluated at compile time and must resolve to a single constant value: literals, references to previously declared constants, integer arithmetic (`+`, `-`, `*`, `/`, `%`) and string/bytes concatenation (`+`) are supported. Other expressions, such as casts, comparisons or function calls, are not. ```solidity int constant MAX_ATTEMPTS = 3; int constant TIMEOUT = 2 hours; +int constant EXTENDED_TIMEOUT = TIMEOUT + 30 minutes; bytes32 constant EMPTY_HASH = 0x0000000000000000000000000000000000000000000000000000000000000000; contract Example() { function spend(int attempts) { require(attempts < MAX_ATTEMPTS); - require(tx.time >= TIMEOUT); + require(tx.time >= EXTENDED_TIMEOUT); } } ``` -The literal must be assignable to the declared type. Global constants are immutable, and their names share the global namespace with user-defined functions and built-in symbols. Parameters and local variables cannot shadow them. +The resolved value must be assignable to the declared type. Constants may reference other constants, as long as those are declared (or imported) before they are used. Global constants are immutable, and their names share the global namespace with user-defined functions and built-in symbols. Parameters and local variables cannot shadow them. + +Global constants do not become constructor arguments or mutable stack variables. The compiler treats them like zero-argument value-returning functions internally: small values and one-use constants are generally inlined, while larger values used repeatedly can be shared with `OP_DEFINE`/`OP_INVOKE`. -### Importing functions and constants from other files -Top-level functions and constants can be split across files and pulled in with an `import` directive, which makes the imported functions and constants available as if they were declared locally. All `import` directives must appear at the **top of the file** after any `pragma` directives and before any constant, function or contract definitions. +## Importing functions and constants from other files +Top-level functions and constants can be split across files and pulled in with an `import` directive, which makes the imported functions and constants available as if they were declared locally. All `import` directives must appear at the **top of the file** after any `pragma` directives and before any constant, function or contract definitions. Cyclic imports are not allowed and result in a compile error. Imports are resolved relative to the importing file: from the filesystem when compiling with [`compileFile`](/docs/compiler#compilefile), or from the `files` compiler option when using [`compileString`](/docs/compiler#compilestring). @@ -201,20 +198,6 @@ Imported function and constant names share a single global namespace, so a name Imported files can declare their own [`pragma` directives](#pragma), and every pragma across the whole import graph — the main file and all (transitively) imported files — must be satisfied by the compiler version. -:::info -`checkSig`, `checkMultiSig` and `this.activeBytecode` cannot be used inside a user-defined function, since they would apply to the function body rather than the contract. Use them in a contract function instead (`checkDataSig` is allowed). -::: - -### Limitations -This first version of user-defined functions is intentionally limited in scope: - -- A value-returning function must end with a single `return` statement (no early or conditional returns — compute into a variable and return it at the end). -- A void function must end with a `require` statement, just like contract functions (when it ends with an if-statement or loop, every branch must end with a `require`). - -:::note -Recursive and mutually recursive functions are allowed and compile fine. At runtime the VM control stack is limited to 100 entries, shared between recursion depth and nested `if` and loop blocks, so excessively deep recursion will fail when the contract gets spent. -::: - ## Statements CashScript functions are made up of a collection of statements that determine whether money may be spent from the contract.