|
|
|
@ -5,7 +5,7 @@ export as namespace peg;
|
|
|
|
|
|
|
|
|
|
declare namespace peg {
|
|
|
|
|
|
|
|
|
|
type Grammar = parser.ast.Grammar;
|
|
|
|
|
type AST = parser.Grammar;
|
|
|
|
|
type GeneratedParser<T = any> = gp.API<T>;
|
|
|
|
|
type SyntaxError = gp.SyntaxErrorConstructor;
|
|
|
|
|
type SourceLocation = gp.SourceLocation;
|
|
|
|
@ -34,47 +34,82 @@ declare namespace peg {
|
|
|
|
|
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;
|
|
|
|
|
type: string;
|
|
|
|
|
location: SourceLocation;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Basic representation of a PEG.js node.
|
|
|
|
|
*/
|
|
|
|
|
interface INode {
|
|
|
|
|
constructor( type: string, location: SourceLocation );
|
|
|
|
|
|
|
|
|
|
type: string;
|
|
|
|
|
location: SourceLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* The main PEG.js AST class returned by the parser.
|
|
|
|
|
*/
|
|
|
|
|
class Grammar extends Node {
|
|
|
|
|
|
|
|
|
|
interface Grammar extends INode {
|
|
|
|
|
// Default properties and methods
|
|
|
|
|
|
|
|
|
|
// Default properties
|
|
|
|
|
private readonly _alwaysConsumesOnSuccess: any;
|
|
|
|
|
type: "grammar";
|
|
|
|
|
comments?: CommentMao;
|
|
|
|
|
initializer?: ast.Initializer;
|
|
|
|
|
rules: ast.Rule[];
|
|
|
|
|
|
|
|
|
|
type: "grammar";
|
|
|
|
|
initializer?: Initializer;
|
|
|
|
|
rules: Rule[];
|
|
|
|
|
constructor(
|
|
|
|
|
initializer: void | ast.Initializer,
|
|
|
|
|
rules: ast.Rule[],
|
|
|
|
|
comments: void | CommentMao,
|
|
|
|
|
location: SourceLocation,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Added by Bytecode generator
|
|
|
|
|
findRule( name: string ): ast.Rule | void;
|
|
|
|
|
indexOfRule( name: string ): number;
|
|
|
|
|
alwaysConsumesOnSuccess( node: ast.Node ): boolean;
|
|
|
|
|
|
|
|
|
|
consts?: string[];
|
|
|
|
|
// Added by Bytecode generator
|
|
|
|
|
|
|
|
|
|
// Added by JavaScript generator
|
|
|
|
|
literals?: string[];
|
|
|
|
|
classes?: string[];
|
|
|
|
|
expectations?: string[];
|
|
|
|
|
functions?: string[];
|
|
|
|
|
|
|
|
|
|
code?: string;
|
|
|
|
|
// Added by JavaScript generator
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
code?: string;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|