Remove Flow annotations and pragmas

This commit is contained in:
Sam Goldman 2016-02-28 13:07:49 -10:00
parent 5f94206382
commit 085361ad1a
7 changed files with 13 additions and 48 deletions

View File

@ -1,15 +1,8 @@
/* @flow */
// A second optional argument can be given to further configure
// the parser process. These options are recognized:
export const defaultOptions: {
sourceType: string,
allowReturnOutsideFunction: boolean,
allowImportExportEverywhere: boolean,
allowSuperOutsideMethod: boolean,
plugins: Array<string>,
strictMode: any
} = {
export const defaultOptions = {
// Source type ("script" or "module") for different semantics
sourceType: "script",
// When enabled, a return at the top level is not considered an
@ -28,7 +21,7 @@ export const defaultOptions: {
// Interpret and default an options object
export function getOptions(opts?: Object): Object {
export function getOptions(opts) {
let options = {};
for (let key in defaultOptions) {
options[key] = opts && key in opts ? opts[key] : defaultOptions[key];

View File

@ -1,4 +1,3 @@
/* @flow */
/* eslint max-len: 0 */
/**
@ -119,7 +118,7 @@ pp.processComment = function (node) {
// result in an empty array, and if so, the array must be
// deleted.
node.leadingComments = this.state.leadingComments.slice(0, i);
if ((node.leadingComments: Array<any>).length === 0) {
if (node.leadingComments.length === 0) {
node.leadingComments = null;
}

View File

@ -1,4 +1,3 @@
/* @flow */
import { reservedWords } from "../util/identifier";
import { getOptions } from "../options";
@ -7,7 +6,7 @@ import Tokenizer from "../tokenizer";
export const plugins = {};
export default class Parser extends Tokenizer {
constructor(options: Object, input: string) {
constructor(options, input) {
options = getOptions(options);
super(options, input);
@ -23,15 +22,15 @@ export default class Parser extends Tokenizer {
}
}
hasPlugin(name: string): boolean {
hasPlugin(name) {
return !!(this.plugins["*"] || this.plugins[name]);
}
extend(name: string, f: Function) {
extend(name, f) {
this[name] = f(this[name]);
}
loadPlugins(plugins: Array<string>): Object {
loadPlugins(plugins) {
let pluginMap = {};
if (plugins.indexOf("flow") >= 0) {
@ -52,13 +51,7 @@ export default class Parser extends Tokenizer {
return pluginMap;
}
parse(): {
type: "File",
program: {
type: "Program",
body: Array<Object>
}
} {
parse() {
let file = this.startNode();
let program = this.startNode();
this.nextToken();

View File

@ -1,4 +1,3 @@
/* @flow */
import { types as tt } from "../tokenizer/types";
import Parser from "./index";

View File

@ -1,4 +1,3 @@
/* @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.
@ -8,27 +7,16 @@ import { types as tt } from "./types";
import { lineBreak } from "../util/whitespace";
export class TokContext {
constructor(
token: string,
isExpr?: boolean,
preserveSpace?: boolean,
override?: Function,
) {
constructor(token, isExpr, preserveSpace, override) {
this.token = token;
this.isExpr = !!isExpr;
this.preserveSpace = !!preserveSpace;
this.override = override;
}
token: string;
isExpr: boolean;
preserveSpace: boolean;
override: ?Function;
}
export const types: {
[key: string]: TokContext;
} = {
export const types = {
b_stat: new TokContext("{", false),
b_expr: new TokContext("{", true),
b_tmpl: new TokContext("${", true),

View File

@ -1,8 +1,7 @@
/* @noflow */
import { isIdentifierStart, isIdentifierChar, isKeyword } from "../util/identifier";
/* 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";
@ -23,11 +22,6 @@ export class Token {
this.loc = new SourceLocation(state.startLoc, state.endLoc);
}
type: TokenType;
value: any;
start: number;
end: number;
loc: SourceLocation;
}
// ## Tokenizer

View File

@ -1,4 +1,3 @@
/* @flow */
// Matches a whole line break (where CRLF is considered a single
// line break). Used to count lines.
@ -6,7 +5,7 @@
export const lineBreak = /\r\n?|\n|\u2028|\u2029/;
export const lineBreakG = new RegExp(lineBreak.source, "g");
export function isNewLine(code: number): boolean {
export function isNewLine(code) {
return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
}