zeoslib  UNKNOWN
 All Files
ZInterbaseToken.pas
Go to the documentation of this file.
1 {*********************************************************}
2 { }
3 { Zeos Database Objects }
4 { String tokenizing classes for Interbase }
5 { }
6 { Originally written by Sergey Seroukhov }
7 { }
8 {*********************************************************}
9 
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
12 { }
13 { License Agreement: }
14 { }
15 { This library is distributed in the hope that it will be }
16 { useful, but WITHOUT ANY WARRANTY; without even the }
17 { implied warranty of MERCHANTABILITY or FITNESS FOR }
18 { A PARTICULAR PURPOSE. See the GNU Lesser General }
19 { Public License for more details. }
20 { }
21 { The source code of the ZEOS Libraries and packages are }
22 { distributed under the Library GNU General Public }
23 { License (see the file COPYING / COPYING.ZEOS) }
24 { with the following modification: }
25 { As a special exception, the copyright holders of this }
26 { library give you permission to link this library with }
27 { independent modules to produce an executable, }
28 { regardless of the license terms of these independent }
29 { modules, and to copy and distribute the resulting }
30 { executable under terms of your choice, provided that }
31 { you also meet, for each linked independent module, }
32 { the terms and conditions of the license of that module. }
33 { An independent module is a module which is not derived }
34 { from or based on this library. If you modify this }
35 { library, you may extend this exception to your version }
36 { of the library, but you are not obligated to do so. }
37 { If you do not wish to do so, delete this exception }
38 { statement from your version. }
39 { }
40 { }
41 { The project web site is located on: }
42 { http://zeos.firmos.at (FORUM) }
43 { http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
44 { svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
45 { }
46 { http://www.sourceforge.net/projects/zeoslib. }
47 { }
48 { }
49 { Zeos Development Group. }
50 {********************************************************@}
51 
52 unit ZInterbaseToken;
53 
54 interface
55 
56 {$I ZParseSql.inc}
57 
58 uses
59  Classes, ZTokenizer, ZGenericSqlToken, ZPostgreSqlToken;
60 
61 type
62 
63  {** Implements a Interbase-specific number state object. }
64  TZInterbaseNumberState = class (TZPostgreSQLNumberState)
65  end;
66 
67  {** Implements a Interbase-specific quote string state object. }
68  TZInterbaseQuoteState = class (TZGenericSQLQuoteState)
69  end;
70 
71  {**
72  This state will either delegate to a comment-handling
73  state, or return a token with just a slash in it.
74  }
75  TZInterbaseCommentState = class (TZCCommentState)
76  end;
77 
78  {** Implements a symbol state object. }
79  TZInterbaseSymbolState = class (TZSymbolState)
80  public
81  constructor Create;
82  end;
83 
84  {** Implements a word state object. }
85  TZInterbaseWordState = class (TZGenericSQLWordState)
86  public
87  constructor Create;
88  end;
89 
90  {** Implements a default tokenizer object. }
91  TZInterbaseTokenizer = class (TZTokenizer)
92  public
93  constructor Create;
94  end;
95 
96 implementation
97 
98 { TZInterbaseSymbolState }
99 
100 {**
101  Creates this Interbase-specific symbol state object.
102 }
103 constructor TZInterbaseSymbolState.Create;
104 begin
105  inherited Create;
106  Add('<=');
107  Add('>=');
108  Add('<>');
109  Add('!=');
110  Add('!<');
111  Add('!>');
112 end;
113 
114 { TZInterbaseWordState }
115 
116 {**
117  Constructs this Interbase-specific word state object.
118 }
119 constructor TZInterbaseWordState.Create;
120 begin
121  SetWordChars(#0, #255, False);
122  SetWordChars('a', 'z', True);
123  SetWordChars('A', 'Z', True);
124  SetWordChars('0', '9', True);
125  SetWordChars('_', '_', True);
126  SetWordChars('$', '$', True);
127 end;
128 
129 { TZInterbaseTokenizer }
130 
131 { TZInterbaseTokenizer }
132 
133 constructor TZInterbaseTokenizer.Create;
134 begin
135  EscapeState := TZEscapeState.Create;
136  WhitespaceState := TZWhitespaceState.Create;
137 
138  SymbolState := TZInterbaseSymbolState.Create;
139  NumberState := TZInterbaseNumberState.Create;
140  QuoteState := TZInterbaseQuoteState.Create;
141  WordState := TZInterbaseWordState.Create;
142  CommentState := TZInterbaseCommentState.Create;
143 
144  SetCharacterState(#0, #32, WhitespaceState);
145  SetCharacterState(#33, #191, SymbolState);
146  SetCharacterState(#192, High(Char), WordState);
147 
148  SetCharacterState('a', 'z', WordState);
149  SetCharacterState('A', 'Z', WordState);
150  SetCharacterState('_', '_', WordState);
151  SetCharacterState('$', '$', WordState);
152 
153  SetCharacterState('0', '9', NumberState);
154  SetCharacterState('.', '.', NumberState);
155 
156  SetCharacterState('"', '"', QuoteState);
157  SetCharacterState(#39, #39, QuoteState);
158 
159  SetCharacterState('/', '/', CommentState);
160 end;
161 
162 end.
163