Added the beginning of the language

master
Ruben 2023-01-16 15:43:54 +01:00
parent f524c4a84d
commit 707337ca6e
No known key found for this signature in database
GPG Key ID: F6DAAC2742760162
1 changed files with 46 additions and 0 deletions

View File

@ -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);