Lexer.h 507 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "LibCpp/Token.h"
  8. #include <AK/StringView.h>
  9. #include <AK/Vector.h>
  10. namespace Cpp {
  11. class Lexer {
  12. public:
  13. Lexer(StringView const&);
  14. Vector<Token> lex();
  15. private:
  16. char peek(size_t offset = 0) const;
  17. char consume();
  18. StringView m_input;
  19. size_t m_index { 0 };
  20. Position m_previous_position { 0, 0 };
  21. Position m_position { 0, 0 };
  22. };
  23. }