Skip to content
On this page

octal composite

Signature

ts
function octal(): Parser<number>

Description

octal parses an octal number prefixed with 0o or 0O, e.g. 0o42, 0O42. Returns a decimal number obtained using parseInt with radix of 8.

Usage

ts
const Parser = octal()

Success

ts
run(Parser).with('0o42')

{
  isOk: true,
  span: [ 0, 4 ],
  pos: 4,
  value: 34
}

Failure

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

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