Skip to content
On this page

letter composite

Signature

ts
function letter(): Parser<string>

Description

letter parses a single alphabetical character. Returns the matched character. Unicode friendly.

Usage

ts
const Parser = letter()

Success

ts
run(Parser).with('X')

{
  isOk: true,
  span: [ 0, 1 ],
  pos: 1,
  value: 'X'
}

ts
run(Parser).with('')

{
  isOk: true,
  span: [ 0, 1 ],
  pos: 1,
  value: ''
}

Failure

ts
run(Parser).with('42')

{
  isOk: false,
  span: [ 0, 0 ],
  pos: 0,
  expected: 'letter'
}