1 /*
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /**
27 * <p>
28 * Nashorn parser API provides interfaces to represent ECMAScript source code
29 * as abstract syntax trees (AST) and Parser to parse ECMAScript source scripts.
30 * </p>
31 * <p>
32 * Using parser API user can write Java code to access parse tree
33 * representation of ECMAScript source. Script source may be a file,
34 * a URL or a String. Unless stated otherwise null argument in methods of this
35 * package result in NullPointerException being thrown.
36 * </p>
37 *
38 * <pre>
39 * <code>
40 * import jdk.nashorn.api.tree.*;
41 * import java.io.File;
42 *
43 * // Simple example that prints warning on 'with' statements
44 * public class Main {
45 * public static void main(String[] args) throws Exception {
46 * // Create a new parser instance
47 * Parser parser = Parser.create();
48 * File sourceFile = new File(args[0]);
49 *
50 * // Parse given source File using parse method.
51 * // Pass a diagnostic listener to print error messages.
52 * CompilationUnitTree cut = parser.parse(sourceFile,
53 * (d) -> { System.out.println(d); });
54 *
55 * if (cut != null) {
56 * // call Tree.accept method passing a SimpleTreeVisitor
57 * cut.accept(new SimpleTreeVisitor<Void, Void>() {
58 * // visit method for 'with' statement
59 * public Void visitWith(WithTree wt, Void v) {
60 * // print warning on 'with' statement
61 * System.out.println("Warning: using 'with' statement!");
62 * return null;
63 * }
64 * }, null);
65 * }
66 * }
67 * }
68 * </code>
69 * </pre>
70 *
71 * @since 1.9
72 */
73 @jdk.Exported
74 package jdk.nashorn.api.tree;
75
--- EOF ---