Skip to content
On this page

run

Signature

ts
interface Runnable<T> {
  with(input: string): Result<T>
}

function run<T>(parser: Parser<T>): Runnable<T>

Description

run is used to run parser with provided input.

Usage

ts
run(string('hello world')).with('hello world')

Success

ts
{
  isOk: true,
  span: [ 0, 11 ],
  pos: 11,
  value: 'hello world'
}

Failure

ts
{
  isOk: false,
  span: [ 0, 0 ],
  pos: 0,
  expected: 'hello world'
}