UNPKG

proc_macro

Version:
77 lines 2.57 kB
import Token from "../tokens/token"; import { IString, IJavaScript, IEqual, IClone } from "./interfaces"; import Expression from "../expressions/expression"; declare type ReadonlyTokens = readonly Token[]; export default class TokenStream implements IString, IJavaScript, IEqual, IClone { private _stream; constructor(tokens?: Token[]); get empty(): boolean; clone(): TokenStream; eq(other: any): boolean; /** * Adds`other` TokenStream to end of `this` TokenStream. * @param other Tokens stream to add. */ concat(other: TokenStream): TokenStream; /** * Checks if TokenStreams are equal until size of smallest. * @param tokenStream TokenStream to compare. */ zipEq(tokenStream: TokenStream): boolean; /** * Parses a string to a proc_macro like token tree. * @param tokenString String to parse. */ static tokenize(tokenString: string): TokenStream; /** * Peeks the next raw Token (Should use `peek` instead). */ get next(): Token; /** * Gets the raw Token array (Should use `parse` instead). */ get stream(): ReadonlyTokens; /** * Gets the next raw Token (Should use `parse` instead). */ shiftNext(): TokenStream | undefined; private shift; private slice; /** * Tagged template to determine if passed tokens are expected tokens. * @param tokens Tokens as string. * @param types Types to check. */ peek<T extends Token | Expression>(tokens: readonly string[], ...types: (new (..._: any[]) => T)[]): boolean; /** * Descriptive error for runtime error. (TODO: Using spans.) * @param msg Message to display. */ error(msg: string): Error; /** * Attempts to parse string of tokens. * @throws If cannot parse tokens. * @param tokenString String of tokens to parse. */ private parseString; /** * Checks if the object can be parsed. * @param tokenStream The TokenStream trying to parse. */ canParse(tokenStream: TokenStream): boolean; /** * Tagged template to parse tokens and types. * @param tokens String representation of tokens. * @param types */ parse<T extends Token | Expression>(tokens: readonly string[], ...types: (new (..._: any[]) => T)[]): T[]; /** * Attempts to parse a Token or Expression type. * @param type Type to parse. */ private parseType; toParenthesisString(): string; toJavaScript(): string; } export {}; //# sourceMappingURL=token_stream.d.ts.map