State
Defined in: .work/repos/tabscript/src/state.ts:128
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new State(
inData,options,startPos?):State
Defined in: .work/repos/tabscript/src/state.ts:151
Parameters
Section titled “Parameters”inData
Section titled “inData”string
options
Section titled “options”startPos?
Section titled “startPos?”number = 0
Returns
Section titled “Returns”State
Properties
Section titled “Properties”errors
Section titled “errors”errors:
ParseError[] =[]
Defined in: .work/repos/tabscript/src/state.ts:146
options
Section titled “options”
readonlyoptions:Options
Defined in: .work/repos/tabscript/src/state.ts:153
Accessors
Section titled “Accessors”inLine
Section titled “inLine”Get Signature
Section titled “Get Signature”get inLine():
number
Defined in: .work/repos/tabscript/src/state.ts:170
Current input line number
Returns
Section titled “Returns”number
Methods
Section titled “Methods”hasMore()
Section titled “hasMore()”hasMore():
boolean
Defined in: .work/repos/tabscript/src/state.ts:173
Check if more input remains to be parsed
Returns
Section titled “Returns”boolean
clearTargetPos()
Section titled “clearTargetPos()”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.
Returns
Section titled “Returns”void
read()
Section titled “read()”Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”string | RegExp
Returns
Section titled “Returns”string
Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”…(string | RegExp)[]
Returns
Section titled “Returns”string[]
peek()
Section titled “peek()”peek(…
whats):any
Defined in: .work/repos/tabscript/src/state.ts:245
Peek at token(s) without consuming them.
Parameters
Section titled “Parameters”…(string | RegExp)[]
Returns
Section titled “Returns”any
accept()
Section titled “accept()”Call Signature
Section titled “Call Signature”accept(
what):string
Defined in: .work/repos/tabscript/src/state.ts:255
Read and emit token(s). Returns undefined if not matched.
Parameters
Section titled “Parameters”string | RegExp
Returns
Section titled “Returns”string
Call Signature
Section titled “Call Signature”accept(…
whats):string[]
Defined in: .work/repos/tabscript/src/state.ts:256
Read and emit token(s). Returns undefined if not matched.
Parameters
Section titled “Parameters”…(string | RegExp)[]
Returns
Section titled “Returns”string[]
acceptType()
Section titled “acceptType()”Call Signature
Section titled “Call Signature”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.
Type Parameters
Section titled “Type Parameters”T
A extends any[]
Parameters
Section titled “Parameters”(…args) => T
…A
Returns
Section titled “Returns”T
Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”string | RegExp
Returns
Section titled “Returns”string
Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”…(string | RegExp)[]
Returns
Section titled “Returns”string[]
emit()
Section titled “emit()”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.
Parameters
Section titled “Parameters”…(string | number | boolean)[]
Returns
Section titled “Returns”void
must()
Section titled “must()”must<
T>(result):T
Defined in: .work/repos/tabscript/src/state.ts:339
Require a value to be truthy, throwing ParseError otherwise.
Type Parameters
Section titled “Type Parameters”T extends string | true
Parameters
Section titled “Parameters”result
Section titled “result”false | T | (() => false | T)
Returns
Section titled “Returns”T
snapshot()
Section titled “snapshot()”snapshot():
Snapshot
Defined in: .work/repos/tabscript/src/state.ts:352
Create a snapshot of current state that can be reverted later.
Returns
Section titled “Returns”Snapshot
parseGroup()
Section titled “parseGroup()”parseGroup(
opts,itemFunc):boolean
Defined in: .work/repos/tabscript/src/state.ts:395
Parse a group with optional delimiters and separators.
Parameters
Section titled “Parameters”ParseGroupOpts
itemFunc
Section titled “itemFunc”() => boolean
Returns
Section titled “Returns”boolean
recoverErrors()
Section titled “recoverErrors()”recoverErrors(
func):any
Defined in: .work/repos/tabscript/src/state.ts:441
Attempt to recover from errors during parsing.
Parameters
Section titled “Parameters”() => any
Returns
Section titled “Returns”any
justAfterNewLine()
Section titled “justAfterNewLine()”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).
Returns
Section titled “Returns”boolean
lastNotSpace()
Section titled “lastNotSpace()”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).
Returns
Section titled “Returns”boolean
outputEndsWith()
Section titled “outputEndsWith()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
readNewline()
Section titled “readNewline()”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.
Returns
Section titled “Returns”boolean
getResult()
Section titled “getResult()”getResult():
object
Defined in: .work/repos/tabscript/src/state.ts:644
Format the output tokens into a final string with proper whitespace.
Returns
Section titled “Returns”object
code:
string
errors
Section titled “errors”errors:
ParseError[]
map:
object
map.in
Section titled “map.in”in:
number[]
map.out
Section titled “map.out”out:
number[]