Sha256: 8a90241f1949cb1ccf3ffa5fdf8fb40187b5f7464aa9fb404bb359b5bd614487

Contents?: true

Size: 1.71 KB

Versions: 12

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/env node

var path = require("path");
var fs = require("fs");
var acorn = require("../dist/acorn.js");

var infile, parsed, tokens, options = {}, silent = false, compact = false, tokenize = false;

function help(status) {
  var print = (status == 0) ? console.log : console.error;
  print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6]");
  print("        [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--help] [--] infile");
  process.exit(status);
}

for (var i = 2; i < process.argv.length; ++i) {
  var arg = process.argv[i];
  if (arg[0] != "-" && !infile) infile = arg;
  else if (arg == "--" && !infile && i + 2 == process.argv.length) infile = process.argv[++i];
  else if (arg == "--ecma3") options.ecmaVersion = 3;
  else if (arg == "--ecma5") options.ecmaVersion = 5;
  else if (arg == "--ecma6") options.ecmaVersion = 6;
  else if (arg == "--ecma7") options.ecmaVersion = 7;
  else if (arg == "--locations") options.locations = true;
  else if (arg == "--allow-hash-bang") options.allowHashBang = true;
  else if (arg == "--silent") silent = true;
  else if (arg == "--compact") compact = true;
  else if (arg == "--help") help(0);
  else if (arg == "--tokenize") tokenize = true;
  else help(1);
}

try {
  var code = fs.readFileSync(infile, "utf8");

  if (!tokenize)
    parsed = acorn.parse(code, options);
  else {
    var get = acorn.tokenize(code, options);
    tokens = [];
    while (true) {
      var token = get();
      tokens.push(token);
      if (token.type.type == "eof")
        break;
    }
  }
} catch(e) {
  console.log(e.message);
  process.exit(1);
}

if (!silent)
  console.log(JSON.stringify(tokenize ? tokens : parsed, null, compact ? null : 2));

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/acorn/bin/acorn
minimum_viable_product-0.0.11 test/dummy/node_modules/acorn/bin/acorn
brwy_rails-0.0.6 test/dummy/node_modules/acorn/bin/acorn
brwy_rails-0.0.5 test/dummy/node_modules/acorn/bin/acorn
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/acorn/bin/acorn
brwy_rails-0.0.4 test/dummy/node_modules/acorn/bin/acorn
brwy_rails-0.0.3 test/dummy/node_modules/acorn/bin/acorn
brwy_rails-0.0.2 test/dummy/node_modules/acorn/bin/acorn
brwy_rails-0.0.1 test/dummy/node_modules/acorn/bin/acorn
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/acorn-jsx/node_modules/acorn/bin/acorn
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/acorn-jsx/node_modules/acorn/bin/acorn
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/acorn-jsx/node_modules/acorn/bin/acorn