zeoslib  UNKNOWN
 All Files
ZOracleToken.pas
Go to the documentation of this file.
1 {*********************************************************}
2 { }
3 { Zeos Database Objects }
4 { String tokenizing classes for Oracle }
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 ZOracleToken;
53 
54 interface
55 
56 {$I ZParseSql.inc}
57 
58 uses
59  Classes, ZTokenizer, ZGenericSqlToken, ZPostgreSqlToken,
60  ZSybaseToken;
61 
62 type
63 
64  {** Implements a Oracle-specific number state object. }
65  TZOracleNumberState = class (TZPostgreSQLNumberState)
66  end;
67 
68  {** Implements a Oracle-specific quote string state object. }
69  TZOracleQuoteState = class (TZGenericSQLQuoteState)
70  end;
71 
72  {**
73  This state will either delegate to a comment-handling
74  state, or return a token with just a slash in it.
75  }
76  TZOracleCommentState = class (TZSybaseCommentState)
77  end;
78 
79  {** Implements a symbol state object. }
80  TZOracleSymbolState = class (TZSymbolState)
81  public
82  constructor Create;
83  end;
84 
85  {** Implements a word state object. }
86  TZOracleWordState = class (TZGenericSQLWordState)
87  public
88  constructor Create;
89  end;
90 
91  {** Implements a default tokenizer object. }
92  TZOracleTokenizer = class (TZTokenizer)
93  public
94  constructor Create;
95  end;
96 
97 implementation
98 
99 { TZOracleSymbolState }
100 
101 {**
102  Creates this Oracle-specific symbol state object.
103 }
104 constructor TZOracleSymbolState.Create;
105 begin
106  inherited Create;
107  Add('<=');
108  Add('>=');
109  Add('<>');
110  Add('!=');
111  Add('||');
112 end;
113 
114 { TZOracleWordState }
115 
116 {**
117  Constructs this Oracle-specific word state object.
118 }
119 constructor TZOracleWordState.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  SetWordChars('#', '#', True);
128  SetWordChars('@', '@', True);
129 end;
130 
131 { TZOracleTokenizer }
132 
133 {**
134  Constructs a tokenizer with a default state table (as
135  described in the class comment).
136 }
137 constructor TZOracleTokenizer.Create;
138 begin
139  EscapeState := TZEscapeState.Create;
140  WhitespaceState := TZWhitespaceState.Create;
141 
142  SymbolState := TZOracleSymbolState.Create;
143  NumberState := TZOracleNumberState.Create;
144  QuoteState := TZOracleQuoteState.Create;
145  WordState := TZOracleWordState.Create;
146  CommentState := TZOracleCommentState.Create;
147 
148  SetCharacterState(#0, #32, WhitespaceState);
149  SetCharacterState(#33, #191, SymbolState);
150  SetCharacterState(#192, High(Char), WordState);
151 
152  SetCharacterState('a', 'z', WordState);
153  SetCharacterState('A', 'Z', WordState);
154  SetCharacterState('_', '_', WordState);
155  SetCharacterState('$', '$', WordState);
156  SetCharacterState('#', '#', WordState);
157 
158  SetCharacterState('0', '9', NumberState);
159  SetCharacterState('.', '.', NumberState);
160 
161  SetCharacterState('"', '"', QuoteState);
162  SetCharacterState(#39, #39, QuoteState);
163 
164  SetCharacterState('/', '/', CommentState);
165  SetCharacterState('-', '-', CommentState);
166 end;
167 
168 end.
169