ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / wmake / src / wmkdependParser.h
blob2285efaa104ef2f3e052ae51d88565ea58a740a0
1 /*---------------------------------*- C++ -*---------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
6 \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 for more details.
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 @file wmkdependParser.atg
26 Description
27 An attributed Coco/R grammar to parse C/C++, Fortran and Java files
28 for include and import statements.
30 SourceFiles
31 generated
33 \*---------------------------------------------------------------------------*/
34 // This file was generated with Coco/R C++ (10 Mar 2010)
35 // http://www.ssw.uni-linz.ac.at/coco/
36 // with these defines:
37 // - FORCE_UTF8
40 #ifndef COCO_wmkdependPARSER_H__
41 #define COCO_wmkdependPARSER_H__
43 #include <iostream>
44 #include <string>
45 #include <list>
46 #include <set>
48 /*---------------------------------------------------------------------------*/
52 #include "wmkdependScanner.h"
54 namespace wmake {
57 /*---------------------------------------------------------------------------*\
58 Class Errors Declaration
59 \*---------------------------------------------------------------------------*/
60 //! Parser error handling
61 class Errors
63 public:
64 int count; //!< The number of errors detected
66 //! Return a string describing the given error code.
67 static std::wstring strerror(int n);
69 Errors(); //!< Construct null - start with no errors
70 virtual ~Errors(); //!< Destructor
71 virtual void clear(); //!< Clear the error count
73 //! Handle a general warning 'msg'
74 virtual void Warning(const std::wstring& msg);
75 //! Handle a general warning 'msg'
76 virtual void Warning(int line, int col, const std::wstring& msg);
77 //! Handle general error 'msg' (eg, a semantic error)
78 virtual void Error(int line, int col, const std::wstring& msg);
79 //! Handle syntax error 'n', uses strerror for the message, calls Error()
80 virtual void SynErr(int line, int col, int n);
81 //! Handle a general exception 'msg'
82 virtual void Exception(const std::wstring& msg);
84 }; // Errors
88 /*---------------------------------------------------------------------------*\
89 Class Parser Declaration
90 \*---------------------------------------------------------------------------*/
91 //! A Coco/R Parser
92 class Parser
94 enum {
95 _EOF=0,
96 _string=1,
97 _sqstring=2,
98 _package_name=3,
99 _package_dir=4,
100 maxT = 10 //<! max term (w/o pragmas)
102 static const int minErrDist = 2; //!< min. distance before reporting errors
104 Token *dummyToken;
105 bool deleteErrorsDestruct_; //!< delete the 'errors' member in destructor
106 int errDist;
108 void SynErr(int n); //!< Handle syntax error 'n'
109 void Get();
110 void Expect(int n);
111 bool StartOf(int s);
112 void ExpectWeak(int n, int follow);
113 bool WeakSeparator(int n, int syFol, int repFol);
115 public:
116 Scanner *scanner;
117 Errors *errors;
119 Token *t; //!< last recognized token
120 Token *la; //!< lookahead token
122 private:
124 //! Set of (java) directories already visited
125 static std::set<std::string> visitedDirs_;
127 //! Replace all '.' with '/'
128 static void dotToSlash(std::string& name);
130 //! Import (java) directories
131 static void importDir(const std::string& dirName);
133 //! Import (java) file
134 static void importFile(const std::string& name);
136 public:
137 //! Set of files already visited
138 static std::set<std::string> visitedFiles;
140 //! Include directories to search
141 static std::list<std::string> includeDirs;
143 //! The name of the top-level source file
144 static std::string sourceFile;
146 //! The name of the top-level dep file
147 static std::string depFile;
149 //! Add directory to list of visited dirs, thus effectively ignoring it
150 static void ignoreDir(const std::string& name);
152 //! Include file
153 static void includeFile(const std::string& name);
155 /*---------------------------------------------------------------------------*/
157 //! Construct for the specified scanner
159 * Use the default error handling, or optionally provide an error
160 * handler, which will not be deleted upon destruction.
162 Parser(Scanner* scan, Errors* err = 0);
163 ~Parser();
164 void Parse(); //!< Execute the parse operation
165 void SemErr(const std::wstring& msg); //!< Handle semantic error
166 bool isUTF8() const; //!< Return true if scanner buffer is UTF8
168 void wmkdepend();
170 }; // end Parser
172 } // End namespace
174 #endif // COCO_wmkdependPARSER_H__
176 // ************************************************************************* //