View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.cpp;
5   
6   import java.io.Reader;
7   import java.util.Map;
8   
9   import net.sourceforge.pmd.lang.AbstractParser;
10  import net.sourceforge.pmd.lang.ParserOptions;
11  import net.sourceforge.pmd.lang.TokenManager;
12  import net.sourceforge.pmd.lang.ast.AbstractTokenManager;
13  import net.sourceforge.pmd.lang.ast.Node;
14  import net.sourceforge.pmd.lang.ast.ParseException;
15  
16  /**
17   * Adapter for the C++ Parser.
18   */
19  public class CppParser extends AbstractParser {
20  
21      /**
22       * Creates a new C++ Parser.
23       * @param parserOptions the options
24       */
25      public CppParser(ParserOptions parserOptions) {
26          super(parserOptions);
27      }
28  
29      @Override
30      public TokenManager createTokenManager(Reader source) {
31          return new CppTokenManager(source);
32      }
33  
34      @Override
35      public boolean canParse() {
36          return false;
37      }
38  
39      @Override
40      public Node parse(String fileName, Reader source) throws ParseException {
41          AbstractTokenManager.setFileName(fileName);
42          throw new UnsupportedOperationException("parse(Reader) is not supported for C++");
43      }
44  
45      @Override
46      public Map<Integer, String> getSuppressMap() {
47          throw new UnsupportedOperationException("getSuppressMap() is not supported for C++");
48      }
49  }