00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { String tokenizing classes for Interbase }
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 ZInterbaseToken;
00055
00056 interface
00057
00058 {$I ZParseSql.inc}
00059
00060 uses
00061 Classes, ZTokenizer, ZGenericSqlToken, ZPostgreSqlToken;
00062
00063 type
00064
00065 {** Implements a Interbase-specific number state object. }
00066 TZInterbaseNumberState = class (TZPostgreSQLNumberState)
00067 end;
00068
00069 {** Implements a Interbase-specific quote string state object. }
00070 TZInterbaseQuoteState = class (TZGenericSQLQuoteState)
00071 end;
00072
00073 {**
00074 This state will either delegate to a comment-handling
00075 state, or return a token with just a slash in it.
00076 }
00077 TZInterbaseCommentState = class (TZCCommentState)
00078 end;
00079
00080 {** Implements a symbol state object. }
00081 TZInterbaseSymbolState = class (TZSymbolState)
00082 public
00083 constructor Create;
00084 end;
00085
00086 {** Implements a word state object. }
00087 TZInterbaseWordState = class (TZGenericSQLWordState)
00088 public
00089 constructor Create;
00090 end;
00091
00092 {** Implements a default tokenizer object. }
00093 TZInterbaseTokenizer = class (TZTokenizer)
00094 public
00095 constructor Create;
00096 end;
00097
00098 implementation
00099
00100 { TZInterbaseSymbolState }
00101
00102 {**
00103 Creates this Interbase-specific symbol state object.
00104 }
00105 constructor TZInterbaseSymbolState.Create;
00106 begin
00107 inherited Create;
00108 Add('<=');
00109 Add('>=');
00110 Add('<>');
00111 Add('!=');
00112 Add('!<');
00113 Add('!>');
00114 end;
00115
00116 { TZInterbaseWordState }
00117
00118 {**
00119 Constructs this Interbase-specific word state object.
00120 }
00121 constructor TZInterbaseWordState.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 end;
00130
00131 { TZInterbaseTokenizer }
00132
00133 {**
00134 Constructs a tokenizer with a default state table (as
00135 described in the class comment).
00136 }
00137 constructor TZInterbaseTokenizer.Create;
00138 begin
00139 WhitespaceState := TZWhitespaceState.Create;
00140
00141 SymbolState := TZInterbaseSymbolState.Create;
00142 NumberState := TZInterbaseNumberState.Create;
00143 QuoteState := TZInterbaseQuoteState.Create;
00144 WordState := TZInterbaseWordState.Create;
00145 CommentState := TZInterbaseCommentState.Create;
00146
00147 SetCharacterState(#0, #255, SymbolState);
00148 SetCharacterState(#0, ' ', WhitespaceState);
00149
00150 SetCharacterState('a', 'z', WordState);
00151 SetCharacterState('A', 'Z', WordState);
00152 SetCharacterState('_', '_', WordState);
00153 SetCharacterState('$', '$', WordState);
00154
00155 SetCharacterState('0', '9', NumberState);
00156 SetCharacterState('.', '.', NumberState);
00157
00158 SetCharacterState('"', '"', QuoteState);
00159 SetCharacterState(#39, #39, QuoteState);
00160
00161 SetCharacterState('/', '/', CommentState);
00162 end;
00163
00164 end.
00165