Make tokenization aware of string templates
This commit is contained in:
		
							parent
							
								
									94a13b0d3c
								
							
						
					
					
						commit
						63792ea983
					
				| @ -31,6 +31,7 @@ pub const Token = union(enum) { | ||||
| 
 | ||||
| 	number: []const coral.io.Byte, | ||||
| 	string: []const coral.io.Byte, | ||||
| 	template_string: []const coral.io.Byte, | ||||
| 
 | ||||
| 	keyword_nil, | ||||
| 	keyword_false, | ||||
| @ -81,6 +82,7 @@ pub const Token = union(enum) { | ||||
| 
 | ||||
| 			.number => |literal| literal, | ||||
| 			.string => |literal| literal, | ||||
| 			.template_string => |literal| literal, | ||||
| 
 | ||||
| 			.keyword_const => "const", | ||||
| 			.keyword_nil => "nil", | ||||
| @ -305,6 +307,22 @@ pub const Stream = struct { | ||||
| 					return; | ||||
| 				}, | ||||
| 
 | ||||
| 				'`' => { | ||||
| 					cursor += 1; | ||||
| 
 | ||||
| 					const begin = cursor; | ||||
| 
 | ||||
| 					while (cursor < self.source.len) switch (self.source[cursor]) { | ||||
| 						'`' => break, | ||||
| 						else => cursor += 1, | ||||
| 					}; | ||||
| 
 | ||||
| 					self.token = .{.template_string = self.source[begin .. cursor]}; | ||||
| 					cursor += 1; | ||||
| 
 | ||||
| 					return; | ||||
| 				}, | ||||
| 
 | ||||
| 				'"' => { | ||||
| 					cursor += 1; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user