mpw-shell/mpw-shell.h

71 lines
1.1 KiB
C
Raw Normal View History

2016-01-27 15:43:34 +00:00
#ifndef __mpw_shell_h__
#define __mpw_shell_h__
#include <string>
#include <vector>
#include <unordered_map>
#include <memory>
#include <cstdint>
2016-02-02 01:38:29 +00:00
#include "environment.h"
2016-01-27 15:43:34 +00:00
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);
2016-02-02 01:38:29 +00:00
std::string expand_vars(const std::string &s, const class Environment &);
2016-01-27 15:43:34 +00:00
//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