parserapi_scripting.js revision 1204:9597425b6b38
1106813Ssimokawa/*
2106813Ssimokawa * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3106813Ssimokawa * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4106813Ssimokawa *
5106813Ssimokawa * This code is free software; you can redistribute it and/or modify it
6106813Ssimokawa * under the terms of the GNU General Public License version 2 only, as
7106813Ssimokawa * published by the Free Software Foundation.
8106813Ssimokawa *
9106813Ssimokawa * This code is distributed in the hope that it will be useful, but WITHOUT
10106813Ssimokawa * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11106813Ssimokawa * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12106813Ssimokawa * version 2 for more details (a copy is included in the LICENSE file that
13106813Ssimokawa * accompanied this code).
14106813Ssimokawa *
15106813Ssimokawa * You should have received a copy of the GNU General Public License version
16106813Ssimokawa * 2 along with this work; if not, write to the Free Software Foundation,
17106813Ssimokawa * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18106813Ssimokawa *
19106813Ssimokawa * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20106813Ssimokawa * or visit www.oracle.com if you need additional information or have any
21106813Ssimokawa * questions.
22106813Ssimokawa */
23106813Ssimokawa
24106813Ssimokawa/**
25106813Ssimokawa * Nashorn parser API -scripting option test.
26106813Ssimokawa *
27106813Ssimokawa * @test
28106813Ssimokawa * @option -scripting
29106813Ssimokawa * @run
30106813Ssimokawa */
31106813Ssimokawa
32106813Ssimokawavar Parser = Java.type("jdk.nashorn.api.tree.Parser");
33106813Ssimokawavar scriptingParser = Parser.create("-scripting");
34106813Ssimokawavar parser = Parser.create();
35106813Ssimokawa
36106813Ssimokawavar backquote = "`ls`";
37106813SsimokawascriptingParser.parse("backquote.js", backquote, print);
38106813Ssimokawaparser.parse("backquote1.js", backquote, print);
39106813Ssimokawa
40106813Ssimokawavar heredoc = "var str = <<EOF\nprint('hello')\nEOF\n";
41106813SsimokawascriptingParser.parse("heredoc.js", heredoc, print);
42106813Ssimokawaparser.parse("heredoc1.js", heredoc, print);
43106813Ssimokawa
44106813Ssimokawavar hashComment = "#comment\nprint('hello')";
45106813SsimokawascriptingParser.parse("hashcomment.js", hashComment, print);
46106813Ssimokawaparser.parse("hashcomment1.js", hashComment, print);
47106813Ssimokawa
48106813Ssimokawa