• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParserRunner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.javascript.jscomp.parsing.ParserRunner的典型用法代码示例。如果您正苦于以下问题:Java ParserRunner类的具体用法?Java ParserRunner怎么用?Java ParserRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParserRunner类属于com.google.javascript.jscomp.parsing包,在下文中一共展示了ParserRunner类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parse

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private void parse(AbstractCompiler compiler, String sourceName,
    String sourceStr) {
  try {
    logger_.fine("Parsing: " + sourceName);
    root = ParserRunner.parse(sourceName, sourceStr,
        compiler.getParserConfig(),
        compiler.getDefaultErrorReporter(),
        logger_);
  } catch (IOException e) {
    compiler.report(JSError.make(AbstractCompiler.READ_ERROR, sourceName));
  }

  if (root == null || compiler.hasHaltingErrors()) {
    // There was a parse error or IOException, so use a dummy block.
    root = new Node(Token.BLOCK);
  } else {
    compiler.prepareAst(root);
  }

  // Set the source name so that the compiler passes can track
  // the source file and module.
  root.putProp(Node.SOURCENAME_PROP, sourceName);
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:24,代码来源:JsAst.java


示例2: getParserConfig

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
@Override
Config getParserConfig() {
  if (parserConfig == null) {
    Config.LanguageMode mode;
    switch (options.getLanguageIn()) {
      case ECMASCRIPT3:
        mode = Config.LanguageMode.ECMASCRIPT3;
        break;
      case ECMASCRIPT5:
        mode = Config.LanguageMode.ECMASCRIPT5;
        break;
      case ECMASCRIPT5_STRICT:
        mode = Config.LanguageMode.ECMASCRIPT5_STRICT;
        break;
      default:
        throw new IllegalStateException("unexpected language mode");
    }

    parserConfig = ParserRunner.createConfig(
      isIdeMode(),
      mode,
      acceptConstKeyword(),
      options.extraAnnotationNames);
  }
  return parserConfig;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:Compiler.java


示例3: parse

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private void parse(AbstractCompiler compiler) {
  try {
    logger_.fine("Parsing: " + sourceFile.getName());
    ParserRunner.ParseResult result = ParserRunner.parse(sourceFile, sourceFile.getCode(),
        compiler.getParserConfig(),
        compiler.getDefaultErrorReporter(),
        logger_);
    root = result.ast;
    compiler.setOldParseTree(sourceFile.getName(), result.oldAst);
  } catch (IOException e) {
    compiler.report(
        JSError.make(AbstractCompiler.READ_ERROR, sourceFile.getName()));
  }

  if (root == null || compiler.hasHaltingErrors()) {
    // There was a parse error or IOException, so use a dummy block.
    root = IR.script();
  } else {
    compiler.prepareAst(root);
  }

  // Set the source name so that the compiler passes can track
  // the source file and module.
  root.setStaticSourceFile(sourceFile);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:JsAst.java


示例4: runVariableRenaming

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private VariableMap runVariableRenaming(
    AbstractCompiler compiler, VariableMap prevVariableMap,
    Node externs, Node root) {
  char[] reservedChars =
      options.anonymousFunctionNaming.getReservedCharacters();
  boolean preserveAnonymousFunctionNames =
      options.anonymousFunctionNaming != AnonymousFunctionNamingPolicy.OFF;
  Set<String> reservedNames = Sets.newHashSet();
  if (exportedNames != null) {
    reservedNames.addAll(exportedNames);
  }
  reservedNames.addAll(ParserRunner.getReservedVars());
  RenameVars rn = new RenameVars(
      compiler,
      options.renamePrefix,
      options.variableRenaming == VariableRenamingPolicy.LOCAL,
      preserveAnonymousFunctionNames,
      options.generatePseudoNames,
      options.shadowVariables,
      prevVariableMap,
      reservedChars,
      reservedNames);
  rn.process(externs, root);
  return rn.getVariableMap();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:DefaultPassConfig.java


示例5: getParserConfig

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
@Override
Config getParserConfig() {
  if (parserConfig == null) {
    parserConfig = ParserRunner.createConfig(
        getTypeRegistry(), isIdeMode());
  }
  return parserConfig;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:Compiler.java


示例6: getParserConfig

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
@Override
Config getParserConfig() {
  if (parserConfig == null) {
    parserConfig = ParserRunner.createConfig(isIdeMode());
  }
  return parserConfig;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:8,代码来源:Compiler.java


示例7: parse

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
/**
 * Parses the given JavaScript string into an abstract syntax tree.
 *
 * @param js The JavaScript code.
 * @param inputFileName The source filename to associate with the input JS.
 * @return An abstract syntax tree.
 * @throws JavaScriptParsingException if parse errors were encountered.
 */
private static Node parse(String js, String inputFileName) throws JavaScriptParsingException {
  StaticSourceFile file = new SimpleSourceFile(inputFileName, false);
  Config config = ParserRunner.createConfig(LanguageMode.ECMASCRIPT6, null, StrictMode.SLOPPY);
  JavaScriptErrorReporter errorReporter = new JavaScriptErrorReporter(js);
  Node script = ParserRunner.parse(file, js, config, errorReporter).ast;
  if (script == null) {
    throw new JavaScriptParsingException(errorReporter.getWarningAndErrorOutput());
  }
  return script;
}
 
开发者ID:PolymerLabs,项目名称:PolymerRenamer,代码行数:19,代码来源:JsRenamer.java


示例8: createConfig

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
protected Config createConfig(Config.LanguageMode mode, Config.StrictMode strictMode) {
  Config config =
      ParserRunner.createConfig(
          mode,
          options.isParseJsDocDocumentation(),
          options.canContinueAfterErrors()
              ? Config.RunMode.KEEP_GOING
              : Config.RunMode.STOP_AFTER_ERROR,
          options.extraAnnotationNames,
          options.parseInlineSourceMaps,
          strictMode);
  return config;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:14,代码来源:Compiler.java


示例9: runVariableRenaming

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private VariableMap runVariableRenaming(
    AbstractCompiler compiler, VariableMap prevVariableMap,
    Node externs, Node root) {
  char[] reservedChars =
      options.anonymousFunctionNaming.getReservedCharacters();
  boolean preserveAnonymousFunctionNames =
      options.anonymousFunctionNaming != AnonymousFunctionNamingPolicy.OFF;
  Set<String> reservedNames = new HashSet<>();
  if (options.renamePrefixNamespace != null) {
    // don't use the prefix name as a global symbol.
    reservedNames.add(options.renamePrefixNamespace);
  }
  reservedNames.addAll(compiler.getExportedNames());
  reservedNames.addAll(ParserRunner.getReservedVars());
  RenameVars rn = new RenameVars(
      compiler,
      options.renamePrefix,
      options.variableRenaming == VariableRenamingPolicy.LOCAL,
      preserveAnonymousFunctionNames,
      options.generatePseudoNames,
      options.shadowVariables,
      options.preferStableNames,
      prevVariableMap,
      reservedChars,
      reservedNames,
      options.nameGenerator);
  rn.process(externs, root);
  return rn.getVariableMap();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:30,代码来源:DefaultPassConfig.java


示例10: parse

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
/** Internal implementation to produce the {@link FileInfo} object. */
private static FileInfo parse(String code, String filename, @Nullable Reporter reporter) {
  ErrorReporter errorReporter = new DelegatingReporter(reporter);
  Compiler compiler = new Compiler();
  compiler.init(
      ImmutableList.<SourceFile>of(), ImmutableList.<SourceFile>of(), new CompilerOptions());

  Config config =
      ParserRunner.createConfig(
          // TODO(sdh): ES8 STRICT, with a non-strict fallback - then give warnings.
          Config.LanguageMode.ECMASCRIPT8,
          Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE,
          Config.RunMode.KEEP_GOING,
          /* extraAnnotationNames */ ImmutableSet.<String>of(),
          /* parseInlineSourceMaps */ true,
          Config.StrictMode.SLOPPY);

  SourceFile source = SourceFile.fromCode(filename, code);
  FileInfo info = new FileInfo(errorReporter);
  ParserRunner.ParseResult parsed = ParserRunner.parse(source, code, config, errorReporter);
  parsed.ast.setInputId(new InputId(filename));
  String version = parsed.features.version();
  if (!version.equals("es3")) {
    info.loadFlags.add(JsArray.of("lang", version));
  }

  for (Comment comment : parsed.comments) {
    if (comment.type == Comment.Type.JSDOC) {
      parseComment(comment, info);
    }
  }
  NodeTraversal.traverseEs6(compiler, parsed.ast, new Traverser(info));
  return info;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:35,代码来源:JsfileParser.java


示例11: createConfig

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
protected Config createConfig(Config.LanguageMode mode) {
  return ParserRunner.createConfig(
    isIdeMode(),
    mode,
    acceptConstKeyword(),
    options.extraAnnotationNames,
    options.useNewParser);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:9,代码来源:Compiler.java


示例12: parse

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private void parse(AbstractCompiler compiler) {
  int startErrorCount = compiler.getErrorManager().getErrorCount();
  try {
    ParserRunner.ParseResult result = ParserRunner.parse(sourceFile, sourceFile.getCode(),
        compiler.getParserConfig(sourceFile.isExtern()
            ? AbstractCompiler.ConfigContext.EXTERNS
            : AbstractCompiler.ConfigContext.DEFAULT),
        compiler.getDefaultErrorReporter(),
        logger_);
    root = result.ast;
    compiler.addComments(sourceFile.getName(), result.comments);
  } catch (IOException e) {
    compiler.report(
        JSError.make(AbstractCompiler.READ_ERROR, sourceFile.getName()));
  }


  if (root == null ||
      // Most passes try to report as many errors as possible,
      // so there may already be errors. We only care if there were
      // errors in the code we just parsed.
      (compiler.getErrorManager().getErrorCount() > startErrorCount && !compiler.isIdeMode())) {
    // There was a parse error or IOException, so use a dummy block.
    root = IR.script();
  } else {
    compiler.prepareAst(root);
  }

  // Set the source name so that the compiler passes can track
  // the source file and module.
  root.setStaticSourceFile(sourceFile);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:33,代码来源:JsAst.java


示例13: runVariableRenaming

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private VariableMap runVariableRenaming(
    AbstractCompiler compiler, VariableMap prevVariableMap,
    Node externs, Node root) {
  char[] reservedChars =
      options.anonymousFunctionNaming.getReservedCharacters();
  boolean preserveAnonymousFunctionNames =
      options.anonymousFunctionNaming != AnonymousFunctionNamingPolicy.OFF;
  Set<String> reservedNames = Sets.newHashSet();
  if (options.renamePrefixNamespace != null) {
    // don't use the prefix name as a global symbol.
    reservedNames.add(options.renamePrefixNamespace);
  }
  if (exportedNames != null) {
    reservedNames.addAll(exportedNames);
  }
  reservedNames.addAll(ParserRunner.getReservedVars());
  RenameVars rn = new RenameVars(
      compiler,
      options.renamePrefix,
      options.variableRenaming == VariableRenamingPolicy.LOCAL,
      preserveAnonymousFunctionNames,
      options.generatePseudoNames,
      options.shadowVariables,
      options.preferStableNames,
      prevVariableMap,
      reservedChars,
      reservedNames);
  rn.process(externs, root);
  return rn.getVariableMap();
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:31,代码来源:DefaultPassConfig.java


示例14: parse

import com.google.javascript.jscomp.parsing.ParserRunner; //导入依赖的package包/类
private void parse(AbstractCompiler compiler) {
  int startErrorCount = compiler.getErrorManager().getErrorCount();
  try {
    ParserRunner.ParseResult result = ParserRunner.parse(sourceFile, sourceFile.getCode(),
        compiler.getParserConfig(),
        compiler.getDefaultErrorReporter(),
        logger_);
    root = result.ast;
    compiler.setOldParseTree(sourceFile.getName(), result.oldAst);
  } catch (IOException e) {
    compiler.report(
        JSError.make(AbstractCompiler.READ_ERROR, sourceFile.getName()));
  }


  if (root == null ||
      // Most passes try to report as many errors as possible,
      // so there may already be errors. We only care if there were
      // errors in the code we just parsed.
      (compiler.getErrorManager().getErrorCount() > startErrorCount && !compiler.isIdeMode())) {
    // There was a parse error or IOException, so use a dummy block.
    root = IR.script();
  } else {
    compiler.prepareAst(root);
  }

  // Set the source name so that the compiler passes can track
  // the source file and module.
  root.setStaticSourceFile(sourceFile);
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:31,代码来源:JsAst.java



注:本文中的com.google.javascript.jscomp.parsing.ParserRunner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultParserNotice类代码示例发布时间:2022-05-23
下一篇:
Java AttributeNames类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap