1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * anjuta
4  * Copyright (C) Eran Ifrah (Main file for CodeLite www.codelite.org/ )
5  * Copyright (C) Massimo Cora' 2009 <maxcvs@email.it> (Customizations for Anjuta)
6  *
7  * anjuta is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * anjuta is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 //////////////////////////////////////////////////////////////////////////////
22 //////////////////////////////////////////////////////////////////////////////
23 //
24 // copyright            : (C) 2008 by Eran Ifrah
25 // file name            : cpp_scanner.h
26 //
27 // -------------------------------------------------------------------------
28 // A
29 //              _____           _      _     _ _
30 //             /  __ \         | |    | |   (_) |
31 //             | /  \/ ___   __| | ___| |    _| |_ ___
32 //             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
33 //             | \__/\ (_) | (_| |  __/ |___| | ||  __/
34 //              \____/\___/ \__,_|\___\_____/_|\__\___|
35 //
36 //                                                  F i l e
37 //
38 //    This program is free software; you can redistribute it and/or modify
39 //    it under the terms of the GNU General Public License as published by
40 //    the Free Software Foundation; either version 2 of the License, or
41 //    (at your option) any later version.
42 //
43 //////////////////////////////////////////////////////////////////////////////
44 //////////////////////////////////////////////////////////////////////////////
45 #ifndef _CPPTOKENIZER_H_
46 #define _CPPTOKENIZER_H_
47 
48 #include "flex-lexer-klass.h"
49 
50 class CppTokenizer : public flex::yyFlexLexer
51 {
52 public:
53 	CppTokenizer();
54 	~CppTokenizer(void);
55 
56 	/* Override the LexerInput function */
57 	int LexerInput(char *buf, int max_size);
58 	void setText(const char* data);
59 	void reset();
60 
61 
62 	/*	Note about comment and line number:
63 	 *	If the last text consumed is a comment, the line number
64 	 *	returned is the line number of the last line of the comment
65 	 *	incase the comment spans over number of lines
66 	 */
67 	const int& lineNo() const;
68 	inline void clearComment();
69 	inline const char* getComment() const;
70 	inline void keepComment(const int& keep);
71 	inline void returnWhite(const int& rw);
72 
73 private:
74 	char *m_data;
75 	char *m_pcurr;
76 	int   m_total;
77 	int   m_curr;
78 };
79 
80 #endif // _CPPTOKENIZER_H_
81