================ @@ -0,0 +1,191 @@ +//===-- DILLexer.cpp ------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// This implements the recursive descent parser for the Data Inspection +// Language (DIL), and its helper functions, which will eventually underlie the +// 'frame variable' command. The language that this parser recognizes is +// described in lldb/docs/dil-expr-lang.ebnf +// +//===----------------------------------------------------------------------===// + +#include "lldb/ValueObject/DILLexer.h" + +namespace lldb_private { + +namespace dil { + +const std::string DILToken::getTokenName(dil::TokenKind kind) { + std::string retval; + switch (kind) { + case dil::TokenKind::coloncolon: + retval = "coloncolon"; + break; + case dil::TokenKind::eof: + retval = "eof"; + break; + case dil::TokenKind::identifier: + retval = "identifier"; + break; + case dil::TokenKind::kw_namespace: + retval = "namespace"; + break; + case dil::TokenKind::kw_this: + retval = "this"; + break; + case dil::TokenKind::l_paren: + retval = "l_paren"; + break; + case dil::TokenKind::r_paren: + retval = "r_paren"; + break; + case dil::TokenKind::unknown: + retval = "unknown"; + break; + default: + retval = "token_name"; + break; + } + return retval; +} + +static bool Is_Letter(char c) { + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) + return true; + return false; +} + +static bool Is_Digit(char c) { return ('0' <= c && c <= '9'); } + +bool DILLexer::Is_Word(std::string::iterator start, uint32_t &length) { + bool done = false; + for (; m_cur_pos != m_expr.end() && !done; ++m_cur_pos) { + char c = *m_cur_pos; + if (!Is_Letter(c) && !Is_Digit(c) && c != '_') { + done = true; + break; + } else + length++; + } + if (length > 0) + return true; + else ---------------- labath wrote:
https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return https://github.com/llvm/llvm-project/pull/120971 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits