mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-12-29 15:29:19 +00:00
71 lines
1.1 KiB
C++
71 lines
1.1 KiB
C++
#ifndef __mpw_shell_h__
|
|
#define __mpw_shell_h__
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <memory>
|
|
#include <cstdint>
|
|
|
|
#include "environment.h"
|
|
|
|
const unsigned char escape = 0xb6;
|
|
|
|
|
|
class token {
|
|
public:
|
|
enum {
|
|
text = 0,
|
|
eof,
|
|
equivalent,
|
|
not_equivalent,
|
|
// remainder are characters.
|
|
|
|
};
|
|
unsigned type = text;
|
|
std::string string;
|
|
|
|
token() = default;
|
|
token(token &&) = default;
|
|
token(const token&) = default;
|
|
|
|
token &operator=(token &&) = default;
|
|
token &operator=(const token &) = default;
|
|
|
|
token(const std::string &s, unsigned t = text) :
|
|
type(t), string(s)
|
|
{}
|
|
|
|
token(std::string &&s, unsigned t = text) :
|
|
type(t), string(std::move(s))
|
|
{}
|
|
|
|
operator std::string() const {
|
|
return string;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<token> tokenize(std::string &s, bool eval = false);
|
|
std::string expand_vars(const std::string &s, const class Environment &);
|
|
|
|
//std::string quote(std::string &&s);
|
|
std::string quote(const std::string &s);
|
|
|
|
|
|
struct process;
|
|
struct value;
|
|
class fdmask;
|
|
|
|
void parse_tokens(std::vector<token> &&tokens, process &p);
|
|
|
|
|
|
|
|
int32_t evaluate_expression(const std::string &name, std::vector<token> &&tokens);
|
|
|
|
|
|
|
|
#endif
|