MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LexString

Method LexString

tensorflow/compiler/xla/service/hlo_lexer.cc:430–446  ·  view source on GitHub ↗

Lexes quoted string with escaping characters. If matched, the quoted string will be unescaped and stored to token_state_.str_val.

Source from the content-addressed store, hash-verified

428// Lexes quoted string with escaping characters. If matched, the quoted string
429// will be unescaped and stored to token_state_.str_val.
430TokKind HloLexer::LexString() {
431 absl::string_view consumable =
432 StringPieceFromPointers(token_state_.token_start, buf_.end());
433 static LazyRE2 escaping_pattern = {R"("([^"\\]|\\.)*")"};
434 if (RE2::Consume(&consumable, *escaping_pattern)) {
435 current_ptr_ = consumable.begin();
436 absl::string_view raw =
437 StringPieceFromPointers(token_state_.token_start + 1, current_ptr_ - 1);
438 string error;
439 if (!absl::CUnescape(raw, &token_state_.str_val, &error)) {
440 LOG(ERROR) << "Failed unescaping string: " << raw << ". error: " << error;
441 return TokKind::kError;
442 }
443 return TokKind::kString;
444 }
445 return TokKind::kError;
446}
447
448string TokKindToString(TokKind kind) {
449 switch (kind) {

Callers

nothing calls this directly

Calls 3

CUnescapeFunction · 0.85
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected