mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	 bb07d678ac
			
		
	
	
		bb07d678ac
		
	
	
	
	
		
			
			This is a totally different syntax than for regular CMake files, and also is undocumented and subject to change, but it's also nice and simple. :^)
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			963 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			963 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/GenericLexer.h>
 | |
| #include <AK/Vector.h>
 | |
| #include <LibCMake/CMakeCache/Token.h>
 | |
| 
 | |
| namespace CMake::Cache {
 | |
| 
 | |
| class Lexer : private GenericLexer {
 | |
| public:
 | |
|     static ErrorOr<Vector<Token>> lex(StringView input);
 | |
| 
 | |
| private:
 | |
|     Lexer(StringView input);
 | |
| 
 | |
|     ErrorOr<Vector<Token>> lex_file();
 | |
| 
 | |
|     void skip_whitespace();
 | |
| 
 | |
|     void consume_comment();
 | |
|     void consume_help_text();
 | |
|     void consume_variable_definition();
 | |
|     void consume_key();
 | |
|     void consume_colon();
 | |
|     void consume_type();
 | |
|     void consume_equals();
 | |
|     void consume_value();
 | |
|     void consume_garbage();
 | |
| 
 | |
|     Position position() const;
 | |
|     void next_line();
 | |
| 
 | |
|     void emit_token(Token::Type, StringView value, Position start, Position end);
 | |
| 
 | |
|     Vector<Token> m_tokens;
 | |
|     size_t m_line { 0 };
 | |
|     size_t m_string_offset_after_previous_newline { 0 };
 | |
| };
 | |
| 
 | |
| }
 |