Made the parse definitions for variable, typedef, using more complete.

Fixed issues seen with expression token parsing
Moved array expression parsing outside of type parsing. Its only done with variable, typdef, and using declarations.
Added parsing of attributes, I'm going to make them separate from the regular specifiers as they are complicated.
This commit is contained in:
2023-04-23 14:33:37 -04:00
parent 09491be375
commit e50e9e094e
6 changed files with 321 additions and 284 deletions

View File

@ -1,24 +0,0 @@
project( 'test', 'c', default_options : ['buildtype=debug'] )
# add_global_arguments('-E', language : 'cpp')
includes = include_directories(
[
'../gen',
'../../singleheader'
])
# get_sources = files('./get_sources.ps1')
# sources = files(run_command('powershell', get_sources, check: true).stdout().strip().split('\n'))
sources = [ 'test.c99.c' ]
if get_option('buildtype').startswith('debug')
add_project_arguments('-DBuild_Debug', language : ['c' ])
endif
add_project_arguments('-Dgentime', language : ['c', 'cpp'])
executable( 'test_c99', sources, include_directories : includes )

View File

@ -1,79 +0,0 @@
#include "gen.h"
#define Table( Type_ ) Table_##Type_
typedef u64(*)(void*) HashingFn;
#if gen_time
# define gen_table( Type_, HashingFn_ ) gen_request_table( #Type_, sizeof(Type_), HashingFn_ )
u64 table_default_hash_fn( void* address )
{
return crc32( address, 4 );
}
Code gen_table_code( char const* type_str, sw type_size, HashingFn hash_fn )
{
Code table;
return table;
}
struct TableRequest
{
char const* Type;
sw Size;
HashingFn HashFn;
};
array(TableRequest) TableRequests;
void gen_request_table( const char* type_str, sw type_size, HashingFn hash_fn )
{
TableRequest request = { type_str, type_size, hash_fn };
array_append( TableRequests, request );
}
u32 gen_table_file()
{
gen_table( u32 );
gen_table( char const* );
array(Code) array_asts;
array_init( array_asts, g_allocator );
sw left = array_count( TableRequests );
sw index = 0;
while( left -- )
{
ArrayRequest request = TableRequests[index];
Code result = gen_table_code( request.Name, request.Size, request.HashFn );
array_append( array_asts, result );
}
Builder
arraygen;
arraygen.open( "table.gen.h" );
left = array_count( array_asts );
index = 0;
while( left-- )
{
Code code = array_asts[index];
arraygen.print( code );
}
arraygen.write();
return 0;
}
#endif
#ifndef gen_time
# include "table.gen.h"
#endif

View File

@ -1,40 +0,0 @@
#define GENC_IMPLEMENTATION
#include "genc.h"
#include "table.h"
struct Test
{
u64 A;
u64 B;
};
#if gen_time
u64 hash_struct( void* test )
{
return crc32( ((Test)test).A, sizeof(u64) );
}
int gen_main()
{
gen_table( Test, & hash_struct )
gen_table_file();
}
#endif
#if runtime
int main()
{
Table(Test) test_table;
}
#endif