~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/FortranProject/tokenizerf.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the FortranProject plugin for Code::Blocks IDE
 
3
 * and licensed under the GNU General Public License, version 3
 
4
 * http://www.gnu.org/licenses/gpl-3.0.html
 
5
 */
 
6
 
 
7
#ifndef FTOKINIZER_H
 
8
#define FTOKINIZER_H
 
9
 
 
10
#include <wx/string.h>
 
11
#include <filemanager.h>
 
12
#include <vector>
 
13
 
 
14
 
 
15
//bool cbRead(wxFile& file,wxString& st);
 
16
 
 
17
// Writes a wxString to a non-unicode file. File must be open. File is closed automatically.
 
18
//bool cbWrite(wxFile& file, const wxString& buff);
 
19
 
 
20
bool ReadFileToString(wxFile& file,wxString& st);
 
21
 
 
22
enum FortranSourceForm
 
23
{
 
24
    fsfFixed=0,
 
25
    fsfFree,
 
26
};
 
27
 
 
28
class Tokenizerf
 
29
{
 
30
        public:
 
31
                Tokenizerf(const wxString& filename = wxEmptyString, FortranSourceForm sourceForm = fsfFree);
 
32
                ~Tokenizerf();
 
33
 
 
34
                bool Init(const wxString& filename, FortranSourceForm sourceForm);
 
35
                bool InitFromBuffer(const wxString& buffer, FortranSourceForm sourceForm);
 
36
                wxString GetToken();
 
37
                wxString GetTokenSameLine();
 
38
                wxString GetTokenSameFortranLine();
 
39
                wxString PeekToken();
 
40
                wxString PeekTokenSameFortranLine();
 
41
                const wxString& GetFilename(){ return m_Filename; }
 
42
                unsigned int GetLineNumber(){ return m_LineNumber; }
 
43
                unsigned int GetPeekedLineNumber(){ return m_PeekedLineNumber; }
 
44
                unsigned int GetCurrentIndex(){ return m_TokenIndex; }
 
45
                unsigned int GetLineCount(){ return m_LineStartIdx.size(); }
 
46
                bool IsOK(){ return m_IsOK; }
 
47
                bool SkipToOneOfChars(const char* chars, bool toLineEnd = false);
 
48
                wxArrayString GetTokensToEOL(wxArrayString* arrStrLines = 0);
 
49
                wxArrayString PeekTokensToEOL();
 
50
                wxString GetCurrentLine();
 
51
                wxString GetLineFortran();
 
52
                wxString GetLine(unsigned int nl);
 
53
                unsigned int GetLineStartIndex(unsigned int indexInLine);
 
54
                unsigned int GetLineEndIndex(unsigned int indexInLine);
 
55
                void SetDetailedParsing(bool detPars);
 
56
                void SetFilename(const wxString& filename);
 
57
        void UngetToken();
 
58
                bool SkipToEOL();
 
59
        protected:
 
60
                void BaseInit();
 
61
                wxString DoGetToken();
 
62
                bool ReadFile();
 
63
                bool SkipWhiteSpace();
 
64
                bool SkipToChar(const wxChar& ch, bool toLineEnd = false);
 
65
                bool SkipBlock(const wxChar& ch, int maxLines = 0);
 
66
                bool SkipUnwanted(); // skips comments, assignments, preprocessor etc.
 
67
                bool IsEOF(){ return m_TokenIndex >= m_BufferLen; }
 
68
                bool MoveToNextChar();
 
69
                void AdjustLineNumber();
 
70
                wxChar CurrentChar();
 
71
                wxChar NextChar();
 
72
                wxChar PreviousChar();
 
73
                bool IsBindTo();
 
74
        private:
 
75
                bool CharInString(const char ch, const char* chars);
 
76
                wxString m_Filename;
 
77
                wxString m_Buffer;
 
78
                unsigned int m_BufferLen;
 
79
                unsigned int m_TokenIndex;
 
80
                unsigned int m_UndoTokenIndex;
 
81
                unsigned int m_PeekedTokenIndex;
 
82
                unsigned int m_LineNumber;
 
83
                unsigned int m_LineNumberStart;
 
84
                unsigned int m_UndoLineNumber;
 
85
                unsigned int m_UndoLineNumberStart;
 
86
                unsigned int m_PeekedLineNumber;
 
87
                unsigned int m_PeekedLineNumberStart;
 
88
                unsigned int m_Column;
 
89
                unsigned int m_UndoColumn;
 
90
                unsigned int m_PeekedColumn;
 
91
                bool m_WasNextLine;
 
92
                bool m_UndoWasNextLine;
 
93
                bool m_PeekedWasNextLine;
 
94
                bool m_WasPeeked;
 
95
                bool m_IsOK;
 
96
                FortranSourceForm m_SourceForm;
 
97
                wxString m_PeekedToken;
 
98
                bool m_DetailedParsing;
 
99
                std::vector<unsigned int> m_LineStartIdx;
 
100
};
 
101
 
 
102
#endif // FTOKINIZER_H