org.jruby.Ruby.parseFromMain()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.jruby.Ruby.parseFromMain方法的一些代码示例,展示了Ruby.parseFromMain的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.parseFromMain方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:parseFromMain

Ruby.parseFromMain介绍

[英]Parse the script contained in the given input stream, using the given filename as the name of the script, and return the root Node. This is used to verify that the script syntax is valid, for jruby -c. The current scope (generally the top-level scope) is used as the parent scope for parsing.
[中]使用给定的文件名作为脚本名,解析给定输入流中包含的脚本,并返回根节点。这用于验证jruby-c的脚本语法是否有效。当前作用域(通常是顶级作用域)用作解析的父作用域。

代码示例

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename) {
  try {
    runtime.parseFromMain(in, filename);
    config.getOutput().println("Syntax OK");
    return true;
  } catch (RaiseException re) {
    if (re.getException().getMetaClass().getBaseName().equals("SyntaxError")) {
      config.getError().println("SyntaxError in " + re.getException().message(runtime.getCurrentContext()));
    } else {
      throw re;
    }
    return false;
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename) {
  try {
    runtime.parseFromMain(in, filename);
    config.getOutput().println("Syntax OK");
    return true;
  } catch (RaiseException re) {
    if (re.getException().getMetaClass().getBaseName().equals("SyntaxError")) {
      config.getError().println("SyntaxError in " + re.getException().message(runtime.getCurrentContext()));
    } else {
      throw re;
    }
    return false;
  }
}

代码示例来源:origin: org.jruby/jruby-complete

private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename) {
  final ThreadContext context = runtime.getCurrentContext();
  final IRubyObject $ex = context.getErrorInfo();
  try {
    runtime.parseFromMain(in, filename);
    config.getOutput().println("Syntax OK");
    return true;
  } catch (RaiseException re) {
    if (re.getException().getMetaClass().getBaseName().equals("SyntaxError")) {
      context.setErrorInfo($ex);
      config.getError().println("SyntaxError in " + re.getException().message(context));
      return false;
    }
    throw re;
  }
}

代码示例来源:origin: org.jruby/jruby-core

private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename) {
  final ThreadContext context = runtime.getCurrentContext();
  final IRubyObject $ex = context.getErrorInfo();
  try {
    runtime.parseFromMain(in, filename);
    config.getOutput().println("Syntax OK");
    return true;
  } catch (RaiseException re) {
    if (re.getException().getMetaClass().getBaseName().equals("SyntaxError")) {
      context.setErrorInfo($ex);
      config.getError().println("SyntaxError in " + re.getException().message(context));
      return false;
    }
    throw re;
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

Node scriptNode = parseFromMain(inputStream, filename);

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

Node scriptNode = parseFromMain(inputStream, filename);

代码示例来源:origin: org.jruby/jruby-complete

ParseResult parseResult = parseFromMain(filename, inputStream);

代码示例来源:origin: org.jruby/jruby-core

ParseResult parseResult = parseFromMain(filename, inputStream);

相关文章

微信公众号

最新文章

更多

Ruby类方法