| 324 | } |
| 325 | |
| 326 | PType |
| 327 | getToken (const char*& str, std::string& ostr, int& num_linefeeds, |
| 328 | bool& newline_from_comment, ParmParse::QuoteType& quote_type) |
| 329 | { |
| 330 | // |
| 331 | // Eat white space and comments. |
| 332 | // |
| 333 | num_linefeeds = eat_garbage(str, &newline_from_comment); |
| 334 | quote_type = ParmParse::QuoteType::None; |
| 335 | // |
| 336 | // Check for end of file. |
| 337 | // |
| 338 | if ( *str == 0 ) |
| 339 | { |
| 340 | return PType::pEOF; |
| 341 | } |
| 342 | // |
| 343 | // Start token scan. |
| 344 | // |
| 345 | lexState state = lexState::START; |
| 346 | int pcnt = 0; // Tracks nested parens |
| 347 | int cbcnt = 0; // Tracks nested curly braces |
| 348 | int sbcnt = 0; // Tracks nested square brackets |
| 349 | bool array_in_string = false; |
| 350 | bool array_escape = false; |
| 351 | while (true) |
| 352 | { |
| 353 | char ch = *str; |
| 354 | if ( ch == 0 ) |
| 355 | { |
| 356 | amrex::Error("ParmParse::getToken: EOF while parsing"); |
| 357 | } |
| 358 | switch (state) |
| 359 | { |
| 360 | case lexState::START: |
| 361 | if ( ch == '=' ) |
| 362 | { |
| 363 | ostr += ch; str++; |
| 364 | return PType::EQ_sign; |
| 365 | } |
| 366 | else if ( ch == '"' ) |
| 367 | { |
| 368 | if (*(str+1) == '"' && *(str+2) == '"') { |
| 369 | str += 3; |
| 370 | if ((*str) == '\n') { |
| 371 | // A newline immediately following the opening |
| 372 | // delimiter will be trimmed. |
| 373 | ++str; |
| 374 | } |
| 375 | state = lexState::TRIPLY_QUOTED_STRING; |
| 376 | quote_type = ParmParse::QuoteType::Triple; |
| 377 | } else { |
| 378 | str++; |
| 379 | state = lexState::QUOTED_STRING; |
| 380 | quote_type = ParmParse::QuoteType::Double; |
| 381 | } |
| 382 | } |
| 383 | else if ( ch == '(' ) |
no test coverage detected