Java Code Examples for jdk.nashorn.internal.runtime.ParserException#throwAsEcmaException()
The following examples show how to use
jdk.nashorn.internal.runtime.ParserException#throwAsEcmaException() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeRegExp.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); }
Example 2
Source File: JSONWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 3
Source File: NativeRegExp.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example 4
Source File: NativeFunction.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionBody(final String funcBody) { final Parser parser = getParser(funcBody); try { parser.parseFunctionBody(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 5
Source File: NativeFunction.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionParameters(final String params) { final Parser parser = getParser(params); try { parser.parseFormalParameterList(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 6
Source File: JSONWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 7
Source File: NativeRegExp.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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); }
Example 8
Source File: NativeFunction.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionBody(final String funcBody) { final Parser parser = getParser(funcBody); try { parser.parseFunctionBody(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 9
Source File: NativeFunction.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionParameters(final String params) { final Parser parser = getParser(params); try { parser.parseFormalParameterList(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 10
Source File: JSONWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 11
Source File: NativeFunction.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionParameters(final String params) { final Parser parser = getParser(params); try { parser.parseFormalParameterList(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 12
Source File: NativeFunction.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionBody(final String funcBody) { final Parser parser = getParser(funcBody); try { parser.parseFunctionBody(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 13
Source File: NativeFunction.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionParameters(final String params) { final Parser parser = getParser(params); try { parser.parseFormalParameterList(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 14
Source File: JSONWriter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 15
Source File: NativeRegExp.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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); }
Example 16
Source File: NativeFunction.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionBody(final String funcBody) { final Parser parser = getParser(funcBody); try { parser.parseFunctionBody(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 17
Source File: NativeFunction.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionParameters(final String params) { final Parser parser = getParser(params); try { parser.parseFormalParameterList(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }
Example 18
Source File: JSONWriter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 19
Source File: NativeRegExp.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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); }
Example 20
Source File: NativeFunction.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void checkFunctionBody(final String funcBody) { final Parser parser = getParser(funcBody); try { parser.parseFunctionBody(); } catch (final ParserException pe) { pe.throwAsEcmaException(); } }