Skip to content

State

Defined in: .work/repos/tabscript/src/state.ts:128

new State(inData, options, startPos?): State

Defined in: .work/repos/tabscript/src/state.ts:151

string

Options

number = 0

State

errors: ParseError[] = []

Defined in: .work/repos/tabscript/src/state.ts:146


readonly options: Options

Defined in: .work/repos/tabscript/src/state.ts:153

get inLine(): number

Defined in: .work/repos/tabscript/src/state.ts:170

Current input line number

number

hasMore(): boolean

Defined in: .work/repos/tabscript/src/state.ts:173

Check if more input remains to be parsed

boolean


clearTargetPos(): void

Defined in: .work/repos/tabscript/src/state.ts:181

Clear the target position used for source mapping. Called after header parsing to ensure next token gets correct position.

void


read(what): string

Defined in: .work/repos/tabscript/src/state.ts:189

Read token(s) from input, consuming them. Returns undefined if not matched. RegExp arguments must have the /y (sticky) flag.

string | RegExp

string

read(…whats): string[]

Defined in: .work/repos/tabscript/src/state.ts:190

Read token(s) from input, consuming them. Returns undefined if not matched. RegExp arguments must have the /y (sticky) flag.

…(string | RegExp)[]

string[]


peek(…whats): any

Defined in: .work/repos/tabscript/src/state.ts:245

Peek at token(s) without consuming them.

…(string | RegExp)[]

any


accept(what): string

Defined in: .work/repos/tabscript/src/state.ts:255

Read and emit token(s). Returns undefined if not matched.

string | RegExp

string

accept(…whats): string[]

Defined in: .work/repos/tabscript/src/state.ts:256

Read and emit token(s). Returns undefined if not matched.

…(string | RegExp)[]

string[]


acceptType<T, A>(func, …args): T

Defined in: .work/repos/tabscript/src/state.ts:272

Read and emit token only if not stripping types. Can also wrap a function call to strip its output when stripping types.

T

A extends any[]

(…args) => T

A

T

acceptType(what): string

Defined in: .work/repos/tabscript/src/state.ts:273

Read and emit token only if not stripping types. Can also wrap a function call to strip its output when stripping types.

string | RegExp

string

acceptType(…whats): string[]

Defined in: .work/repos/tabscript/src/state.ts:274

Read and emit token only if not stripping types. Can also wrap a function call to strip its output when stripping types.

…(string | RegExp)[]

string[]


emit(…args): void

Defined in: .work/repos/tabscript/src/state.ts:310

Emit output text. Automatically handles source mapping based on last read position. Numbers are treated as explicit position markers. false means the next arg should not have an automatic position emitted. true means the next arg should have an automatic position emitted, but it should not be used for source mapping, and the next token will get the same automatic position again.

…(string | number | boolean)[]

void


must<T>(result): T

Defined in: .work/repos/tabscript/src/state.ts:339

Require a value to be truthy, throwing ParseError otherwise.

T extends string | true

false | T | (() => false | T)

T


snapshot(): Snapshot

Defined in: .work/repos/tabscript/src/state.ts:352

Create a snapshot of current state that can be reverted later.

Snapshot


parseGroup(opts, itemFunc): boolean

Defined in: .work/repos/tabscript/src/state.ts:395

Parse a group with optional delimiters and separators.

ParseGroupOpts

() => boolean

boolean


recoverErrors(func): any

Defined in: .work/repos/tabscript/src/state.ts:441

Attempt to recover from errors during parsing.

() => any

any


justAfterNewLine(): boolean

Defined in: .work/repos/tabscript/src/state.ts:475

Check if we’re at the start of a new line (for breaking operator processing).

boolean


lastNotSpace(): boolean

Defined in: .work/repos/tabscript/src/state.ts:483

Check if the character before current position is not a space. Used to distinguish function calls foo(x) from spaced expressions foo (x).

boolean


outputEndsWith(str): boolean

Defined in: .work/repos/tabscript/src/state.ts:491

Check if the last emitted output ends with the given string. Useful for conditionally emitting closing tokens.

string

boolean


readNewline(): boolean

Defined in: .work/repos/tabscript/src/state.ts:506

Read a newline token (including handling indent changes). This is public because the Main parser loop needs it.

boolean


getResult(): object

Defined in: .work/repos/tabscript/src/state.ts:644

Format the output tokens into a final string with proper whitespace.

object

code: string

errors: ParseError[]

map: object

in: number[]

out: number[]