Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- auto Read(Tokenizer* tokenizer) {
- Token token = tokenizer->GetToken();
- tokenizer->Next();
- if (ConstantToken* constant = std::get_if<ConstantToken>(&token)) {
- return std::make_shared<Number>(constant->GetValue());
- } else if (SymbolToken* symbol = std::get_if<SymbolToken>(&token)) {
- return std::make_shared<Symbol>(symbol->GetString());
- } else if (DotToken* dot = std::get_if<DotToken>(&token)) {
- return std::shared_ptr<Dot>();
- } else if (token == Token{BracketToken::OPEN}) {
- return ReadList(tokenizer);
- } else if (token == Token{BracketToken::CLOSE}) { // <---- ИНТЕРЕСЕН ВОТ ЭТОТ СЛУЧАЙ
- return std::shared_ptr<CloseBracket>();
- } else {
- return nullptr;
- }
- }
- auto ReadList(Tokenizer* tokenizer) {
- auto cell = std::shared_ptr<Cell>(new Cell);
- cell->SetFirst(Read(tokenizer));
- if (typeid(cell->GetFirst()) == typeid(std::shared_ptr<CloseBracket>())) { // Не работает :(
- tokenizer->Next();
- return nullptr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement