本文整理汇总了Java中jdk.nashorn.internal.runtime.ParserException.throwAsEcmaException方法的典型用法代码示例。如果您正苦于以下问题:Java ParserException.throwAsEcmaException方法的具体用法?Java ParserException.throwAsEcmaException怎么用?Java ParserException.throwAsEcmaException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ParserException
的用法示例。
在下文中一共展示了ParserException.throwAsEcmaException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFunctionParameters
import jdk.nashorn.internal.runtime.ParserException; //导入方法依赖的package包/类
private static void checkFunctionParameters(final String params) {
final Parser parser = getParser(params);
try {
parser.parseFormalParameterList();
} catch (final ParserException pe) {
pe.throwAsEcmaException();
}
}
示例2: checkFunctionBody
import jdk.nashorn.internal.runtime.ParserException; //导入方法依赖的package包/类
private static void checkFunctionBody(final String funcBody) {
final Parser parser = getParser(funcBody);
try {
parser.parseFunctionBody();
} catch (final ParserException pe) {
pe.throwAsEcmaException();
}
}
示例3: NativeRegExp
import jdk.nashorn.internal.runtime.ParserException; //导入方法依赖的package包/类
NativeRegExp(final String input, final String flagString, final Global global) {
this(global);
try {
this.regexp = RegExpFactory.create(input, flagString);
} catch (final ParserException e) {
// translate it as SyntaxError object and throw it
e.throwAsEcmaException();
throw new AssertionError(); //guard against null warnings below
}
this.setLastIndex(0);
}
示例4: parse
import jdk.nashorn.internal.runtime.ParserException; //导入方法依赖的package包/类
/**
* Returns AST as JSON compatible string.
*
* @param context context
* @param code code to be parsed
* @param name name of the code source (used for location)
* @param includeLoc tells whether to include location information for nodes or not
* @return JSON string representation of AST of the supplied code
*/
public static String parse(final Context context, final String code, final String name, final boolean includeLoc) {
final Parser parser = new Parser(context.getEnv(), sourceFor(name, code), new Context.ThrowErrorManager(), context.getEnv()._strict, context.getLogger(Parser.class));
final JSONWriter jsonWriter = new JSONWriter(includeLoc);
try {
final FunctionNode functionNode = parser.parse(); //symbol name is ":program", default
functionNode.accept(jsonWriter);
return jsonWriter.getString();
} catch (final ParserException e) {
e.throwAsEcmaException();
return null;
}
}
示例5: NativeRegExp
import jdk.nashorn.internal.runtime.ParserException; //导入方法依赖的package包/类
NativeRegExp(final String input, final String flagString, final Global global, final ScriptObject proto) {
super(proto, $nasgenmap$);
try {
this.regexp = RegExpFactory.create(input, flagString);
} catch (final ParserException e) {
// translate it as SyntaxError object and throw it
e.throwAsEcmaException();
throw new AssertionError(); //guard against null warnings below
}
this.globalObject = global;
this.setLastIndex(0);
}