/* * Copyright (c) 2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace CMake { class Lexer : private GenericLexer { public: static ErrorOr> lex(StringView input); private: Lexer(StringView input); ErrorOr> lex_file(); void skip_whitespace(); void consume_whitespace_or_comments(); void consume_command_invocation(); void consume_arguments(); void consume_argument(); void consume_bracket_argument(); void consume_quoted_argument(); void consume_unquoted_argument(); void consume_comment(); void consume_open_paren(); void consume_close_paren(); void consume_garbage(); StringView read_bracket_argument(); static Vector parse_variable_references_from_argument(StringView argument_value, Position argument_start); Position position() const; void next_line(); void emit_token(Token::Type, StringView value, Position start, Position end, Optional = {}, Vector = {}); Vector m_tokens; size_t m_line { 0 }; size_t m_string_offset_after_previous_newline { 0 }; }; }