Update tsd to include latest changes
These changes are mainly from from @Minigun and @futagoza
This commit is contained in:
parent
4b6ceb2b46
commit
f41ef82ce9
81
lib/typings/api.d.ts
vendored
81
lib/typings/api.d.ts
vendored
|
@ -5,7 +5,7 @@ export as namespace peg;
|
||||||
|
|
||||||
declare namespace peg {
|
declare namespace peg {
|
||||||
|
|
||||||
type Grammar = parser.ast.Grammar;
|
type AST = parser.Grammar;
|
||||||
type GeneratedParser<T = any> = gp.API<T>;
|
type GeneratedParser<T = any> = gp.API<T>;
|
||||||
type SyntaxError = gp.SyntaxErrorConstructor;
|
type SyntaxError = gp.SyntaxErrorConstructor;
|
||||||
type SourceLocation = gp.SourceLocation;
|
type SourceLocation = gp.SourceLocation;
|
||||||
|
@ -34,41 +34,47 @@ declare namespace peg {
|
||||||
namespace parser {
|
namespace parser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface's that describe the abstact sytax tree used by PEG.js
|
* PEG.js node constructor, used internally by the PEG.js to create nodes.
|
||||||
*/
|
*/
|
||||||
namespace ast {
|
class Node {
|
||||||
|
|
||||||
/**
|
|
||||||
* Unlike `parser.ast.INode` this interface represent's all PEG.js node's.
|
|
||||||
*/
|
|
||||||
type Node
|
|
||||||
= Grammar
|
|
||||||
| Initializer
|
|
||||||
| Rule
|
|
||||||
| Named
|
|
||||||
| Expression;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic representation of a PEG.js node.
|
|
||||||
*/
|
|
||||||
interface INode {
|
|
||||||
|
|
||||||
type: string;
|
type: string;
|
||||||
location: SourceLocation;
|
location: SourceLocation;
|
||||||
|
|
||||||
|
constructor( type: string, location: SourceLocation );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Grammar extends INode {
|
/**
|
||||||
|
* The main PEG.js AST class returned by the parser.
|
||||||
|
*/
|
||||||
|
class Grammar extends Node {
|
||||||
|
|
||||||
// Default properties
|
// Default properties and methods
|
||||||
|
|
||||||
|
private readonly _alwaysConsumesOnSuccess: any;
|
||||||
type: "grammar";
|
type: "grammar";
|
||||||
initializer?: Initializer;
|
comments?: CommentMao;
|
||||||
rules: Rule[];
|
initializer?: ast.Initializer;
|
||||||
|
rules: ast.Rule[];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
initializer: void | ast.Initializer,
|
||||||
|
rules: ast.Rule[],
|
||||||
|
comments: void | CommentMao,
|
||||||
|
location: SourceLocation,
|
||||||
|
);
|
||||||
|
|
||||||
|
findRule( name: string ): ast.Rule | void;
|
||||||
|
indexOfRule( name: string ): number;
|
||||||
|
alwaysConsumesOnSuccess( node: ast.Node ): boolean;
|
||||||
|
|
||||||
// Added by Bytecode generator
|
// Added by Bytecode generator
|
||||||
|
|
||||||
consts?: string[];
|
literals?: string[];
|
||||||
|
classes?: string[];
|
||||||
|
expectations?: string[];
|
||||||
|
functions?: string[];
|
||||||
|
|
||||||
// Added by JavaScript generator
|
// Added by JavaScript generator
|
||||||
|
|
||||||
|
@ -76,6 +82,35 @@ declare namespace peg {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CommentMao {
|
||||||
|
|
||||||
|
[ offset: number ]: {
|
||||||
|
|
||||||
|
text: string;
|
||||||
|
multiline: boolean;
|
||||||
|
location: SourceLocation;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface's that describe the abstact sytax tree used by PEG.js
|
||||||
|
*/
|
||||||
|
namespace ast {
|
||||||
|
|
||||||
|
interface INode extends parser.Node { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlike `parser.Node` this interface represent's all PEG.js node's.
|
||||||
|
*/
|
||||||
|
type Node
|
||||||
|
= parser.Grammar
|
||||||
|
| Initializer
|
||||||
|
| Rule
|
||||||
|
| Named
|
||||||
|
| Expression;
|
||||||
|
|
||||||
interface Initializer extends INode {
|
interface Initializer extends INode {
|
||||||
|
|
||||||
type: "initializer";
|
type: "initializer";
|
||||||
|
|
36
lib/typings/modules.d.ts
vendored
36
lib/typings/modules.d.ts
vendored
|
@ -20,27 +20,8 @@ declare module "pegjs/lib/parser" {
|
||||||
|
|
||||||
declare module "pegjs/lib/parser/ast" {
|
declare module "pegjs/lib/parser/ast" {
|
||||||
|
|
||||||
export class Node {
|
export const Node: peg.parser.Node;
|
||||||
|
export const Grammar: peg.parser.Grammar;
|
||||||
type: string;
|
|
||||||
location: peg.SourceLocation;
|
|
||||||
|
|
||||||
constructor( type: string, location: peg.SourceLocation );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Grammar extends Node {
|
|
||||||
|
|
||||||
initializer?: peg.parser.ast.Initializer;
|
|
||||||
rules: peg.parser.ast.Rule[];
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
initializer: void | peg.parser.ast.Initializer,
|
|
||||||
rules: peg.parser.ast.Rule[],
|
|
||||||
location: peg.SourceLocation,
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,19 +43,6 @@ declare module "pegjs/lib/compiler" {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "pegjs/lib/compiler/asts" {
|
|
||||||
|
|
||||||
namespace asts {
|
|
||||||
|
|
||||||
function findRule( ast: peg.Grammar, name: string ): peg.parser.ast.Rule | void;
|
|
||||||
function indexOfRule( ast: peg.Grammar, name: string ): number;
|
|
||||||
function alwaysConsumesOnSuccess( ast: peg.Grammar, node: peg.parser.ast.Node ): boolean;
|
|
||||||
|
|
||||||
}
|
|
||||||
export default asts;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "pegjs/lib/compiler/index" {
|
declare module "pegjs/lib/compiler/index" {
|
||||||
|
|
||||||
export default peg.compiler;
|
export default peg.compiler;
|
||||||
|
|
Loading…
Reference in a new issue