~s-cecilio/lenmus/v5.1.x

« back to all changes in this revision

Viewing changes to src/ldp_parser/LDPToken.h

  • Committer: cecilios
  • Date: 2006-03-05 11:33:10 UTC
  • Revision ID: svn-v4:2587a929-2f0e-0410-ae78-fe6f687d5efe:trunk:2
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// RCS-ID: $Id: LDPToken.h,v 1.4 2006/03/01 19:19:31 cecilios Exp $
 
2
//--------------------------------------------------------------------------------------
 
3
//    LenMus Phonascus: The teacher of music
 
4
//    Copyright (c) 2002-2006 Cecilio Salmeron
 
5
//
 
6
//    This program is free software; you can redistribute it and/or modify it under the 
 
7
//    terms of the GNU General Public License as published by the Free Software Foundation;
 
8
//    either version 2 of the License, or (at your option) any later version.
 
9
//
 
10
//    This program is distributed in the hope that it will be useful, but WITHOUT ANY 
 
11
//    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 
12
//    PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
13
//
 
14
//    You should have received a copy of the GNU General Public License along with this 
 
15
//    program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 
 
16
//    Fifth Floor, Boston, MA  02110-1301, USA.
 
17
//
 
18
//    For any comment, suggestion or feature request, please contact the manager of 
 
19
//    the project at cecilios@users.sourceforge.net
 
20
//
 
21
//-------------------------------------------------------------------------------------
 
22
/*! @file LDPToken.h
 
23
    @brief Header file for class lmLDPToken
 
24
    @ingroup ldp_parser
 
25
*/
 
26
#ifdef __GNUG__
 
27
// #pragma interface
 
28
#endif
 
29
 
 
30
#ifndef __LMTOKEN_H        //to avoid nested includes
 
31
#define __LMTOKEN_H
 
32
 
 
33
 
 
34
class lmLDPParser;
 
35
 
 
36
 
 
37
enum ETokenType {
 
38
    tkStartOfElement = 0,
 
39
    tkEndOfElement,
 
40
    tkIntegerNumber,
 
41
    tkRealNumber,
 
42
    tkLabel,
 
43
    tkString,
 
44
    tkEndOfFile,
 
45
    //tokens for internal use
 
46
    tkSpaces,        //token separator
 
47
    tkComment        //to be filtered out in tokenizer routines
 
48
};
 
49
 
 
50
 
 
51
    
 
52
class lmLDPToken
 
53
{
 
54
public:
 
55
    lmLDPToken();
 
56
    ~lmLDPToken() {}
 
57
 
 
58
    ETokenType  GetType() { return m_Type; }
 
59
    wxString    GetValue() { return m_sValue; }
 
60
    wxString    GetDescription();
 
61
    void        Set(ETokenType nType, wxString sValue) {
 
62
                    m_Type = nType;
 
63
                    m_sValue = sValue;
 
64
                }
 
65
 
 
66
private:
 
67
    wxString    m_sValue;
 
68
    ETokenType  m_Type;
 
69
 
 
70
};
 
71
 
 
72
class lmLDPTokenBuilder
 
73
{
 
74
public:
 
75
    lmLDPTokenBuilder(lmLDPParser* pParser);
 
76
    ~lmLDPTokenBuilder() {}
 
77
 
 
78
    void RepeatToken() { m_fRepeatToken = true; }
 
79
    lmLDPToken* ReadToken();
 
80
 
 
81
 
 
82
private:
 
83
    void        GNC();
 
84
    void        GetNewBuffer();
 
85
    wxString    Extract(long iFrom, long iTo=0);
 
86
    bool        IsLetter(wxChar ch);
 
87
    bool        IsNumber(wxChar ch);
 
88
    void        ParseNewToken();
 
89
 
 
90
 
 
91
    lmLDPParser*    m_pParser;        //parser using this token builder
 
92
    lmLDPToken      m_token;
 
93
    bool            m_fRepeatToken;
 
94
    wxString        m_sInBuf;       // buffer being analised. It is different from the file
 
95
                                    // reading buffer so that we can insert / alter its content: i.e.
 
96
                                    // to expand macros, #define susbtitutions, etc. 
 
97
 
 
98
    long        m_lastPos;      // index of last character read by GNC() First char = 1. 
 
99
                                // Zero means "no char read yet"
 
100
    long        m_maxPos;       // buffer size - 1 = maximum value for m_lastPos
 
101
    wxChar      m_curChar;      // character being processed. It is read by GNC()
 
102
 
 
103
 
 
104
};
 
105
    
 
106
#endif    // __LMTOKEN_H
 
 
b'\\ No newline at end of file'