-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokenizer.h
38 lines (29 loc) · 1008 Bytes
/
tokenizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef TOKENIZER_H_
#define TOKENIZER_H_
#include <vector>
#include <string>
#define MAXTOKEN 1024
/*
vector<string> tokenize(const char *line)
------------------
Tokenize the input line into a vector of strings and return
Parameters:
------------------
line: const char *
The input as received by the `readline` function call made in the main shell loop
Returns:
------------------
tokens: vector<string>
A list of tokens generated from the input line
The tokenizer escapes quotes, spaces and the backslash character
*/
std::vector<std::string> tokenize(char* line);
/*
vector<vector<string>> parsePipeTokens(vector<string> tokens)
------------------
In case the input contains pipes, split around the pipe character into individual
token groups. For example the input [cat, a.txt, |, grep, "some text", |, wc] is split as
[[cat, a.txt], [grep, "some text"], [wc]]
*/
std::vector<std::vector<std::string>> parsePipeTokens(std::vector<std::string> tokens);
#endif // TOKENIZER_H_