Skip to main content
Module

x/ohm_js/index.d.ts>Interval

A library and language for building parsers, interpreters, compilers, etc.
Go to Latest
interface Interval
import { type Interval } from "https://deno.land/x/ohm_js@v17.0.3/index.d.ts";

An Interval represents a subset of a string.

Properties

sourceString: string

The string containing the interval.

startIdx: number

The start index of the interval in sourceString.

endIdx: number

The end index of the interval in sourceString.

contents: string

Contents of interval

Methods

collapsedLeft(): Interval

Returns a new Interval at the start of this one

collapsedRight(): Interval

Returns a new Interval at the end of this one

coverageWith(...intervals: Interval[]): Interval

Returns a new Interval that covers this Interval and all the argument Intervals. The new Interval will start at the lowest start index and end at the largest end index.

getLineAndColumnMessage(): string

Returns a nicely-formatted string describing the start of the Interval.

getLineAndColumn(): LineAndColumnInfo

Returns a structure containing information about the location of the interval in the source string, including the line and column number.

minus(that: Interval): Interval[]

Returns an array of 0, 1, or 2 intervals that represents the result of the interval difference operation.

relativeTo(that: Interval): Interval

Returns a new Interval that has the same extent as this one, but which is relative to that, an Interval that fully covers this one.

trimmed(): Interval

Returns a new Interval which contains the same contents as this one, but with whitespace trimmed from both ends.

subInterval(offset: number, len: number): Interval

Returns a new Interval on the same source string, with the given length and beginning at startIdx + offset.