mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:12:46 +00:00 
			
		
		
		
	HackStudio: Make CppTokens have (line,column) positions
These are infinitely more useful than raw indices into the input text.
This commit is contained in:
		
							parent
							
								
									0d53d74d5f
								
							
						
					
					
						commit
						0604fcf9fd
					
				
					 2 changed files with 27 additions and 6 deletions
				
			
		|  | @ -23,6 +23,11 @@ | |||
|     __TOKEN(Keyword)               \ | ||||
|     __TOKEN(Identifier) | ||||
| 
 | ||||
| struct CppPosition { | ||||
|     int line { -1 }; | ||||
|     int column { -1 }; | ||||
| }; | ||||
| 
 | ||||
| struct CppToken { | ||||
|     enum class Type { | ||||
| #define __TOKEN(x) x, | ||||
|  | @ -43,7 +48,8 @@ struct CppToken { | |||
|     } | ||||
| 
 | ||||
|     Type m_type { Type::Invalid }; | ||||
|     StringView m_view; | ||||
|     CppPosition m_start; | ||||
|     CppPosition m_end; | ||||
| }; | ||||
| 
 | ||||
| class CppLexer { | ||||
|  | @ -58,4 +64,6 @@ private: | |||
| 
 | ||||
|     StringView m_input; | ||||
|     int m_index { 0 }; | ||||
|     CppPosition m_previous_position { 0, 0 }; | ||||
|     CppPosition m_position { 0, 0 }; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling