42 token.
mType = VLTToken::TOKEN_ERROR;
47 return getRawtextBlock(token);
51 inline StringTurbo(std::string* str): mString(str)
58 mBuffer[mPosition] =
'\0';
62 inline void push_back(
const char& ch)
64 mBuffer[mPosition++] = ch;
67 inline void operator=(
const char& ch)
73 inline void operator=(
const char* s)
75 size_t len = strlen(s);
76 memcpy( mBuffer, s, len);
82 size_t len = strlen(str);
86 return memcmp(mBuffer, str, len) == 0;
98 if (!readTextChar(ch1))
100 token.
mType = VLTToken::TOKEN_EOF;
110 if(readTextChar(ch2))
115 for(ch1 = 0; readTextChar(ch1) && ch1 !=
'\n'; )
126 while(readTextChar(ch1))
128 if (ch1 ==
'*' && readTextChar(ch2) && ch2 ==
'/')
140 Log::error(
Say(
"Line %n : unexpected character '%c' after '/'.\n") << mLineNumber << ch2 );
146 Log::error(
Say(
"Line %n : unexpected end of file in comment.\n") << mLineNumber);
152 }
while(ch1 ==
' ' || ch1 ==
'\t' || ch1 ==
'\n');
157 token.
mType = VLTToken::LeftRoundBracket;
162 token.
mType = VLTToken::RightRoundBracket;
167 token.
mType = VLTToken::LeftSquareBracket;
172 token.
mType = VLTToken::RightSquareBracket;
177 if(readTextChar(ch2) && ch2 ==
'<')
181 while(ch2 !=
'\n' && readTextChar(ch2))
204 token.
mType = VLTToken::LeftFancyBracket;
206 mRawtextBlock =
true;
217 token.
mType = VLTToken::LeftCurlyBracket;
225 token.
mType = VLTToken::RightCurlyBracket;
230 if(readTextChar(ch2))
234 token.
mType = VLTToken::RightFancyBracket;
240 Log::error(
Say(
"Line %n : expected '}' instead of '%c' after '>'.\n") << mLineNumber << ch2 );
246 Log::error(
Say(
"Line %n : unexpected end of file.\n") << mLineNumber );
251 token.
mType = VLTToken::Equals;
257 while(readTextChar(ch1) && ch1 !=
'>')
259 if ( (ch1 >=
'a' && ch1 <=
'z') || (ch1 >=
'A' && ch1 <=
'Z') || (ch1 >=
'0' && ch1 <=
'9') || ch1 ==
'_' || ch1 ==
':' )
260 string_turbo.push_back(ch1);
263 Log::error(
Say(
"Line %n : unexpected character '%c'.\n") << mLineNumber << ch1 );
267 string_turbo.push_back(
'>');
270 Log::error(
Say(
"Line %n : unexpected end of file while reading object header.\n") << mLineNumber );
273 token.
mType = VLTToken::TagHeader;
278 while(readTextChar(ch1))
280 if ( (ch1 >=
'a' && ch1 <=
'z') || (ch1 >=
'A' && ch1 <=
'Z') || (ch1 >=
'0' && ch1 <=
'9') || ch1 ==
'_' )
281 string_turbo.push_back(ch1);
288 if (string_turbo ==
"#_")
290 Log::error(
Say(
"Line %n : illegal id '#_' found.\n") << mLineNumber );
293 token.
mType = VLTToken::ID;
297 while(readTextChar(ch1))
306 Log::error(
Say(
"Line %n : end of line found before end of string, did you forget a \"?.\n") << mLineNumber );
311 if (ch1 ==
'\\' && readTextChar(ch2))
335 string_turbo.push_back(ch1);
339 string_turbo.push_back(ch1);
343 Log::error(
Say(
"Line %n : end of file found before end of string, did you forget a \"?.\n") << mLineNumber );
348 token.
mType = VLTToken::String;
354 if ( (ch1 >=
'a' && ch1 <=
'z') || (ch1 >=
'A' && ch1 <=
'Z') || ch1 ==
'_' )
356 string_turbo.push_back(ch1);
357 while(readTextChar(ch1))
359 if ( (ch1 >=
'a' && ch1 <=
'z') || (ch1 >=
'A' && ch1 <=
'Z') || (ch1 >=
'0' && ch1 <=
'9') || ch1 ==
'_' )
360 string_turbo.push_back(ch1);
367 if (string_turbo ==
"_")
369 Log::error(
Say(
"Line %n : unexpected character '_'.\n") << mLineNumber );
375 if (string_turbo ==
"true" || string_turbo ==
"false")
376 token.
mType = VLTToken::Boolean;
378 token.
mType = VLTToken::Identifier;
399 if ( (ch1 >=
'0' && ch1 <=
'9') || ch1 ==
'.' || ch1 ==
'+' || ch1 ==
'-' )
401 token.
mType = VLTToken::TOKEN_ERROR;
402 string_turbo.push_back(ch1);
404 enum { sZERO, sPLUS_MINUS, sINT, sFRAC, sPOINT, sE, sPLUS_MINUS_EXP, sEXP } state = sINT;
406 if ( ch1 >=
'1' && ch1 <=
'9' )
415 if (ch1 ==
'+' || ch1 ==
'-')
418 while(readTextChar(ch1))
426 string_turbo.push_back(ch1);
431 token.
mType = VLTToken::Integer;
440 string_turbo.push_back(ch1);
444 if (ch1 >=
'1' && ch1 <=
'9')
446 string_turbo.push_back(ch1);
452 string_turbo.push_back(ch1);
457 Log::error(
Say(
"Line %n :unexpected character '%c'.\n") << mLineNumber << ch1 );
463 if (ch1 >=
'0' && ch1 <=
'9')
464 string_turbo.push_back(ch1);
468 string_turbo.push_back(ch1);
473 token.
mType = VLTToken::Integer;
480 if (ch1 >=
'0' && ch1 <=
'9')
482 string_turbo.push_back(ch1);
487 Log::error(
Say(
"Line %n :unexpected character '%c'.\n") << mLineNumber << ch1 );
493 if (ch1 >=
'0' && ch1 <=
'9')
494 string_turbo.push_back(ch1);
496 if (ch1 ==
'E' || ch1 ==
'e')
498 string_turbo.push_back(ch1);
503 token.
mType = VLTToken::real;
510 if (ch1 ==
'+' || ch1 ==
'-')
512 string_turbo.push_back(ch1);
513 state = sPLUS_MINUS_EXP;
517 Log::error(
Say(
"Line %n :unexpected character '%c'.\n") << mLineNumber << ch1 );
522 case sPLUS_MINUS_EXP:
523 if (ch1 >=
'0' && ch1 <=
'9')
525 string_turbo.push_back(ch1);
530 Log::error(
Say(
"Line %n :unexpected character '%c'.\n") << mLineNumber << ch1 );
536 if (ch1 >=
'0' && ch1 <=
'9')
537 string_turbo.push_back(ch1);
540 token.
mType = VLTToken::real;
550 token.
mType = VLTToken::Integer;
554 if (state == sFRAC || state == sEXP)
556 token.
mType = VLTToken::real;
564 Log::error(
Say(
"Line %n : unexpected character '%c'.\n") << mLineNumber << ch1 );
570 bool VLTTokenizer::getRawtextBlock(
VLTToken& token)
572 mRawtextBlock =
false;
574 token.
mType = VLTToken::TOKEN_ERROR;
578 while(readTextChar(ch))
587 if (readTextChar(ch2))
600 token.
mType = VLTToken::RawtextBlock;
A simple String formatting class.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
A token of information as defined by VLT specification.
Visualization Library main namespace.
bool operator==(const ref< T1 > &o1, const ref< T2 > &o2)