Advertisement
TimSenin

Untitled

Nov 10th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. auto Read(Tokenizer* tokenizer) {
  2.     Token token = tokenizer->GetToken();
  3.     tokenizer->Next();
  4.     if (ConstantToken* constant = std::get_if<ConstantToken>(&token)) {
  5.         return std::make_shared<Number>(constant->GetValue());
  6.     } else if (SymbolToken* symbol = std::get_if<SymbolToken>(&token)) {
  7.         return std::make_shared<Symbol>(symbol->GetString());
  8.     } else if (DotToken* dot = std::get_if<DotToken>(&token)) {
  9.         return std::shared_ptr<Dot>();
  10.     } else if (token == Token{BracketToken::OPEN}) {
  11.         return ReadList(tokenizer);
  12.     } else if (token == Token{BracketToken::CLOSE}) {  // <---- ИНТЕРЕСЕН ВОТ ЭТОТ СЛУЧАЙ
  13.         return std::shared_ptr<CloseBracket>();
  14.     } else {
  15.         return nullptr;
  16.     }
  17. }
  18.  
  19. auto ReadList(Tokenizer* tokenizer) {
  20.     auto cell = std::shared_ptr<Cell>(new Cell);
  21.     cell->SetFirst(Read(tokenizer));
  22.     if (typeid(cell->GetFirst()) == typeid(std::shared_ptr<CloseBracket>())) {  // Не работает :(
  23.         tokenizer->Next();
  24.         return nullptr;
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement