test: finish lexer61 test and fix its issue.
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace yycc::carton::lexer61 {
|
||||
|
||||
Lexer61::Lexer61() : m_ArgsCollection(), m_CurrentArg(), m_CurrentChar(u8'\0'), m_State(LexerState::Space), m_PrevState(LexerState::Space) {}
|
||||
Lexer61::Lexer61() :
|
||||
m_ArgsCollection(), m_CurrentArg(), m_CurrentChar(u8'\0'), m_State(LexerState::Space), m_PrevState(LexerState::Space) {}
|
||||
|
||||
Lexer61::~Lexer61() {}
|
||||
|
||||
LexerResult<std::vector<std::u8string_view>> Lexer61::lex(const std::u8string_view &cmd) {
|
||||
LexerResult<std::vector<std::u8string>> Lexer61::lex(const std::u8string_view &cmd) {
|
||||
// Clear variables when we start a new lex.
|
||||
this->reset();
|
||||
|
||||
@@ -67,20 +68,6 @@ namespace yycc::carton::lexer61 {
|
||||
}
|
||||
}
|
||||
|
||||
LexerResult<std::vector<std::u8string>> Lexer61::owend_lex(const std::u8string_view &cmd) {
|
||||
auto rv = this->lex(cmd);
|
||||
if (rv.has_value()) {
|
||||
auto source = std::move(rv.value());
|
||||
std::vector<std::u8string> elems;
|
||||
for (const auto &strl_view : source) {
|
||||
elems.emplace_back(std::u8string(strl_view));
|
||||
}
|
||||
return elems;
|
||||
} else {
|
||||
std::unexpected(rv.error());
|
||||
}
|
||||
}
|
||||
|
||||
void Lexer61::reset() {
|
||||
// Because these value may be moved, so we need assign them with new value,
|
||||
// rather clear them.
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace yycc::carton::lexer61 {
|
||||
YYCC_DEFAULT_COPY_MOVE(Lexer61)
|
||||
|
||||
public:
|
||||
LexerResult<std::vector<std::u8string_view>> lex(const std::u8string_view& cmd);
|
||||
LexerResult<std::vector<std::u8string>> owend_lex(const std::u8string_view& cmd);
|
||||
LexerResult<std::vector<std::u8string>> lex(const std::u8string_view& cmd);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
@@ -36,11 +35,11 @@ namespace yycc::carton::lexer61 {
|
||||
void proc_escape();
|
||||
void proc_normal();
|
||||
|
||||
std::vector<std::u8string_view> m_ArgsCollection; ///< Internal result holder.
|
||||
std::u8string m_CurrentArg; ///< Holding current building commandline argument.
|
||||
char8_t m_CurrentChar; ///< Holding current char analysing.
|
||||
LexerState m_State; ///< Recording current state.
|
||||
LexerState m_PrevState; ///< Recording previous state.
|
||||
std::vector<std::u8string> m_ArgsCollection; ///< Internal result holder.
|
||||
std::u8string m_CurrentArg; ///< Holding current building commandline argument.
|
||||
char8_t m_CurrentChar; ///< Holding current char analysing.
|
||||
LexerState m_State; ///< Recording current state.
|
||||
LexerState m_PrevState; ///< Recording previous state.
|
||||
};
|
||||
|
||||
} // namespace yycc::carton::lexer61
|
||||
|
||||
Reference in New Issue
Block a user