BashSpark
Loading...
Searching...
No Matches
shell_tokenizer.h
Go to the documentation of this file.
1
30#pragma once
31
32#include <vector>
33
35
36namespace bs {
72
82 struct shell_token {
86 std::size_t m_nPos;
88 std::string_view m_sTokenText;
89 };
90
95 public:
105 static std::vector<shell_token> tokens(ifakestream &oStdIn);
106
107 private:
115 static void tokens(
116 std::vector<shell_token> &vTokens,
117 ifakestream &oStdIn,
118 char cDelimiter
119 );
120
130 static void tokens_dollar(std::vector<shell_token> &vTokens, ifakestream &oStdIn);
131
138 static void tokens_dollar_variable(std::vector<shell_token> &vTokens, ifakestream &oStdIn);
139
146 static void tokens_quote_simple(std::vector<shell_token> &vTokens, ifakestream &oStdIn);
147
154 static void tokens_quote_double(std::vector<shell_token> &vTokens, ifakestream &oStdIn);
155
162 static void tokens_backslash(std::vector<shell_token> &vTokens, ifakestream &oStdIn);
163 };
164}
A class for input stream behavior with a character type.
Definition fakestream.h:70
Definition shell_tokenizer.h:94
static std::vector< shell_token > tokens(ifakestream &oStdIn)
Tokenizes input from the standard input stream.
Definition shell_tokenizer.cpp:155
Generic input and output stream classes with character types.
BashSpark main namespace.
Definition command.h:39
shell_token_type
Enumeration of types of tokens that can be parsed from shell commands.
Definition shell_tokenizer.h:44
@ TK_QUOTE_DOUBLE
Represents double quotes (e.g., "text").
@ TK_CMD_SEPARATOR
Represents command separators (e.g., ;).
@ TK_QUOTE_BACK
Represents back quotes (e.g., command).
@ TK_OPERATOR
Represents various operators.
@ TK_OR
Represents a logical OR (||).
@ TK_DOLLAR
Represents a dollar sign ($).
@ TK_OPEN_PARENTHESIS
Represents an open parenthesis ('(').
@ TK_BACKGROUND
Represents background execution (&).
@ TK_CLOSE_SQR_BRACKETS
Represents a close square bracket (']').
@ TK_OPEN_BRACKETS
Represents an open bracket ('{').
@ TK_AND
Represents logical AND (&&).
@ TK_DOLLAR_SPECIAL
Represents special dollar sign usages (e.g., $?, $).
@ TK_CLOSE_PARENTHESIS
Represents a close parenthesis (')').
@ TK_QUOTE_SIMPLE
Represents simple quotes (e.g., 'text').
@ TK_EOF
Represents the end of the file/input.
@ TK_EXCLAMATION
Represents an exclamation mark (!).
@ TK_WORD
Represents a word in the command.
@ TK_PIPE
Represents a pipe (|).
@ TK_ESCAPED
Represents escaped characters.
@ TK_SPACE
Represents whitespace in the command.
@ TK_UNICODE
Represents Unicode characters.
@ TK_CLOSE_BRACKETS
Represents a close bracket ('}').
@ TK_OPEN_SQR_BRACKETS
Represents an open square bracket ('[').
Represents a token generated during command parsing.
Definition shell_tokenizer.h:82
std::string_view m_sTokenText
The text of the token.
Definition shell_tokenizer.h:88
std::size_t m_nPos
The position of the token in the input.
Definition shell_tokenizer.h:86
shell_token_type m_nType
The type of the token.
Definition shell_tokenizer.h:84