1 /*---------------------------------*- C++ -*---------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
27 An attributed Coco/R grammar to parse C/C++, Fortran and Java files
28 for include and import statements.
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:
40 #ifndef COCO_wmkdependPARSER_H__
41 #define COCO_wmkdependPARSER_H__
48 /*---------------------------------------------------------------------------*/
52 #include "wmkdependScanner.h"
57 /*---------------------------------------------------------------------------*\
58 Class Errors Declaration
59 \*---------------------------------------------------------------------------*/
60 //! Parser error handling
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
);
88 /*---------------------------------------------------------------------------*\
89 Class Parser Declaration
90 \*---------------------------------------------------------------------------*/
100 maxT
= 10 //<! max term (w/o pragmas)
102 static const int minErrDist
= 2; //!< min. distance before reporting errors
105 bool deleteErrorsDestruct_
; //!< delete the 'errors' member in destructor
108 void SynErr(int n
); //!< Handle syntax error 'n'
112 void ExpectWeak(int n
, int follow
);
113 bool WeakSeparator(int n
, int syFol
, int repFol
);
119 Token
*t
; //!< last recognized token
120 Token
*la
; //!< lookahead token
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
);
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
);
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);
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
174 #endif // COCO_wmkdependPARSER_H__
176 // ************************************************************************* //