| 
									
										
										
										
											2020-09-09 13:00:06 -07:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							| 
									
										
										
										
											2020-09-09 13:57:01 -07:00
										 |  |  | #include <sstream>
 | 
					
						
							| 
									
										
										
										
											2020-09-09 13:00:06 -07:00
										 |  |  | #include "definition.hpp"
 | 
					
						
							|  |  |  | #include "location.hh"
 | 
					
						
							|  |  |  | #include "parser.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct parse_driver; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void scanner_init(parse_driver* d, yyscan_t* scanner); | 
					
						
							|  |  |  | void scanner_destroy(yyscan_t* scanner); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct parse_driver { | 
					
						
							|  |  |  |     std::string file_name; | 
					
						
							| 
									
										
										
										
											2020-09-09 13:57:01 -07:00
										 |  |  |     std::ostringstream string_stream; | 
					
						
							| 
									
										
										
										
											2020-09-09 13:00:06 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     yy::location location; | 
					
						
							|  |  |  |     size_t file_offset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<size_t> line_offsets; | 
					
						
							|  |  |  |     definition_group global_defs; | 
					
						
							| 
									
										
										
										
											2020-09-11 02:16:29 -07:00
										 |  |  |     std::string file_contents; | 
					
						
							| 
									
										
										
										
											2020-09-09 13:00:06 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     parse_driver(const std::string& file) | 
					
						
							| 
									
										
										
										
											2020-09-09 13:57:01 -07:00
										 |  |  |         : file_name(file), file_offset(0) {} | 
					
						
							| 
									
										
										
										
											2020-09-09 13:00:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-11 02:16:29 -07:00
										 |  |  |     bool run_parse(); | 
					
						
							|  |  |  |     void write(const char* buff, size_t len); | 
					
						
							|  |  |  |     void mark_line(); | 
					
						
							|  |  |  |     size_t get_index(int line, int column); | 
					
						
							|  |  |  |     size_t get_line_end(int line); | 
					
						
							|  |  |  |     void print_highlighted_location(std::ostream& stream, const yy::location& loc); | 
					
						
							| 
									
										
										
										
											2020-09-09 13:00:06 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define YY_DECL yy::parser::symbol_type yylex(yyscan_t yyscanner, parse_driver& drv)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | YY_DECL; |