2023-04-22 19:24:55 -07:00
# Documentation
2023-07-19 20:42:28 -07:00
The core library is contained within `gen.hpp` and `gen.cpp` .
Things related to the editor and scanner are in their own respective files. (Ex: `gen.scanner.<hpp/cpp>` )
2023-07-24 10:44:19 -07:00
Dependencies are within `gen.dep.<hpp/cpp>`
2023-07-19 20:42:28 -07:00
2023-04-22 19:24:55 -07:00
## gen.hpp
2023-07-13 12:00:05 -07:00
Feature Macros:
2023-04-22 19:24:55 -07:00
2023-07-24 10:44:19 -07:00
* `GEN_DONT_USE_NAMESPACE` : By default, the library is wrapped in a `gen` namespace, this will disable that expose it to the global scope.
2023-07-18 21:14:15 -07:00
* `GEN_DONT_ENFORCE_GEN_TIME_GUARD` : By default, the library ( gen.hpp/ gen.cpp ) expects the macro `GEN_TIME` to be defined, this disables that.
2023-07-15 20:38:53 -07:00
* `GEN_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves.
2023-04-22 19:24:55 -07:00
* `GEN_DEFINE_LIBRARY_CORE_CONSTANTS` : Optional typename codes as they are non-standard to C/C++ and not necessary to library usage
2023-07-15 20:38:53 -07:00
* `GEN_ENFORCE_STRONG_CODE_TYPES` : Enforces casts to filtered code types.
2023-07-24 10:44:19 -07:00
* `GEN_EXPOSE_BACKEND` : Will expose symbols meant for internal use only.
* `GEN_Define_Attribute_Tokens` : Allows user to define their own attribute macros for use in parsing.
2023-04-22 19:24:55 -07:00
2023-07-19 20:42:28 -07:00
`GEN_USE_RECURSIVE_AST_DUPLICATION` is available but its not well tested and should not need to be used.
If constructing ASTs properly. There should be no modification of ASTs, and thus this would never become an issue.
2023-07-18 21:14:15 -07:00
(I will probably remove down the line...)
2023-07-16 00:26:07 -07:00
2023-07-18 21:14:15 -07:00
Due to the design of `gen.hpp` to support being written alongside runtime intended code (in the same file), all the code is wrapped in a `GEN_TIME` `#ifdef` and then wrapped further in a `gen` namespace to avoid pollution of the global scope.
2023-04-22 19:24:55 -07:00
2023-06-28 22:45:56 -07:00
*Note: Its possible with the scanner feature to support parsing runtime files that use "generic" macros or identifiers with certain patterns.
2023-04-22 19:24:55 -07:00
This can be used to auto-queue generation of dependent definitions for the symbols used.*
### Organization
2023-07-12 00:15:52 -07:00
Dependencies : Mostly from the c-zpl library.
2023-04-22 19:24:55 -07:00
log_failure definition : based on whether to always use fatal on all errors
Major enum definitions and their associated functions used with the AST data
* `ECode` : Used to tag ASTs by their type
2023-07-18 21:14:15 -07:00
* `EOperator` : Used to tag operator overloads with their op type
2023-06-28 22:37:42 -07:00
* `ESpecifier` : Used with specifier ASTs for all specifiers the user may tag an associated
AST with.
* `AccessSpec` : Used with class and struct ASTs to denote the public, protected, or private fields.
2023-07-13 20:01:20 -07:00
* `EnumT` : Used with def_enum to determine if constructing a regular enum or an enum class.
2023-07-18 21:14:15 -07:00
* `ModuleFlag` : Used with any valid definition that can have export or import related keywords associated with it.
2023-04-22 19:24:55 -07:00
#### Data Structures
2023-07-13 20:01:20 -07:00
`StringCache` : Hash table for cached strings. (`StringCached` typedef used to denote strings managed by it)
2023-04-22 19:24:55 -07:00
2023-07-15 20:38:53 -07:00
`Code` : Wrapper for `AST` with functionality for handling it appropriately.
2023-07-18 21:14:15 -07:00
`AST` : The node data structure for the code.
2023-07-15 20:38:53 -07:00
`Code Types` : Codes with typed ASTs. Body, Param, and Specifier have unique implementation, the rest use `Define_CodeType`
`AST Types` : Filtered AST definitions.
2023-04-22 19:24:55 -07:00
#### Gen Interface
2023-07-18 21:14:15 -07:00
First set of forwards are either backend functions used for various aspects of AST generation or configurations allocators used for different containers.
2023-04-22 19:24:55 -07:00
2023-07-18 21:14:15 -07:00
Interface forwards defined in order of: Upfront, Parsing, Untyped.
2023-04-22 19:24:55 -07:00
From there forwards for the File handlers are defined: Builder, Editor, Scanner.
#### Macros
General helper macros are defined along with the optional DSL macros.
#### Constants
Constants including optional ones are defined.
#### Inlines
Inlined functions related to the AST datatype that required forwards for gen interface functions are defined.
## gen.cpp
2023-07-12 00:15:52 -07:00
* Dependencies
2023-07-10 19:22:32 -07:00
* Static data
2023-06-28 22:37:42 -07:00
* AST Body case macros are next.
2023-07-10 19:22:32 -07:00
* AST implementation
2023-06-28 22:37:42 -07:00
* Gen interface begins with its `init` , `deinit` , etc.. Until `make_code_entires`
* operator__validate defined, which will be used to verify if an operator definition is constructible.
* Allocator interface for data arrays, code pool, code entries, string arenas, and string table.
* Helper macros used throughout the constructor API
* Upfront constructors, following the same order as shown in the header.
* Parsing constructors, it defines its own lexer, and has many helper functions for parsing not exposed through the header.
* Untyped constructors
* Builder
* Editor
* Scanner