Added the beginning of the language
parent
f524c4a84d
commit
707337ca6e
46
src/lang.h
46
src/lang.h
|
@ -11,4 +11,50 @@
|
|||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
enum class TokenType {
|
||||
LEFT_PAREN,
|
||||
RIGHT_PAREN,
|
||||
COLONCOLON,
|
||||
STRING,
|
||||
INTRINSIC,
|
||||
CONSTANT
|
||||
};
|
||||
enum class Intrinsic { LET, UNLET, ENTER, EXIT, SHOW, HIDE };
|
||||
enum class Constant { Character, Location, Image };
|
||||
|
||||
struct Token {
|
||||
TokenType type;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct IntrinsicToken : Token {
|
||||
Intrinsic intrinsic;
|
||||
};
|
||||
|
||||
struct ConstantToken : Token {
|
||||
Constant constant;
|
||||
};
|
||||
|
||||
struct StringToken : Token {
|
||||
std::string string;
|
||||
};
|
||||
|
||||
std::map<std::string, Token> tokens = {
|
||||
{"(", Token{TokenType::LEFT_PAREN, "("}},
|
||||
{")", Token{TokenType::RIGHT_PAREN, ")"}},
|
||||
{"::", Token{TokenType::COLONCOLON, "::"}},
|
||||
{"let", IntrinsicToken{TokenType::INTRINSIC, "let", Intrinsic::LET}},
|
||||
{"unlet", IntrinsicToken{TokenType::INTRINSIC, "unlet", Intrinsic::UNLET}},
|
||||
{"enter", IntrinsicToken{TokenType::INTRINSIC, "enter", Intrinsic::ENTER}},
|
||||
{"exit", IntrinsicToken{TokenType::INTRINSIC, "exit", Intrinsic::EXIT}},
|
||||
{"show", IntrinsicToken{TokenType::INTRINSIC, "show", Intrinsic::SHOW}},
|
||||
{"hide", IntrinsicToken{TokenType::INTRINSIC, "hide", Intrinsic::HIDE}},
|
||||
{"Character",
|
||||
ConstantToken{TokenType::CONSTANT, "Character", Constant::Character}},
|
||||
{"Location",
|
||||
ConstantToken{TokenType::CONSTANT, "Location", Constant::Location}},
|
||||
{"Image", ConstantToken{TokenType::CONSTANT, "Image", Constant::Image}},
|
||||
};
|
||||
|
||||
int read_file(std::deque<std::string> args);
|
||||
int parse_line(std::istream stream);
|
||||
|
|
Loading…
Reference in New Issue