UNPKG

calcium-lang

Version:
61 lines (60 loc) 1.48 kB
import Environment from "../runtime/environment"; import Address from "./address"; /** * when returns true, the block should be executed. */ export declare type Enter = (env: Environment) => boolean; /** * executed when the block ends * The returned value represents a result when a `Block` ends with * a jump over two or more points on the address. */ export declare type Exit = (env: Environment) => Result; /** * the kind of a `Block` */ export declare enum Kind { Call = "Call", ClassDef = "ClassDef", Except = "Except", For = "For", IfElifElse = "IfElifElse", Ifs = "Ifs", ForEach = "ForEach", ForRange = "ForRange", Try = "Try", While = "While" } export declare enum Result { /** * an exception has occurred */ Invalid = "Invalid", /** * moved over two or more points */ Jumpped = "Jumpped", /** * shifted one point only */ Exited = "Exited" } /** * a syntactic scope */ export declare class Block { readonly kind: Kind; private readonly shouldEnter; private readonly willExit; readonly address: Address; /** * * @param kind * @param address * @param shouldEnter determine whether this block should be executed * @param willExit executed before this block ends */ constructor(kind: Kind, address: Address, shouldEnter: Enter, willExit: Exit); willEnter(env: Environment): void; exit(env: Environment): Result; }