WIP: Fleshing out parsing constructor

This code commit will compile just backing up stuff before I switch the functions to use the lexer instead of manually sifting through the string.
This commit is contained in:
Edward R. Gonzalez 2023-04-18 22:47:59 -04:00
parent eec93cee78
commit 86cd0e1fb7
5 changed files with 892 additions and 125 deletions

View File

@ -14,7 +14,9 @@
"exception": "cpp",
"optional": "cpp",
"tuple": "cpp",
"xmemory": "cpp"
"xmemory": "cpp",
"algorithm": "cpp",
"limits": "cpp"
},
"C_Cpp.intelliSenseEngineFallback": "disabled"
}

View File

@ -60,6 +60,7 @@ using zpl::EFileError_NONE;
using zpl::alloc;
using zpl::arena_allocator;
using zpl::arena_init_from_memory;
using zpl::arena_init_from_allocator;
using zpl::arena_free;
using zpl::bprintf;
using zpl::char_is_alpha;
@ -79,6 +80,7 @@ using zpl::snprintf_va;
using zpl::string_appendc;
using zpl::string_append_fmt;
using zpl::string_append_length;
using zpl::string_make_length;
using zpl::string_length;
using zpl::string_make;
using zpl::strnlen;

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,8 @@
* Macro or template generation : This library is to avoid those, adding support for them adds unnecessary complexity.
* Vendor provided dynamic dispatch (virtuals) : Roll your own, this library might roll its own vtable/interface generation helpers in the future.
* RTTI : This is kinda covered with the last point, but just wanted to emphasize.
* Exceptions : Most fo the
* RTTI
* Exceptions
* Execution statement validation : Execution expressions are defined using the untyped string API.
Keywords in from "Modern C++":
@ -383,6 +383,9 @@
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
// #define GEN_DONT_USE_FATAL
#define GEN_ENFORCE_READONLY_AST
#define GEN_FEATURE_INCREMENTAL
#define GEN_FEATURE_PARSING
#define GEN_FEATURE_EDITOR
#define GEN_FEATURE_SCANNER
@ -439,6 +442,7 @@ namespace gen
Entry( Variable ) \
Entry( Typedef ) \
Entry( Typename ) \
Entry( Union ) \
Entry( Using ) \
Entry( Using_Namespace )
@ -498,7 +502,7 @@ namespace gen
Entry( Assgin_Divide, /= ) \
Entry( Assgin_Modulo, %= ) \
Entry( Assgin_BAnd, &= ) \
Entry( Assgin_BOr, &= ) \
Entry( Assgin_BOr, |= ) \
Entry( Assign_BXOr, ^= ) \
Entry( Assign_LShift, <<= ) \
Entry( Assign_RShift, >>= ) \
@ -535,7 +539,7 @@ namespace gen
enum Type : u32
{
# define Entry( Type, Token ) Type,
# define Entry( Type_, Token_ ) Type_,
Define_Operators
# undef Entry
Comma,
@ -552,7 +556,7 @@ namespace gen
local_persist
char const* lookup[ Num_Ops ] = {
# define Entry( Type, Token ) txt(Token),
# define Entry( Type_, Token_ ) txt(Token_),
Define_Operators
# undef Entry
","
@ -570,15 +574,11 @@ namespace gen
# if defined(ZPL_SYSTEM_WINDOWS)
# define API_Export_Code __declspec(dllexport)
# define API_Import_Code __declspec(dllimport)
# define API_Keyword __declspec
# elif defined(ZPL_SYSTEM_MACOS)
# define API_Export_Code __attribute__ ((visibility ("default")))
# define API_Import_Code __attribute__ ((visibility ("default")))
# endif
# if defined(ZPL_MODULE_THREADING)
# define Thread_Local_Code thread_local
# else
# define Thread_Local_Code "NOT DEFINED"
# define API_Keyword __attribute__
# endif
# define Define_Specifiers \
@ -587,8 +587,8 @@ namespace gen
Entry( Attribute, "You cannot stringize an attribute this way" ) \
Entry( Alignas, alignas ) \
Entry( Array_Decl, "You cannot stringize an array declare this way" ) \
Entry( Const, const ) \
Entry( C_Linkage, extern "C" ) \
Entry( Const, const ) \
Entry( Consteval, consteval ) \
Entry( Constexpr, constexpr ) \
Entry( Constinit, constinit ) \
@ -605,7 +605,7 @@ namespace gen
Entry( Register, register ) \
Entry( RValue, && ) \
Entry( Static_Member, static ) \
Entry( Thread_Local, Thread_Local_Code ) \
Entry( Thread_Local, thread_local ) \
Entry( Volatile, volatile )
enum Type : u32
@ -1100,6 +1100,7 @@ namespace gen
# pragma endregion Upfront
# pragma region Incremental
# ifdef GEN_FEATURE_INCREMENTAL
Code make_class ( s32 length, char const* name, Code parent = NoCode, Code specifiers = NoCode );
Code make_enum ( s32 length, char const* name, Code type = NoCode, EnumT specifier = EnumRegular );
Code make_function ( s32 length, char const* name, Code params = NoCode, Code ret_type = NoCode, Code specifiers = NoCode );
@ -1109,9 +1110,11 @@ namespace gen
Code make_params ();
Code make_specifiers ();
Code make_struct ( s32 length, char const* name, Code parent = NoCode, Code specifiers = NoCode );
# endif
# pragma endregion Incremental
# pragma region Parsing
# ifdef GEN_FEATURE_PARSING
Code parse_class ( s32 length, char const* class_def );
Code parse_enum ( s32 length, char const* enum_def );
Code parse_execution ( s32 length, char const* exec_def );
@ -1136,6 +1139,7 @@ namespace gen
s32 parse_variables ( s32 length, char const* vars_def, Code* out_var_codes );
s32 parse_typedefs ( s32 length, char const* typedef_def, Code* out_typedef_codes );
s32 parse_usings ( s32 length, char const* usings_def, Code* out_using_codes );
# endif
# pragma endregion Parsing
# pragma region Untyped text
@ -1364,10 +1368,13 @@ namespace gen
# define operator_body( ... ) gen::def_operator_body ( macro_num_args( __VA_ARGS__ ), __VA_ARGS__ )
# define struct_body( ... ) gen::def_struct_body ( macro_num_args( __VA_ARGS__ ), __VA_ARGS__ )
# ifdef GEN_FEATURE_INCREMENTAL
// Incremental
# define make( ConstructType_, Name_, ... ) Code Name_ = make_##ConstructType_( txt_n_len(Name_), __VA_ARGS__ );
# endif
# ifdef GEN_FEATURE_PARSING
// Parsing
# define class_code( ... ) gen::parse_class ( txt_n_len( __VA_ARGS__ ))
@ -1381,6 +1388,7 @@ namespace gen
# define type_code( ... ) gen::parse_type ( txt_n_len( __VA_ARGS__ ))
# define typedef_code( ... ) gen::parse_typedef ( txt_n_len( __VA_ARGS__ ))
# define using_code( ... ) gen::parse_code ( txt_n_len( __VA_ARGS__ ))
# endif
// Untyped

61
thirdparty/zpl.h vendored
View File

@ -35,7 +35,7 @@ GitHub:
Version History:
19.0.0 - Check all results of zpl_alloc() when using JSON parser/writer (rheatley-pervasid)
18.1.5 - set parent to parsed JSON nodes (fixed)
- fix zpl_json/csv_write_string off-by-one issue
18.1.4 - fix zpl_random_gen_isize/zpl_random_range_isize 32bit overflow
@ -51,13 +51,13 @@ Version History:
18.0.0 - removed coroutines module
- removed timer module
- rename zpl_adt_get -> zpl_adt_query
17.0.0 - ADT API changes
zpl_adt_inset_* -> zpl_adt_append_*
zpl_adt_node now holds a parent field, methods no longer require a pointer to the parent
methods are now documented
- add zpl_thread_init_nowait (gaopeng)
16.1.1 - fix scientific notation parsing
16.1.0 - introduce ZPL_PARSER_DISABLE_ANALYSIS that disables extra parsing capabilities to offer better raw performance
at a cost of lack of node metadata.
@ -69,7 +69,7 @@ Version History:
- fix memory leak when parsing a json array (gaopeng)
- add zpl_strntok (gaopeng)
- add zpl_semaphore_trywait (gaopeng)
15.0.3 - fix zpl_sign call in math failing to compile
on macos devices
15.0.2 - zpl_sign0 was introduced
@ -77,7 +77,7 @@ Version History:
- zpl_sign(0) returns 0
15.0.0 - Rework zpl ring buffer
- various code improvements
14.1.7 - fix zpl_random_range_i64
- set thread's is_running before we start a thread
14.1.6 - remove windows.h dependency for header part
@ -87,7 +87,7 @@ Version History:
14.1.0 - add hashtable map_mut method
14.0.1 - fix zpl_array_remove_at boundary bug
14.0.0 - heap memory allocator analysis
13.4.1 - adt optimizations
13.4.0 - new adt manipulation methods
13.3.3 - fix zpl_str_skip_literal bug
@ -102,7 +102,7 @@ Version History:
13.1.1 - fix emscripten support
13.1.0 - abstract data tree naming update
13.0.0 - text parsers refactor
12.8.0 - zpl_opts improvements
12.7.0 - math improvements
12.6.2 - remove register usage (BeastLe9enD)
@ -119,7 +119,7 @@ Version History:
12.1.0 - Add rectangle partitioning
12.0.1 - Optimize zpl_strlen
12.0.0 - JSON API revamp + improvements
11.3.0 - JSON zpl_json_str_to_flt + cleanup
11.2.5 - fix small atomics typo
11.2.4 - JSON rewrite core parser
@ -141,7 +141,7 @@ Version History:
11.0.0 - New jobs system
- Rewrite the timer module
- zpl_ring rework
10.13.0 - Initial ARM threading support
10.12.1 - Fix missing zpL_alloc_str
10.12.0 - Add zpl_crc64
@ -185,7 +185,7 @@ Version History:
10.0.4 - Flush tester output to fix ordering
10.0.3 - Fix ZPL_STATIC_ASSERT under MSVC
10.0.0 - Major overhaul of the library
9.8.10 - JSON fix array-based documents with objects
9.8.9 - JSON document structured as array now properly recognizes the root object as array.
9.8.8 - Fixed an incorrect parsing of empty array nodes.
@ -218,7 +218,7 @@ Version History:
9.1.0 - get_env rework and fixes
9.0.3 - Small fixes and removals
9.0.0 - New documentation format, removed deprecated code, changed styles
8.14.1 - Fix string library
8.14.0 - Added zpl_re_match_all
8.13.0 - Update system command API
@ -237,7 +237,7 @@ Version History:
8.10.0 - Added zpl_strchr
8.9.0 - API improvements for JSON5 parser
8.8.4 - Add support for SJSON formatting http://bitsquid.blogspot.com/2009/10/simplified-json-notation.html
6.8.3 - JSON5 exp fix
6.8.2 - Bugfixes applied from gb
6.8.1 - Performance improvements for JSON5 parser
@ -257,7 +257,7 @@ Version History:
6.0.2 - Fixed warnings for json5 i64 printfs
6.0.1 - Fixed warnings for particual win compiler in dirlist method
6.0.0 - New build, include/ was renamed to code/
5.8.3 - Naming fixes
5.8.2 - Job system now supports prioritized tasks
5.8.1 - Renames zpl_pad to zpl_ring
@ -285,7 +285,7 @@ Version History:
5.0.2 - Fix segfault when using zpl_stack_memory
5.0.1 - Small code improvements
5.0.0 - Project structure changes
4.7.2 - Got rid of size arg for zpl_str_split_lines
4.7.1 - Added an example
4.7.0 - Added zpl_path_dirlist
@ -310,7 +310,7 @@ Version History:
4.0.2 - Warning fix for _LARGEFILE64_SOURCE
4.0.1 - include stdlib.h for getenv (temp)
4.0.0 - ARM support, coding style changes and various improvements
3.4.1 - zpl_memcopy now uses memcpy for ARM arch-family
3.4.0 - Removed obsolete code
3.3.4 - Added Travis CI config
@ -331,7 +331,7 @@ Version History:
3.0.2 - Fixed linux part, and removed trailing spaces
3.0.1 - Small bugfix in zpl_file_open
3.0.0 - Added several fixes and features
2.4.0 - Added remove to hash table
2.3.3 - Removed redundant code
2.3.2 - Eliminated extra warnings
@ -344,7 +344,7 @@ Version History:
2.0.8 - Small adjustments
2.0.7 - MinGW related fixes
2.0.0 - New NPM based version
1.2.2 - Small fix
1.2.1 - Macro fixes
1.2.0 - Added zpl_async macro
@ -354,15 +354,15 @@ Version History:
License:
This Software is dual licensed under the following licenses:
Unlicense
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@ -370,7 +370,7 @@ License:
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@ -378,15 +378,15 @@ License:
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
BSD 3-Clause
Copyright (c) 2016-2021 Dominik Madarász. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@ -395,7 +395,7 @@ License:
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -8367,7 +8367,9 @@ ZPL_END_NAMESPACE
# endif
# if ! defined( thread_local )
# if defined( _MSC_VER ) && _MSC_VER >= 1300
# if defined( __cplusplus ) && __cplusplus >= 201103L
# define thread_local thread_local
# elif defined( _MSC_VER ) && _MSC_VER >= 1300
# define thread_local __declspec( thread )
# elif defined( __GNUC__ )
# define thread_local __thread
@ -8803,7 +8805,10 @@ ZPL_END_NAMESPACE
# endif
# else
# if ! defined( thread_local )
# define thread_local
# if defined( __cplusplus ) && __cplusplus >= 201103L
# define thread_local thread_local
# else
# define thread_local
# endif
# endif