-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tokenizer.h
70 lines (63 loc) · 2.97 KB
/
Tokenizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//---------------------------------------------------------------------------
#ifndef TokenizerH
#define TokenizerH
//---------------------------------------------------------------------------
#include <stdlib.h>
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
typedef void __fastcall (__closure *TTokenNotifyEvent)(System::TObject* Sender, AnsiString *Token);
//---------------------------------------------------------------------------
class PACKAGE TTokenizer : public TComponent
{
private:
TTokenNotifyEvent FOnGotToken;
AnsiString *FWhitespace;
AnsiString *FDelimiters;
AnsiString *FStrDelims;
AnsiString *FTrimChars;
AnsiString *FText;
TStringList *FTokens;
int FTokenCount;
bool EndOfList;
int CurrToken;
bool __fastcall IsDelimiter(AnsiString s);
bool __fastcall IsWhitespace(AnsiString s);
bool __fastcall IsStringDelimiter(AnsiString s);
void __fastcall ParseText();
void __fastcall AddFToken(AnsiString *s);
protected:
virtual AnsiString __fastcall GetWhitespace();
virtual void __fastcall SetWhitespace(AnsiString ws);
virtual AnsiString __fastcall GetDelimiters();
virtual void __fastcall SetDelimiters(AnsiString d);
virtual AnsiString __fastcall GetStringDelimiters();
virtual void __fastcall SetStringDelimiters(AnsiString d);
virtual AnsiString __fastcall GetText();
virtual void __fastcall SetText(AnsiString t);
virtual AnsiString __fastcall GetTrimCharacters();
virtual void __fastcall SetTrimCharacters(AnsiString tc);
public:
__fastcall TTokenizer(TComponent* Owner);
__fastcall ~TTokenizer();
virtual void __fastcall GetTokens(TStringList *sl);
virtual AnsiString __fastcall GetToken(int Num);
virtual AnsiString __fastcall GetFirstToken();
virtual AnsiString __fastcall GetNextToken();
bool __fastcall TokenIsNumeric(int i);
bool __fastcall TokenIsAlphabetic(int i);
bool __fastcall TokenIsAlphanum(int i);
bool __fastcall EndOfTokens();
__published:
__property AnsiString Whitespace = {read=GetWhitespace, write=SetWhitespace, nodefault};
__property AnsiString Delimiters = {read=GetDelimiters, write=SetDelimiters, nodefault};
__property AnsiString StringDelimiters = {read=GetStringDelimiters, write=SetStringDelimiters, nodefault};
__property AnsiString TrimCharacters = {read=GetTrimCharacters, write=SetTrimCharacters, nodefault};
__property AnsiString Text = {read=GetText, write=SetText, nodefault};
__property int TokenCount = {read=FTokenCount, nodefault};
__property TTokenNotifyEvent OnGotToken = {read=FOnGotToken, write=FOnGotToken, nodefault};
};
//---------------------------------------------------------------------------
#endif