gencpp/base/auxiliary/scanner.hpp

47 lines
1.4 KiB
C++
Raw Permalink Normal View History

#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
2024-12-10 13:13:14 -08:00
# include "helpers/push_ignores.inline.hpp"
# include "components/header_start.hpp"
# include "components/types.hpp"
# include "components/gen/ecode.hpp"
# include "components/gen/eoperator.hpp"
# include "components/gen/especifier.hpp"
# include "components/ast.hpp"
# include "components/code_types.hpp"
# include "components/ast_types.hpp"
# include "components/interface.hpp"
# include "components/inlines.hpp"
# include "components/gen/ast_inlines.hpp"
# include "components/header_end.hpp"
#endif
2023-08-21 18:40:23 -07:00
2024-12-10 13:13:14 -08:00
#pragma region Scanner
// This is a simple file reader that reads the entire file into memory.
// It has an extra option to skip the first few lines for undesired includes.
// This is done so that includes can be kept in dependency and component files so that intellisense works.
Code scan_file( char const* path );
Progress towards bootstrap/singleheader generation I will most likely need to refactor some of the components & dependencies files to get the desired gneration implementation the way I want. Specficially I want to be able to eliminate macros I'm using for enums and common patterns for implmeentation of the data structures. When it comes to the cpp files, I may leave those alone as the macros largely help ith readability. Replacing those macros is expensive and most likely not worth it. The macros under consideration with replacing using the library bootstrap are: * Define_Types * Define_Operators * Define_Specifiers * GEN_Define_Attribute_Tokens * Define_CodeType * Using_Code * Define_TokType * def_constant_spec ? * Helper Macros for def_**_body functions ? * AST unallowed types case macros? (The last three I'm unsure about as they work fine, and neeeding the debugger steps there is a rare scenario...) The enums could be manually generated and have its fields derived from a CSV (which is what genc is currently doing). This would allow the user to specify custom attribute macros as well with greater ease. I may maually inline ProcessModuleFlags, as its not even necessary as any specific symbol with a module flag will only use the export value. Import is only used on modules themselves (from what I can tell). The Parser::lex function could be offloaded to its own file in case the user wants to swap the entire thing out. (Most likely may want to for various purposes) The problem with extracting any definitions out of a component file currently is that will lead to splintering that componnet to multiple other components. This is necessary as the proper scanner is not implemented yet (only a reduimentary scan_file proc is made so far).
2023-07-24 19:19:21 -07:00
2024-12-10 20:35:47 -08:00
CodeBody parse_file( const char* path );
2024-12-10 13:13:14 -08:00
// The follow is basic support for light csv parsing (use it as an example)
// Make something robust if its more serious.
typedef struct CSV_Column CSV_Column;
struct CSV_Column {
CSV_Object ADT;
2024-12-10 20:35:47 -08:00
Array(ADT_Node) Content;
};
2024-12-10 13:13:14 -08:00
typedef struct CSV_Columns2 CSV_Columns2;
struct CSV_Columns2 {
CSV_Object ADT;
2024-12-10 20:35:47 -08:00
Array(ADT_Node) Col_1;
Array(ADT_Node) Col_2;
2024-12-10 13:13:14 -08:00
};
2024-12-10 20:35:47 -08:00
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path);
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
2024-12-10 13:13:14 -08:00
#pragma endregion Scanner