00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { String tokenizing classes for Oracle }
00005 { }
00006 { Originally written by Sergey Seroukhov }
00007 { }
00008 {*********************************************************}
00009
00010 {@********************************************************}
00011 { Copyright (c) 1999-2006 Zeos Development Group }
00012 { }
00013 { License Agreement: }
00014 { }
00015 { This library is distributed in the hope that it will be }
00016 { useful, but WITHOUT ANY WARRANTY; without even the }
00017 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00018 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00019 { Public License for more details. }
00020 { }
00021 { The source code of the ZEOS Libraries and packages are }
00022 { distributed under the Library GNU General Public }
00023 { License (see the file COPYING / COPYING.ZEOS) }
00024 { with the following modification: }
00025 { As a special exception, the copyright holders of this }
00026 { library give you permission to link this library with }
00027 { independent modules to produce an executable, }
00028 { regardless of the license terms of these independent }
00029 { modules, and to copy and distribute the resulting }
00030 { executable under terms of your choice, provided that }
00031 { you also meet, for each linked independent module, }
00032 { the terms and conditions of the license of that module. }
00033 { An independent module is a module which is not derived }
00034 { from or based on this library. If you modify this }
00035 { library, you may extend this exception to your version }
00036 { of the library, but you are not obligated to do so. }
00037 { If you do not wish to do so, delete this exception }
00038 { statement from your version. }
00039 { }
00040 { }
00041 { The project web site is located on: }
00042 { http:
00043 { http:
00044 { svn:
00045 { }
00046 { http:
00047 { http:
00048 { }
00049 { }
00050 { }
00051 { Zeos Development Group. }
00052 {********************************************************@}
00053
00054 unit ZOracleToken;
00055
00056 interface
00057
00058 {$I ZParseSql.inc}
00059
00060 uses
00061 Classes, ZTokenizer, ZGenericSqlToken, ZPostgreSqlToken,
00062 ZSybaseToken;
00063
00064 type
00065
00066 {** Implements a Oracle-specific number state object. }
00067 TZOracleNumberState = class (TZPostgreSQLNumberState)
00068 end;
00069
00070 {** Implements a Oracle-specific quote string state object. }
00071 TZOracleQuoteState = class (TZGenericSQLQuoteState)
00072 end;
00073
00074 {**
00075 This state will either delegate to a comment-handling
00076 state, or return a token with just a slash in it.
00077 }
00078 TZOracleCommentState = class (TZSybaseCommentState)
00079 end;
00080
00081 {** Implements a symbol state object. }
00082 TZOracleSymbolState = class (TZSymbolState)
00083 public
00084 constructor Create;
00085 end;
00086
00087 {** Implements a word state object. }
00088 TZOracleWordState = class (TZGenericSQLWordState)
00089 public
00090 constructor Create;
00091 end;
00092
00093 {** Implements a default tokenizer object. }
00094 TZOracleTokenizer = class (TZTokenizer)
00095 public
00096 constructor Create;
00097 end;
00098
00099 implementation
00100
00101 { TZOracleSymbolState }
00102
00103 {**
00104 Creates this Oracle-specific symbol state object.
00105 }
00106 constructor TZOracleSymbolState.Create;
00107 begin
00108 inherited Create;
00109 Add('<=');
00110 Add('>=');
00111 Add('<>');
00112 Add('!=');
00113 Add('||');
00114 end;
00115
00116 { TZOracleWordState }
00117
00118 {**
00119 Constructs this Oracle-specific word state object.
00120 }
00121 constructor TZOracleWordState.Create;
00122 begin
00123 SetWordChars(#0, #255, False);
00124 SetWordChars('a', 'z', True);
00125 SetWordChars('A', 'Z', True);
00126 SetWordChars('0', '9', True);
00127 SetWordChars('_', '_', True);
00128 SetWordChars('$', '$', True);
00129 SetWordChars('#', '#', True);
00130 SetWordChars('@', '@', True);
00131 end;
00132
00133 { TZOracleTokenizer }
00134
00135 {**
00136 Constructs a tokenizer with a default state table (as
00137 described in the class comment).
00138 }
00139 constructor TZOracleTokenizer.Create;
00140 begin
00141 WhitespaceState := TZWhitespaceState.Create;
00142
00143 SymbolState := TZOracleSymbolState.Create;
00144 NumberState := TZOracleNumberState.Create;
00145 QuoteState := TZOracleQuoteState.Create;
00146 WordState := TZOracleWordState.Create;
00147 CommentState := TZOracleCommentState.Create;
00148
00149 SetCharacterState(#0, #255, SymbolState);
00150 SetCharacterState(#0, ' ', WhitespaceState);
00151
00152 SetCharacterState('a', 'z', WordState);
00153 SetCharacterState('A', 'Z', WordState);
00154 SetCharacterState('_', '_', WordState);
00155 SetCharacterState('$', '$', WordState);
00156 SetCharacterState('#', '#', WordState);
00157
00158 SetCharacterState('0', '9', NumberState);
00159 SetCharacterState('.', '.', NumberState);
00160
00161 SetCharacterState('"', '"', QuoteState);
00162 SetCharacterState(#39, #39, QuoteState);
00163
00164 SetCharacterState('/', '/', CommentState);
00165 SetCharacterState('-', '-', CommentState);
00166 end;
00167
00168 end.
00169