import type { Token } from '../lexer/Token'; import type { Range } from 'vscode-languageserver'; /** * A set of operations that must be implemented to properly handle conditional compilation chunks. * */ export interface Visitor { visitBrightScript(chunk: BrightScriptChunk): Token[]; visitDeclaration(chunk: DeclarationChunk): Token[]; visitIf(chunk: HashIfStatement): Token[]; visitError(chunk: ErrorChunk): never; } /** * The base construct of the conditional-compilation preprocessor. Represents one of many things, * but typically has a one-to-many relationship with tokens in the input BrightScript files. */ export interface Chunk { accept(visitor: Visitor): Token[]; } /** A series of BrightScript tokens that will be parsed and interpreted directly. */ export declare class BrightScriptChunk implements Chunk { readonly tokens: Token[]; constructor(tokens: Token[]); accept(visitor: Visitor): Token[]; } /** * A conditional compilation directive that declares a constant value that's in-scope only during * preprocessing. * * Typically takes the form of: * * @example * #const foo = true */ export declare class DeclarationChunk implements Chunk { readonly name: Token; readonly value: Token; constructor(name: Token, value: Token); accept(visitor: Visitor): Token[]; } /** * The combination of a conditional compilation value (or identifier) and the chunk to include if * `condition` evaluates to `true`. */ export interface HashElseIfStatement { condition: Token; thenChunks: Chunk[]; } /** * A directive that adds the "conditional" to "conditional compilation". Typically takes the form * of: * * @example * #if foo * someBrightScriptGoesHere() * #else if bar * compileSomeOtherCode() * #else * otherwise("compile this!") * #end if */ export declare class HashIfStatement implements Chunk { readonly condition: Token; readonly thenChunks: Chunk[]; readonly elseIfs: HashElseIfStatement[]; readonly elseChunks?: Chunk[]; constructor(condition: Token, thenChunks: Chunk[], elseIfs: HashElseIfStatement[], elseChunks?: Chunk[]); accept(visitor: Visitor): Token[]; } /** * A forced BrightScript compilation error with a message attached. Typically takes the form of: * * @example * #error Some message describing the error goes here. */ export declare class ErrorChunk implements Chunk { readonly hashError: Token; readonly message: Token; constructor(hashError: Token, message: Token); readonly range: Range; accept(visitor: Visitor): never; }