UNPKG

redc

Version:

Compiles RED lang into Minecraft schematics

57 lines (56 loc) 1.35 kB
export declare type Source = 'ram' | 'device' | 'input'; export declare type operand = string | number; export declare type UnaryOperators = 'not' | 'shift'; export declare type BinaryOperators = 'and' | 'or' | 'xor' | 'plus'; export interface UnaryOperator { type: UnaryOperators; assignedTo: string; operand: operand; } export interface BinaryOperator { type: BinaryOperators; assignedTo: string; operand1: operand; operand2: operand; } export declare type Instruction = (BinaryOperator | UnaryOperator | { type: 'assignment'; assignedTo: string; value: operand; } | { type: 'jump'; to: string; if?: string; } | { type: 'pointer'; source: Source; at: string; to: string; } | { type: 'ptrcopy'; source: Source; at: string; to: string; } | { type: 'exit'; }) & { line: number; }; export interface ParseData { variables: Record<string, { source: Source; address: number; }>; routines: Record<string, Instruction[]>; entry: string; } interface Context { scope: 'main' | 'routine'; parseData: ParseData; currentRoutine: string; tags: string[]; line: number; } export declare function parseLine(line: string, context: Context): string | void; export declare function parse(lines: string[]): ParseData; export {};