01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang;
05
06 import java.io.Reader;
07 import java.util.Map;
08
09 import net.sourceforge.pmd.lang.ast.Node;
10 import net.sourceforge.pmd.lang.java.ast.ParseException;
11
12 /**
13 * Common interface for calling tree-building parsers or source files.
14 *
15 * @author Pieter_Van_Raemdonck - Application Engineers NV/SA - www.ae.be
16 */
17 public interface Parser {
18 /**
19 * Get a TokenManager for the given source.
20 * @param fileName The file name being parsed (may be <code>null</code>).
21 * @param source Reader that provides the source code to tokenize.
22 * @return A TokenManager for reading token.
23 */
24 TokenManager getTokenManager(String fileName, Reader source);
25
26 /**
27 * Indicates if this parser can actual parse, or if it can only tokenize.
28 */
29 boolean canParse();
30
31 /**
32 * Parse source code and return the root node of the AST.
33 *
34 * @param fileName The file name being parsed (may be <code>null</code>).
35 * @param source Reader that provides the source code of a compilation unit
36 * @return the root node of the AST that is built from the source code
37 * @throws ParseException In case the source code could not be parsed, probably
38 * due to syntactical errors.
39 */
40 Node parse(String fileName, Reader source) throws ParseException;
41
42 // TODO Document
43 Map<Integer, String> getSuppressMap();
44
45 // TODO Document
46 String getSuppressMarker();
47
48 // TODO Document
49 void setSuppressMarker(String marker);
50 }
|