Revert "Remove Flow annotations and pragmas"
This reverts commit 4252244d06.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* @flow */
|
||||
|
||||
// The algorithm used to determine whether a regexp can appear at a
|
||||
// given point in the program is loosely based on sweet.js' approach.
|
||||
@@ -7,16 +8,27 @@ import { types as tt } from "./types";
|
||||
import { lineBreak } from "../util/whitespace";
|
||||
|
||||
export class TokContext {
|
||||
constructor(token, isExpr, preserveSpace, override) {
|
||||
constructor(
|
||||
token: string,
|
||||
isExpr?: boolean,
|
||||
preserveSpace?: boolean,
|
||||
override?: Function,
|
||||
) {
|
||||
this.token = token;
|
||||
this.isExpr = !!isExpr;
|
||||
this.preserveSpace = !!preserveSpace;
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
token: string;
|
||||
isExpr: boolean;
|
||||
preserveSpace: boolean;
|
||||
override: ?Function;
|
||||
}
|
||||
|
||||
export const types = {
|
||||
export const types: {
|
||||
[key: string]: TokContext;
|
||||
} = {
|
||||
b_stat: new TokContext("{", false),
|
||||
b_expr: new TokContext("{", true),
|
||||
b_tmpl: new TokContext("${", true),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* eslint max-len: 0 */
|
||||
/* eslint indent: 0 */
|
||||
|
||||
import type { TokenType } from "./types";
|
||||
import { isIdentifierStart, isIdentifierChar, isKeyword } from "../util/identifier";
|
||||
import { types as tt, keywords as keywordTypes } from "./types";
|
||||
import { types as ct } from "./context";
|
||||
@@ -21,6 +22,11 @@ export class Token {
|
||||
this.loc = new SourceLocation(state.startLoc, state.endLoc);
|
||||
}
|
||||
|
||||
type: TokenType;
|
||||
value: any;
|
||||
start: number;
|
||||
end: number;
|
||||
loc: SourceLocation;
|
||||
}
|
||||
|
||||
// ## Tokenizer
|
||||
|
||||
Reference in New Issue
Block a user