You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
import {ScriptFile} from "./ScriptValue.js"
|
|
|
|
export interface Options {
|
|
/** Whether this is a script or an expression. Required. */
|
|
readonly start: "ScriptFile"|"Expression"
|
|
/** The file (or other source) the text is being parsed from. Required.*/
|
|
readonly grammarSource: string
|
|
}
|
|
|
|
export interface Position {
|
|
readonly offset: number
|
|
readonly line: number
|
|
readonly column: number
|
|
}
|
|
|
|
export interface Location {
|
|
readonly source: string
|
|
readonly start: Position
|
|
readonly end: Position
|
|
}
|
|
|
|
// For later:
|
|
//export function parse(text: string, options: Options & {readonly start: "Expression"}): Expression
|
|
export function parse(text: string, options: Options & {readonly start: "ScriptFile"}): ScriptFile
|
|
|
|
export class SyntaxError extends Error {
|
|
readonly name: "SyntaxError"
|
|
readonly message: string
|
|
readonly expected: (readonly string[])|null
|
|
readonly found: string|null
|
|
readonly location: Location
|
|
constructor(message: string, expected: (readonly string[])|null, found: string|null, location: Location)
|
|
format(mappings: readonly {readonly source: string, readonly text: string}[]): string
|
|
} |