@types/nearley
Advanced tools
Comparing version 2.9.0 to 2.11.0
@@ -1,4 +0,5 @@ | ||
// Type definitions for nearley 2.9 | ||
// Type definitions for nearley 2.11 | ||
// Project: https://github.com/Hardmath123/nearley#readme | ||
// Definitions by: Nikita Litvin <https://github.com/deltaidea> | ||
// BendingBender <https://github.com/BendingBender> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -9,17 +10,6 @@ | ||
export class Parser { | ||
constructor(rules: Rule[], start: string, options?: ParserOptions); | ||
constructor(grammar: Grammar, options?: ParserOptions); | ||
/** | ||
* The Parser object can be fed data in parts with .feed(data). | ||
* You can then find an array of parsings with the .results property. | ||
* If results is empty, then there are no parsings. | ||
* If results contains multiple values, then that combination is ambiguous. | ||
* | ||
* @throws If there are no possible parsings, nearley will throw an error | ||
* whose offset property is the index of the offending token. | ||
* Reserved token for indicating a parse fail. | ||
*/ | ||
feed(chunk: string): void; | ||
finish(): any[]; | ||
restore(column: {[x: string]: any, lexerState: LexerState}): void; | ||
save(): LexerState; | ||
static fail: {}; | ||
@@ -39,6 +29,17 @@ grammar: Grammar; | ||
constructor(grammar: Grammar, options?: ParserOptions); | ||
/** | ||
* Reserved token for indicating a parse fail. | ||
* The Parser object can be fed data in parts with .feed(data). | ||
* You can then find an array of parsings with the .results property. | ||
* If results is empty, then there are no parsings. | ||
* If results contains multiple values, then that combination is ambiguous. | ||
* | ||
* @throws If there are no possible parsings, nearley will throw an error | ||
* whose offset property is the index of the offending token. | ||
*/ | ||
static fail: {}; | ||
feed(chunk: string): this; | ||
finish(): any[]; | ||
restore(column: {[key: string]: any, lexerState: LexerState}): void; | ||
save(): {[key: string]: any, lexerState: LexerState}; | ||
} | ||
@@ -52,22 +53,44 @@ | ||
export class Rule { | ||
constructor(name: any, symbols: any, postprocess: any); | ||
toString(withCursorAt: any): any; | ||
static highestId: number; | ||
id: number; | ||
name: string; | ||
symbols: any[]; | ||
postprocess?: Postprocessor; | ||
constructor(name: string, symbols: any[], postprocess?: Postprocessor); | ||
toString(withCursorAt?: number): string; | ||
} | ||
export class Grammar { | ||
constructor(rules: Rule[], start: string); | ||
static fromCompiled(rules: CompiledRules): Grammar; | ||
rules: Rule[]; | ||
byName: {[x: string]: Rule}; | ||
start: string; | ||
byName: {[ruleName: string]: Rule[]}; | ||
lexer?: Lexer; | ||
constructor(rules: Rule[]); | ||
} | ||
export namespace Grammar { | ||
function fromCompiled(rules: Rule[], start: string): Grammar; | ||
export interface CompiledRules { | ||
Lexer?: Lexer; | ||
ParserStart: string; | ||
ParserRules: ParserRule[]; | ||
} | ||
export interface ParserRule { | ||
name: string; | ||
symbols: any[]; | ||
postprocess?: Postprocessor; | ||
} | ||
export type Postprocessor = (data: any[], reference: number, wantedBy: {}) => void; | ||
export interface Lexer { | ||
/** | ||
* Sets the internal buffer to chunk, and restore line/col/state info taken from save(). | ||
* Sets the internal buffer to data, and restores line/col/state info taken from save(). | ||
*/ | ||
reset(chunk: string, state?: LexerState): void; | ||
reset(data: string, state?: LexerState): void; | ||
/** | ||
@@ -87,14 +110,6 @@ * Returns e.g. {type, value, line, col, …}. Only the value attribute is required. | ||
*/ | ||
formatError(token: Token): string; | ||
/** | ||
* Returns true if the lexer can emit tokens with that name. | ||
* Used to resolve %-specifiers in compiled nearley grammars. | ||
*/ | ||
has(tokenType: string): boolean; | ||
formatError(token: Token, message: string): string; | ||
} | ||
export interface Token { | ||
[x: string]: any; | ||
value: string; | ||
} | ||
export type Token = string | { value: string; }; | ||
@@ -101,0 +116,0 @@ export interface LexerState { |
{ | ||
"name": "@types/nearley", | ||
"version": "2.9.0", | ||
"version": "2.11.0", | ||
"description": "TypeScript definitions for nearley", | ||
@@ -10,2 +10,6 @@ "license": "MIT", | ||
"url": "https://github.com/deltaidea" | ||
}, | ||
{ | ||
"name": "BendingBender", | ||
"url": "https://github.com/BendingBender" | ||
} | ||
@@ -20,5 +24,4 @@ ], | ||
"dependencies": {}, | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "e4fcbc3204678733bfb6781d5bb6b247175f9786d5f2ac1ad112737bc43c6c8f", | ||
"typesPublisherContentHash": "3678c44638e9ac1e086c8a43c2e9a7322fedf050596b077f81c9c9305886659a", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Mon, 05 Jun 2017 19:55:52 GMT | ||
* Last updated: Fri, 25 Aug 2017 16:04:54 GMT | ||
* Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: nearley | ||
# Credits | ||
These definitions were written by Nikita Litvin <https://github.com/deltaidea>. | ||
These definitions were written by Nikita Litvin <https://github.com/deltaidea>, BendingBender <https://github.com/BendingBender>. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5918
95