Add definitions for acorn tokenizer function

This commit is contained in:
Chad Killingsworth
2017-03-06 15:28:27 -06:00
parent bbe7b0aa23
commit 796b98ffef
2 changed files with 9 additions and 3 deletions

View File

@@ -67,3 +67,6 @@ acorn.getLineInfo('string', 56);
acorn.plugins['test'] = function (p: acorn.Parser, config: any) {
}
acorn.tokenizer('console.log("hello world)', {locations: true}).getToken();
acorn.tokenizer('console.log("hello world)', {locations: true})[Symbol.iterator]().next();

9
acorn/index.d.ts vendored
View File

@@ -238,9 +238,12 @@ declare namespace acorn {
function parseExpressionAt(input: string, pos?: number, options?: Options): ESTree.Expression;
// todo: here the tokenizer function returns a Parser instance, that is targeting the detail of
// Parser prototype. Someone need this please reade README.md first.
// function tokenizer(options: Options, input: string): Parser;
interface ITokenizer {
getToken() : Token,
[Symbol.iterator](): Iterator<Token>
}
function tokenizer(input: string, options: Options): ITokenizer;
let parse_dammit: IParse | undefined;
let LooseParser: ILooseParserClass | undefined;