26 secondCharAtEndOfFile (
false),
29 weOwnTokenBuffer (
false)
40 secondCharAtEndOfFile (
false),
43 weOwnTokenBuffer (
false)
46 weOwnTokenBuffer =
true;
58 secondCharAtEndOfFile (
false),
61 weOwnTokenBuffer (
false)
67 weOwnTokenBuffer =
true;
101 while (tokenList.QueueSize () < tokenListLen)
103 ReadInNextLogicalToken ();
111 delete operatorChars ;
118 while (tokenList.QueueSize () < 1)
119 ReadInNextLogicalToken ();
121 KKStrPtr t = tokenList.PopFromFront ();
140 while ((t != NULL) && (*t
!= delToken))
142 tokens->PushOnBack (t);
147 tokens->PushOnBack (t);
156 tokenList.PushOnFront (t);
164 while ((tokenList.QueueSize () < (kkint32)(idx + 1)) && !atEndOfFile)
165 ReadInNextLogicalToken ();
167 if (idx >= tokenList.size ())
170 return tokenList.IdxToPtr ((kkint32)idx);
179 while ((tokenList.QueueSize () < 1) && (!atEndOfFile))
180 ReadInNextLogicalToken ();
182 return (tokenList.QueueSize () < 1);
195 else if (secondCharAtEndOfFile)
204 firstChar = secondChar;
208 secondCharAtEndOfFile =
true;
222 void Tokenizer::ReadInNextLogicalToken ()
224 KKStrPtr t = GetNextTokenRaw ();
231 tokenList.PushOnBack (t);
237 bool Tokenizer::WhiteSpaceChar (
char c)
const 239 if (strchr (
" ", c) == NULL)
248 bool Tokenizer::DelimiterChar (
char c)
const 250 return (strchr (
"\n\r\t", c) != NULL);
254 bool Tokenizer::OperatorChar (
char c)
const 256 return (strchr (operatorChars, c) != NULL);
267 while ((firstChar ==
' ') && (!atEndOfFile))
270 if (firstChar ==
'\n')
272 if (secondChar ==
'\r')
275 else if (firstChar ==
'\r')
277 if (secondChar ==
'\n')
286 KKStrPtr nextRawToken = NULL;
288 if ((firstChar ==
'"') || (firstChar ==
'\''))
291 nextRawToken = ProcessStringToken (firstChar);
294 else if (OperatorChar (firstChar))
296 nextRawToken = ProcessOperatorToken ();
301 nextRawToken = ProcessFieldToken ();
312 KKStrPtr
Tokenizer::ProcessStringToken (
char strDelChar)
314 if (firstChar == strDelChar)
322 if (firstChar == strDelChar)
329 else if (firstChar ==
'\\')
358 KKStrPtr
Tokenizer::ProcessOperatorToken ()
360 KKStrPtr field =
new KKStr (3
);
363 if ((firstChar ==
'+') && (secondChar ==
'+'))
369 else if ((firstChar ==
'-') && (secondChar ==
'-'))
375 else if (firstChar ==
'=')
377 if (strchr (
"=<>+-*/^", secondChar) != NULL)
379 field->Append (secondChar);
384 else if (strchr (
"+-*/^<>", firstChar) != NULL)
386 if (secondChar ==
'=')
388 field->Append (secondChar);
403 KKStrPtr field =
new KKStr (10
);
404 while ((!WhiteSpaceChar (firstChar)) &&
405 (!DelimiterChar (firstChar)) &&
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for 'size' characters.
char * STRDUP(const char *src)
TokenBufferStr(const KKStr &_buff)
TokenBufferStream(const KKStr &_fileName)
KKStrConstPtr operator[](kkuint32 idx)
unsigned __int32 kkuint32
Tokenizer(const KKStr &_fileName, bool &_fileOpened)
virtual bool EndOfFile()=0
KKStr(const KKStr &str)
Copy Constructor.
void PushTokenOnFront(KKStrPtr t)
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
KKStrConstPtr Peek(kkuint32 idx)
Tokenizer(TokenBufferPtr _in)
bool operator!=(const KKStr &right) const
TokenBuffer * TokenBufferPtr
Class is meant to break down a stream into a set of logical tokens.
Tokenizer(const KKStr &_str)
KKStrListPtr GetNextTokens(const KKStr &delToken)
Returns a list of tokens up to and including the first occurrence of 'delToken'.
void DefineOperatorChars(char *const _operatorChars)
virtual char GetNextChar()=0