import { TemplateError } from './errors'; import { Opcode } from './opcodes'; import { Sink } from './sink'; import { Code, Instruction, Root } from './instructions'; type AssemblerState = (type: Opcode, inst: Instruction, push: boolean) => AssemblerState; /** * Assembles a stream of instructions into a valid tree that can be executed. * As individual instructions are parsed they are fed to this state machine. */ export declare class Assembler extends Sink { errors: TemplateError[]; root: Root; private stack; private state; private current?; constructor(); /** * Accept an instruction and weave it into the instruction tree. */ accept(inst: Instruction): void; /** * Accept an error and append to the errors array. */ error(err: TemplateError): void; /** * Indicates that the last instruction has been fed to the assembler. * Performs a check and returns a flag indicating success. */ complete(): boolean; /** * Return the raw code assembled. */ code(): Code; /** * Append the next instruction to the current instruction's consequent block, * then push the next instruction onto the stack. */ pushConsequent(type: Opcode, inst: Instruction): AssemblerState; /** * Push a block instruction onto the stack. */ push(type: Opcode, inst: Instruction): AssemblerState; /** * Pop a block instruction off the stack. */ pop(): AssemblerState; /** * Return the handler state for a given instruction type. */ stateFor(type: Opcode): AssemblerState; /** * Append to the current instruction's consequent block. */ addConsequent(inst: Instruction): void; /** * Set the alternate branch instruction. */ setAlternate(inst: Instruction): void; /** * ALTERNATES_WITH state. */ stateAlternatesWith(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * Block state handles MACRO and STRUCT. */ stateBlock(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * Dead state. */ stateDead(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * EOF state. */ stateEOF(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * IF state. */ stateIf(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * OR_PREDICATE state. */ stateOrPredicate(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * PREDICATE state. */ statePredicate(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * REPEATED state. */ stateRepeated(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * ROOT state. */ stateRoot(type: Opcode, inst: Instruction, push: boolean): AssemblerState; /** * SECTION state. */ stateSection(type: Opcode, inst: Instruction, push: boolean): AssemblerState; } export {};