mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
# Conflicts: # .gitignore # ajv/ajv.d.ts # angular-material/angular-material.d.ts # angular-protractor/angular-protractor.d.ts # angularjs/angular-tests.ts # angularjs/angular.d.ts # aws-sdk/aws-sdk.d.ts # electron-devtools-installer/electron-devtools-installer-tests.ts # electron-json-storage/electron-json-storage-tests.ts # electron-notifications/electron-notifications.d.ts # electron-notify/electron-notify.d.ts # electron-window-state/electron-window-state.d.ts # electron/electron-prebuilt.d.ts # enzyme/enzyme.d.ts # eventemitter3/eventemitter3-tests.ts # eventemitter3/eventemitter3.d.ts # graphql/graphql.d.ts # highcharts/highcharts.d.ts # immutable/immutable.d.ts # inquirer/inquirer.d.ts # jasmine/jasmine.d.ts # joi/joi.d.ts # jquery.dataTables/jquery.dataTables-tests.ts # jquery.dataTables/jquery.dataTables.d.ts # kafka-node/kafka-node.d.ts # kefir/kefir.d.ts # kendo-ui/kendo-ui.d.ts # koa/koa.d.ts # leaflet/leaflet.d.ts # lodash/lodash.d.ts # mapbox-gl/mapbox-gl.d.ts # material-ui/material-ui.d.ts # menubar/menubar.d.ts # mongodb/mongodb.d.ts # needle/needle-tests.ts # needle/needle.d.ts # noble/noble.d.ts # node/node.d.ts # pegjs/pegjs.d.ts # pixi.js/pixi.js.d.ts # polymer/polymer.d.ts # quill/quill-tests.ts # quill/quill.d.ts # react-bootstrap/react-bootstrap.d.ts # react-fa/react-fa-tests.tsx # react-fa/react-fa.d.ts # react-native/react-native.d.ts # react-select/react-select.d.ts # react/react.d.ts # threejs/three-vrcontrols.d.ts # threejs/three-vreffect.d.ts # toastr/toastr.d.ts # validator/validator.d.ts # webpack/webpack.d.ts # winston/winston.d.ts
135 lines
6.2 KiB
TypeScript
135 lines
6.2 KiB
TypeScript
// Type definitions for PEG.js v0.10.0
|
|
// Project: http://pegjs.org/
|
|
// Definitions by: vvakame <https://github.com/vvakame>, Tobias Kahlert <https://github.com/SrTobi>, C.J. Bell <https://github.com/siegebell>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
declare namespace PEG {
|
|
function parse(input:string):any;
|
|
|
|
interface Location {
|
|
line: number;
|
|
column: number;
|
|
offset: number;
|
|
}
|
|
|
|
interface LocationRange {
|
|
start: Location,
|
|
end: Location
|
|
}
|
|
|
|
class SyntaxError {
|
|
line: number;
|
|
column: number;
|
|
offset: number;
|
|
location: LocationRange;
|
|
expected:any[];
|
|
found:any;
|
|
name:string;
|
|
message:string;
|
|
}
|
|
}
|
|
|
|
export type Location = PEG.Location;
|
|
export type LocationRange = PEG.LocationRange;
|
|
|
|
export interface ExpectedItem {
|
|
type: string;
|
|
value?: string;
|
|
description: string;
|
|
}
|
|
|
|
export interface PegjsError extends Error {
|
|
name: string;
|
|
message: string;
|
|
location: LocationRange;
|
|
found?: any;
|
|
expected?: ExpectedItem[];
|
|
stack?: any;
|
|
}
|
|
|
|
export type GrammarError = PegjsError;
|
|
export var GrammarError: any;
|
|
|
|
export interface ParserOptions {
|
|
startRule: string;
|
|
tracer: any;
|
|
}
|
|
|
|
export interface Parser {
|
|
parse(input: string, options?:ParserOptions): any;
|
|
|
|
SyntaxError: any;
|
|
}
|
|
|
|
export interface BuildOptionsBase {
|
|
/** rules the parser will be allowed to start parsing from (default: the first rule in the grammar) */
|
|
allowedStartRules?: string[];
|
|
/** if `true`, makes the parser cache results, avoiding exponential parsing time in pathological cases but making the parser slower (default: `false`) */
|
|
cache?: boolean;
|
|
/** selects between optimizing the generated parser for parsing speed (`"speed"`) or code size (`"size"`) (default: `"speed"`) */
|
|
optimize?: "speed" | "size";
|
|
/** plugins to use */
|
|
plugins?: any[];
|
|
/** makes the parser trace its progress (default: `false`) */
|
|
trace?: boolean
|
|
}
|
|
|
|
export interface ParserBuildOptions extends BuildOptionsBase {
|
|
/** if set to `"parser"`, the method will return generated parser object; if set to `"source"`, it will return parser source code as a string (default: `"parser"`) */
|
|
output?: "parser"
|
|
}
|
|
|
|
export interface OutputFormatAmdCommonjs extends BuildOptionsBase {
|
|
/** if set to `"parser"`, the method will return generated parser object; if set to `"source"`, it will return parser source code as a string (default: `"parser"`) */
|
|
output: "source";
|
|
/** format of the genreated parser (`"amd"`, `"bare"`, `"commonjs"`, `"globals"`, or `"umd"`); valid only when `output` is set to `"source"` (default: `"bare"`) */
|
|
format: "amd" | "commonjs";
|
|
/** parser dependencies, the value is an object which maps variables used to access the dependencies in the parser to module IDs used to load them; valid only when `format` is set to `"amd"`, `"commonjs"`, or `"umd"` (default: `{}`) */
|
|
dependencies?: any
|
|
}
|
|
|
|
export interface OutputFormatUmd extends BuildOptionsBase {
|
|
/** if set to `"parser"`, the method will return generated parser object; if set to `"source"`, it will return parser source code as a string (default: `"parser"`) */
|
|
output: "source";
|
|
/** format of the genreated parser (`"amd"`, `"bare"`, `"commonjs"`, `"globals"`, or `"umd"`); valid only when `output` is set to `"source"` (default: `"bare"`) */
|
|
format: "umd";
|
|
/** parser dependencies, the value is an object which maps variables used to access the dependencies in the parser to module IDs used to load them; valid only when `format` is set to `"amd"`, `"commonjs"`, or `"umd"` (default: `{}`) */
|
|
dependencies?: any
|
|
/** name of a global variable into which the parser object is assigned to when no module loader is detected; valid only when `format` is set to `"globals"` or `"umd"` (default: `null`) */
|
|
exportVar?: any
|
|
}
|
|
|
|
export interface OutputFormatGlobals extends BuildOptionsBase {
|
|
/** if set to `"parser"`, the method will return generated parser object; if set to `"source"`, it will return parser source code as a string (default: `"parser"`) */
|
|
output: "source";
|
|
/** format of the genreated parser (`"amd"`, `"bare"`, `"commonjs"`, `"globals"`, or `"umd"`); valid only when `output` is set to `"source"` (default: `"bare"`) */
|
|
format: "globals";
|
|
/** name of a global variable into which the parser object is assigned to when no module loader is detected; valid only when `format` is set to `"globals"` or `"umd"` (default: `null`) */
|
|
exportVar?: any
|
|
}
|
|
|
|
export interface OutputFormatBare extends BuildOptionsBase {
|
|
/** if set to `"parser"`, the method will return generated parser object; if set to `"source"`, it will return parser source code as a string (default: `"parser"`) */
|
|
output: "source";
|
|
/** format of the genreated parser (`"amd"`, `"bare"`, `"commonjs"`, `"globals"`, or `"umd"`); valid only when `output` is set to `"source"` (default: `"bare"`) */
|
|
format?: "bare"
|
|
}
|
|
|
|
/** Returns a generated parser object. It will throw an exception if the grammar is invalid. The exception will contain `message` property with more details about the error. */
|
|
export function generate(grammar: string, options?: ParserBuildOptions): Parser;
|
|
/** Returns the generated source code as a `string`. It will throw an exception if the grammar is invalid. The exception will contain `message` property with more details about the error. */
|
|
export function generate(grammar: string, options: OutputFormatAmdCommonjs): string;
|
|
/** Returns the generated source code as a `string`. It will throw an exception if the grammar is invalid. The exception will contain `message` property with more details about the error. */
|
|
export function generate(grammar: string, options: OutputFormatUmd): string;
|
|
/** Returns the generated source code as a `string`. It will throw an exception if the grammar is invalid. The exception will contain `message` property with more details about the error. */
|
|
export function generate(grammar: string, options: OutputFormatGlobals): string;
|
|
/** Returns the generated source code as a `string`. It will throw an exception if the grammar is invalid. The exception will contain `message` property with more details about the error. */
|
|
export function generate(grammar: string, options: OutputFormatBare): string;
|
|
|
|
export namespace parser {
|
|
type SyntaxError = PegjsError;
|
|
var SyntaxError: any;
|
|
}
|
|
export as namespace PEG;
|
|
|