33 Commits

Author SHA1 Message Date
Ed_
754bcfb31e Fixes to get it back to where I was last at with the const specifier issue 2023-09-25 16:42:29 -04:00
Ed_
a8708abf8b WIP : Various changes to project before small hiatus. (Broken)
I need to manually review these as the changes have various errors that are difficult to diagnose why.

I took a break to do handmade hero and now a bit rusty.
2023-09-25 12:12:11 -04:00
Ed_
4b48b96a79 WIP : better AST::debug_str()
Now its more contexually rich to the ast type, however I need to hookup tokens from parsing to the AST. There needs to be a way for the debug string to lookup the token and provide the contexual line.
Can either pass it ( TokArray* toks ) from the parser on failure (or `CodeFile`)..
Technically there is more than enough room for another Token* ptr. I could add another and specifiers would still have at minimum 14 slots before needing to extended to next specs.
**************... yeah
2023-09-12 02:32:44 -04:00
Ed_
9495fc2985 Updates to documentation 2023-09-11 18:34:37 -04:00
Ed_
378de73a7d Merge branch 'main' of https://github.com/Ed94/gencpp 2023-09-08 15:15:13 -04:00
Ed_
35ac0c1048 Fix compile-error for singleheader found with scanner's scan_file. 2023-09-08 15:14:43 -04:00
Ed_
2c893d5e35 Merge pull request #34 from Ed94/dev
Dev
2023-09-07 23:06:02 -04:00
Ed_
6ea40094ee More fixes from clang warnings. Parser::lex prep for changes
parse_static_assert now properly adds new-line to end of statement.

I'm going to end up making a static_assert ast... that or when the statement ast is made it will handle adding that newline.
2023-09-07 22:52:51 -04:00
Ed_
0a8d3bfc6a Added fixed arenas (just ergonomics) 2023-09-07 22:29:04 -04:00
Ed_
212b4e6d16 Fixes for compiling with clang
Clang just had better errors and caught stuff msvc did not.
2023-09-07 21:11:57 -04:00
Ed_
d606c790ca Added a new AST member NextVar to be used for comma separated variable support.
Interface adding has been adjusted to use ParentType->Next.

Using the AST_Class->Next was bad since that breaks the linked list a body AST would have used for traversal.
2023-09-06 03:06:30 -04:00
Ed_
2bfbef1d0c strip_formatting : Remove code thats no longer needed.
Its everyting related to stripping a function body.
2023-09-06 02:09:26 -04:00
Ed_
f1fb75cc1c Progress on strip_formatting function, support for multi-dimentional array variables and typenames.
strip_formatting suffers from some edge failure with what looks to be escaped character literals (not entirely sure).

I've decided to not remove formatting from unvalidated function bodies since I plan to support parsing its content properly.
However expression values for a statement will fail to have their formatting removed with this.

Since I don't plan to parse those anytime soon, I'll have to fix any edge cases for those at least..
2023-09-06 02:07:09 -04:00
Ed_
2200bcde9a Improved singleheader test
Need to make the debug_str provided by the AST type aware to provide as much contextual information as possible (finally got to this point with validation).

Singleheader test now directly calls clang-format to cleanup the reconstructed copy of the singleheader. Its needed to remove any sort of formatting discrepancies found by the parser since its sensistive to that for new-lines, etc.
2023-09-05 13:36:59 -04:00
Ed_
3e249d9bc5 Reorganization of parser, refactor of parse_type( bool* ) and progression of parser docs
Wanted to make parser implementation easier to sift through, so I emphasized alphabetical order more.

Since I couldn't just strip whitespace from typenames I decided to make the parse_type more aware of the typename's components if it was a function signature.
This ofc lead to the dark & damp hell that is parsing typenames.

Also made initial implementation to support parsing decltype within a typename signature..

The test failure for the singleheader is still a thing, these changes have not addressed that.
2023-09-05 01:48:11 -04:00
Ed_
3868e1e811 Added cursed typedef 2023-09-04 12:32:31 -04:00
Ed_
543427dfe5 Fixes to parsing for validation
Removed whitespace stripping from parse_type, prepped for doing some major changes for function signature typenames

Moved template argument parsing to its own helper function since its used in more the one spot.

Latest failure is due to stack overflow when validating parameters. (Shouldn't be hard to debug)
2023-09-03 23:36:51 -04:00
Ed_
f2d4ec96f0 Dumb fix for name check on parameters
Its now spitting out actual validation failures.
2023-09-03 20:34:27 -04:00
Ed_
1076818250 Got whitepace stripping properly working (AFAICT) for parse_define()
Made debug for viewing whitespace in AST::is_equal with String::visualize_whitespace()

Format stripping code is currently confined within parse_define()

I plan to move it to its own function soon, I just want to make sure its finalized first.

Other unvalidated content will need to have an extra check for preprocessed lines.
Example: Function bodies can have a #define <identifier> <definition>. I cannot strip the last <new line> as it will break the semantic importance to distinguish that line.
So it needs to be:
<content before> <new line>
<preprocessed line> <new line>
<content after>

In the content string that is minimally preserved
2023-09-03 20:29:49 -04:00
Ed_
c4c308c8ba Fixes for auxilary code + typo fix in ast.cpp
Needed the intellisense directive ifdef wrap.
2023-08-29 00:03:08 -04:00
Ed_
a4d9a63d71 Updated single-header based on last cs and also docs 2023-08-28 23:52:44 -04:00
Ed_
0197afd543 Changed how editor intellisense directives are handled for compoenents and dependencies
Didn't like the way I was processing them in scan_file.
2023-08-28 23:46:50 -04:00
Ed_
7249a7317d Added space stripping during for content of various ASTs
* Typedef/Typename
* Function Names
* Pragmas
* Attributes
2023-08-26 11:55:05 -04:00
Ed_
abf51e4aa9 Adjustment to AST::is_equal based on issues found with last CS.
Defined check_member_content, will spit out the strings if they aren't equivalent so the user can verify for themselves if its correct.
2023-08-25 18:57:53 -04:00
Ed_
9b6dc3cbd8 Work on AST::is_equal.
The NumEntries checks need to be deferred until the end as a final unresolved check on valdiation. As if there really is a discrepancy of entires it should be revealed by the specific entry failing.

Right now the latest failure with the single header check involves a define directive specifically the define does omit whitespace properly and so the check interprets the different cached content to be non-equivalent.

This will happen with all unvalidated aspects of the AST ( expressions, function bodies, etc )

There are two ways to resolve, either make an AST that can tokenize all items (not realistic), or I need to strip non-syntax important whitespace and then cache the string. This would mean removing everything but a single whitespace for all content within a content string. Otherwise, I would have to somehow make sure the content of the string has the exact formatting between both files for the definitions that matter.

AST types with this issue:
* Define Directive
* Pragma Directive
* Comment
* Execution
* Platform Attributes
* Untyped

Comments can technically be left unverified as they do not matter semantically.
When the serialization is first emitted, the content these strings should for the most part be equivalent. However I do see some possible failures for that if a different style of bracket placment is used (between the serialization).

At that point what I could do is just leave those unverified and just emit the content to the user as warning that the ast and the other compared could not be verified.

Those technically can be handled on a per-eye basis, and worst case the tests with the compiler will in the determine if any critical defintions are missing for the user.
2023-08-25 18:40:13 -04:00
Ed_
9edcbad907 Fixes to parsing marco content, progress on validation test (single-header) 2023-08-23 21:19:31 -04:00
Ed_
a6766cf0b1 Singleheader validation test got through ast reconstruction, failed to validate the reconstructed AST. 2023-08-23 18:16:45 -04:00
Ed_
8635b0fd1b doc update for parampack typename 2023-08-23 13:18:32 -04:00
Ed_
30eec99628 Changes to include usage, starting to attempt singleheader automated verification 2023-08-23 13:17:22 -04:00
Ed_
f9117a2353 Added zpl's ivrtual memory to dependencies (unused for now) 2023-08-23 11:07:43 -04:00
Ed_
c81f4b34ee Cleanup and doc updates 2023-08-23 02:17:47 -04:00
Ed_
c97762ac16 Added support for inline comments
Also now doing comment serialization on def_comment directly as parse_comment doesn't need it.

Essentially comment ast types serialize the same way s untyped and execution ASTs
2023-08-23 00:25:14 -04:00
Ed_
5e79e8ba65 Started to setup for codebase validation tests.
Fleshed out initial version of AST::is_equal( AST* )

Setup the test directory with initial files for each major validation test.
2023-08-22 16:01:50 -04:00
97 changed files with 5613 additions and 2170 deletions

6
.gitignore vendored
View File

@ -32,3 +32,9 @@ bld/
[Ll]og/
[Ll]ogs/
vc140.pdb
# Unreal
**/Unreal/*.h
**/Unreal/*.cpp
! **/Unreal/validate.unreal.cpp

View File

@ -10,8 +10,9 @@
"UNICODE",
"_UNICODE",
"GEN_TIME",
"GEN_IMPLEMENTATION"
"GEN_IMPLEMENTATION",
// "GEN_DONT_USE_NAMESPACE"
"GEN_INTELLISENSE_DIRECTIVES"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe",
@ -28,8 +29,9 @@
"UNICODE",
"_UNICODE",
"GEN_TIME",
"GEN_IMPLEMENTATION"
"GEN_IMPLEMENTATION",
// "GEN_DONT_USE_NAMESPACE"
"GEN_INTELLISENSE_DIRECTIVES"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Users/Ed/scoop/apps/llvm/current/bin/clang++.exe",

View File

@ -24,7 +24,11 @@
"filesystem": "cpp",
"format": "cpp",
"ratio": "cpp",
"xstring": "cpp"
"xstring": "cpp",
"functional": "cpp",
"vector": "cpp",
"list": "cpp",
"xhash": "cpp"
},
"C_Cpp.intelliSenseEngineFallback": "disabled",
"mesonbuild.configureOnOpen": true,

View File

@ -5,14 +5,17 @@ An attempt at simple staged metaprogramming for c/c++.
The library API is a composition of code element constructors.
These build up a code AST to then serialize with a file builder.
This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto),
its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain.
This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto).
Its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain.
## Notes
The project has reached an *alpha* state, all the current functionality works for the test cases but it will most likely break in many other cases.
This project is still in development (very much an alpha state), so expect bugs and missing features.
See [issues](https://github.com/Ed94/gencpp/issues) for a list of known bugs or todos.
A `natvis` and `natstepfilter` are provided in the scripts directory.
The library can already be used to generate code just fine, but the parser is where the most work is needed. If your C++ isn't "down to earth" expect issues.
A `natvis` and `natstepfilter` are provided in the scripts directory (its outdated, I'll update this readme when its not).
***The editor and scanner have not been implemented yet. The scanner will come first, then the editor.***
@ -123,7 +126,7 @@ struct ArrayHeader
```
**Note: The formatting shown here is not how it will look. For your desired formatting its recommended to run a pass through the files with an auto-formatter.**
*(The library currently uses clang-format for formatting, beaware its pretty slow...)*
*(The library currently uses clang-format for formatting, beware its pretty slow...)*
## Building

37
docs/AST_Design.md Normal file
View File

@ -0,0 +1,37 @@
# Forward
Was never satisfied with how I did the wrap of the management of the AST.
For C++, the current design may be as good as it gets for the limitations of the langauge.
I'll at least try in this issue to brainstorm something simpiler without losing ergonomics.
This will also be a good place to document the current design.
## Current Design
`AST` is the actual managed node object for the library.
Its raw and really not meant to be used directly.
All user interaction must be with its pointer so the type they deal with is `AST*`.
For user-facing code, they should never be giveen a nullptr. Instead, they should be given a designated `Invalid` AST node.
In order to abstract away constant use of `AST*`, I wanted to provide a wrapper for it.
The simpliest being just a type alias.
```cpp
using Code = AST*;
```
This is what the genc library would have to use due to its constraints of a langauge.
Anything else and it would either be an unergonomic mess of struct wrapping with a mess of macros & procedures to interface with it.
Further, to provide intuitive filters on the AST, there are AST types (covered in [AST_Types.md](AST_Types.md)).
These are pure PODS that just have the lay members relevant to the type of AST node they represent.
Each of them has a Code type alias specific to it.
Again, the simpliest case for these would be a type alias.
```cpp
using struct AST_Typedef CodeTypedef;
```

688
docs/AST_Types.md Normal file
View File

@ -0,0 +1,688 @@
# AST Types Documentation
While the Readme for docs covers the data layout per AST, this will focus on the AST types avaialble, and their nuances.
## Body
These are containers representing a scope body of a definition that can be of the following `ECode` type:
* Class_Body
* Enum_Body
* Export_Body
* Extern_Linkage_Body
* Function_Body
* Global_Body
* Namespace_Body
* Struct_Body
* Union_Body
Fields:
```cpp
Code Front;
Code Back;
Code Parent;
StringCached Name;
CodeT Type;
s32 NumEntries;
```
The `Front` member represents the start of the link list and `Back` the end.
NumEntries is the number of entries in the body.
Parent should have a compatible ECode type for the type of defintion used.
Serialization:
Will output only the entries, the braces are handled by the parent.
```cpp
<Front>...
<Back>
```
## Attributes
Represent standard or vendor specific C/C++ attributes.
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
<Content>
```
While the parser supports the `__declspec` and `__attribute__` syntax, the upfront constructor ( def_attributes ) must have the user specify the entire attribute, including the `[[]]`, `__declspec` or `__attribute__` parts.
## Comment
Stores a comment.
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
<Content>
```
The parser will perserve comments found if residing with a body or in accepted inline-to-definition locations.
Otherwise they will be skipped by the TokArray::__eat and TokArray::current( skip foramtting enabled ) functions.
The upfront constructor: `def_comment` expects to recieve a comment without the `//` or `/* */` parts. It will add them during construction.
## Class & Struct
Fields:
```cpp
CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes;
CodeType ParentType;
CodeBody Body;
CodeType Prev; // Used to store references to interfaces
CodeType Next; // Used to store references to interfaces
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
AccessSpec ParentAccess;
```
Serialization:
```cpp
// Class_Fwd
<ModuleFlags> <class/struct> <Name>; <InlineCmt>
// Class
<ModuleFlags> <class/struct> <Attributes> <Name> : <ParentAccess> <ParentType>, public <ParentType->Next>, ... <InlineCmt>
{
<Body>
};
```
You'll notice that only one parent type is supported only with parent access. This library only supports single inheritance, the rest must be done through interfaces.
## Constructor
Fields:
```cpp
CodeComment InlineCmt; // Only supported by forward declarations
Code InitializerList;
CodeParam Params;
Code Body;
Code Prev;
Code Next;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
// Constructor_Fwd
<Specs> <Parent->Name>( <Params> ); <InlineCmt>
// Constructor
<Specs> <Parent->Name>( <Params> ) <InlineCmt>
: <InitializerList>
{
<Body>
}
```
## Define
Represents a preprocessor define
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
#define <Name> <Content>
```
## Destructor
Fields:
```cpp
CodeComment InlineCmt;
CodeSpecifiers Specs;
Code Body;
Code Prev;
Code Next;
Code Parent;
CodeT Type;
```
Serialization:
```cpp
// Destructor_Fwd
<Specs> ~<Parent->Name>( <Params> ) <Specs>; <InlineCmt>
// Destructor
<Specs> ~<Parent->Name>( <Params> ) <Specs>
{
<Body>
}
```
## Enum
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeType UnderlyingType;
CodeBody Body;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
// Enum_Fwd
<ModuleFlags> enum class <Name> : <UnderlyingType>; <InlineCmt>
// Enum
<ModuleFlags> <enum or enum class> <Name> : <UnderlyingType>
{
<Body>
};
```
## Execution
Just represents an execution body. Equivalent to an untyped body.
Will be obsolute when function body parsing is implemented.
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
<Content>
```
## External Linkage
Fields:
```cpp
CodeBody Body;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
extern "<Name>"
{
<Body>
}
```
## Include
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
#include <Content>
```
## Friend
This library (until its necessary become some third-party library to do otherwise) does not support friend declarations with in-statment function definitions.
Fields:
```cpp
CodeComment InlineCmt;
Code Declaration;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
friend <Declaration>; <InlineCmt>
```
## Function
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ReturnType;
CodeParam Params;
CodeBody Body;
Code Prev;
Code Parent;
Code Next;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
// Function_Fwd
<ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>( <Params> ) <Specs>; <InlineCmt>
// Function
<ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>( <Params> ) <Specs>
{
<Body>
}
```
## Module
Fields:
```cpp
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags> module <Name>;
```
## Namespace
Fields:
```cpp
CodeBody Body;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags> namespace <Name>
{
<Body>
}
```
## Operator Overload
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ReturnType;
CodeParam Params;
CodeBody Body;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
OperatorT Op;
```
Serialization:
```cpp
// Operator_Fwd
<ModuleFlags> <Attributes> <Specs> <ReturnType> operator <Op>( <Params> ) <Specs>; <InlineCmt>
// Operator
<ModuleFlags> <Attributes> <Specs> <ReturnType> <Name>operator <Op>( <Params> ) <Specs>
{
<Body>
}
```
## Operator Cast Overload ( User-Defined Type Conversion )
Fields:
```cpp
CodeComment InlineCmt;
CodeSpecifiers Specs;
CodeType ValueType;
CodeBody Body;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
// Operator_Cast_Fwd
<Specs> operator <ValueType>() <Specs>; <InlineCmt>
// Operator_Cast
<Specs> <Name>operator <ValueType>() <Specs>
{
<Body>
}
```
## Parameters
Fields:
```cpp
CodeType ValueType;
Code Value;
CodeParam Last;
CodeParam Next;
Code Parent;
StringCached Name;
CodeT Type;
s32 NumEntries;
```
Serialization:
```cpp
<ValueType> <Name>, <Next>... <Last>
```
## Pragma
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
#pragma <Content>
```
## Preprocessor Conditional
Fields:
```cpp
StringCached Content;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
```
Serialization:
```cpp
#<based off Type> <Content>
```
## Specifiers
Fields:
```cpp
SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ];
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
s32 NumEntries;
```
Serialization:
```cpp
<Spec>, ...
```
## Template
Fields:
```cpp
CodeParam Params;
Code Declaration;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags>
template< <Params> >
<Declaration>
```
## Typename
Typenames represent the type "symbol".
Fields:
```cpp
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeReturnType ReturnType;
CodeParam Params;
Code ArrExpr;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
b32 IsParamPack;
```
Serialization:
```cpp
<Attributes> <Name> <Specs> <IsParamPack ?: ...>
```
## Typedef
Behave as usual except function or macro typedefs.
Those don't use the underlying type field as everything was serialized under the Name field.
Fields:
```cpp
CodeComment InlineCmt;
Code UnderlyingType;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
b32 IsFunction;
```
Serialization:
```cpp
// Regular
<ModuleFlags> typedef <UnderlyingType> <Name>; <InlineCmt>
// Functions
<ModuleFlags> typedef <Name>; <InlineCmt>
```
## Union
Fields:
```cpp
CodeAttributes Attributes;
CodeBody Body;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
<ModuleFlags> union <Attributes> <Name>
{
<Body>
}
```
## Using
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeType UnderlyingType;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
// Regular
<ModuleFlags> using <Attributes> <Name> = <UnderlyingType>; <InlineCmt>
// Namespace
<ModuleFlags> using namespace <Name>; <InlineCmt>
```
## Variable
Fields:
```cpp
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ValueType;
Code BitfieldSize;
Code Value;
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
```
Serialization:
```cpp
// Regular
<ModuleFlags> <Attributes> <Specs> <ValueType> <Name> = <Value>; <InlineCmt>
// Bitfield
<ModuleFlags> <Attributes> <Specs> <ValueType> <Name> : <BitfieldSize> = <Value>; <InlineCmt>
```

89
docs/Parser_Algo.md Normal file
View File

@ -0,0 +1,89 @@
# Parser's Algorithim
gencpp uses a hand-written recursive descent parser. Both the lexer and parser handle a full C/C++ file in a single pass.
## Notable implementation background
### Lexer
The lex procedure does the lexical pass of content provided as a `StrC` type.
The tokens are stored (for now) in `gen::Parser::Tokens`.
Fields:
```cpp
Array<Token> Arr;
s32 Idx;
```
What token types are supported can be found in [ETokType.csv](../project/enums/ETokType.csv) you can also find the token types in [ETokType.h](../project/components/gen/etoktype.cpp) , which is the generated enum from the csv file.
Tokens are defined with the struct `gen::Parser::Token`:
Fields:
```cpp
char const* Text;
sptr Length;
TokType Type;
s32 Line;
s32 Column;
bool IsAssign;
```
`IsAssign` is a flag that is set when the token is an assignment operator. Which is used for various purposes:
* Using statment assignment
* Parameter argument default value assignment
* Variable declaration initialization assignment
I plan to replace IsAssign with a general flags field and properly keep track of all operator types instead of abstracting it away to `ETokType::Operator`.
Traversing the tokens is done with the following interface macros:
| Macro | Description |
| --- | --- |
| `currtok_noskip` | Get the current token without skipping whitespace |
| `currtok` | Get the current token, skip any whitespace tokens |
| `prevtok` | Get the previous token (does not skip whitespace) |
| `nexttok` | Get the next token (does not skip whitespace) |
| `eat( Token Type )` | Check to see if the current token is of the given type, if so, advance Token's index to the next token |
| `left` | Get the number of tokens left in the token array |
| `check_noskip` | Check to see if the current token is of the given type, without skipping whitespace |
| `check` | Check to see if the current token is of the given type, skip any whitespace tokens |
### Parser
The parser has a limited user interface, only specific types of definitions or statements are expected to be provided by the user directly when using to construct an AST dynamically (See SOA for example). It however does attempt to provide capability to parse a full C/C++ from production codebases.
Each public user interface procedure has the following format:
```cpp
CodeStruct parse_<definition type>( StrC def )
{
check_parse_args( def );
using namespace Parser;
TokArray toks = lex( def );
if ( toks.Arr == nullptr )
return CodeInvalid;
// Parse the tokens and return a constructed AST using internal procedures
...
}
```
The most top-level parsing procedure used for C/C++ file parsing is `parse_global_body`:
It uses a helper procedure called `parse_global_nspace`.
Each internal procedure will be
## parse_global_nspace
1. Make sure the type provided to the helper function is a `Namespace_Body`, `Global_Body`, `Export_Body`, `Extern_Linkage_body`.
2. If its not a `Global_Body` eat the opening brace for the scope.
3.
## parse_type

View File

@ -1,9 +1,12 @@
# Parsing
The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST.
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) under 5000 loc.
The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST.
The parsing implementation supports the following for the user:
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around 5500 loc. I hope to keep it under 10k loc worst case.
You can think of this parser of a frontend parser vs a semantic parser. Its intuitively similar to WYSIWYG. What you precerive as the syntax from the user-side before the compiler gets a hold of it, is what you get.
User exposed interface:
```cpp
CodeClass parse_class ( StrC class_def );
@ -27,10 +30,12 @@ CodeUsing parse_using ( StrC using_def );
CodeVar parse_variable ( StrC var_def );
```
To parse file buffers, use the `parse_global_body` function.
***Parsing will aggregate any tokens within a function body or expression statement to an untyped Code AST.***
Everything is done in one pass for both the preprocessor directives and the rest of the language.
The parser performs no macro expansion as the scope of gencpp feature-set is to only support the preprocessor for the goal of having rudimentary awareness of preprocessor ***conditionals***, ***defines***, and ***includes***, and ***pragmas***.
The parser performs no macro expansion as the scope of gencpp feature-set is to only support the preprocessor for the goal of having rudimentary awareness of preprocessor ***conditionals***, ***defines***, ***includes***, and ***pragmas***.
The keywords supported for the preprocessor are:
@ -51,10 +56,17 @@ Any preprocessor definition abuse that changes the syntax of the core language i
Exceptions:
* function signatures are allowed for a preprocessed macro: `neverinline MACRO() { ... }`
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_FUNCTION_SIGNATURES`
* typedefs allow for a preprocessed macro: `typedef MACRO();`
* Disable with: `#define GEN_PARSER_DISABLE_MACRO_TYPEDEF`
*(Exceptions are added on an on-demand basis)*
*(See functions `parse_operator_function_or_variable` and `parse_typedef` )*
Adding your own exceptions is possible by simply modifying the parser to allow for the syntax you need.
*Note: You could interpret this strictness as a feature. This would allow the user to see if their codebase or a third-party's codebase some some egregious preprocessor abuse.*
The lexing and parsing takes shortcuts from whats expected in the standard.
* Numeric literals are not checked for validity.
@ -64,8 +76,6 @@ The lexing and parsing takes shortcuts from whats expected in the standard.
* Assumed to *come before specifiers* (`const`, `constexpr`, `extern`, `static`, etc) for a function
* Or in the usual spot for class, structs, (*right after the declaration keyword*)
* typedefs have attributes with the type (`parse_type`)
* As a general rule; if its not available from the upfront constructors, its not available in the parsing constructors.
* *Upfront constructors are not necessarily used in the parsing constructors, this is just a good metric to know what can be parsed.*
* Parsing attributes can be extended to support user defined macros by defining `GEN_DEFINE_ATTRIBUTE_TOKENS` (see `gen.hpp` for the formatting)
Empty lines used throughout the file are preserved for formatting purposes during ast serialization.

View File

@ -32,7 +32,7 @@ Two generic templated containers are used throughout the library:
* `template< class Type> struct Array`
* `template< class Type> struct HashTable`
Both Code and AST definitions have a `template< class Type> Code/AST cast()`. Its just an alternative way to explicitly cast to each other.
Both Code and AST definitions have a `template< class Type> Code/AST :: cast()`. Its just an alternative way to explicitly cast to each other.
`template< class Type> swap( Type& a, Type& b)` is used over a macro.
@ -42,6 +42,7 @@ Otherwise the library is free of any templates.
**There is no support for validating expressions.**
Its difficult to parse without enough benefits (At the metaprogramming level).
I plan to add this only at the tail of the project parsing milestone.
**Only trivial template support is provided.**
The intention is for only simple, non-recursive substitution.
@ -70,28 +71,36 @@ Data layout of AST struct:
union {
struct
{
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
AST* Specs; // Function, Operator, Type symbol, Variable
AST* Specs; // Destructor, Function, Operator, Typename, Variable
union {
AST* InitializerList; // Constructor, Destructor
AST* ParentType; // Class, Struct
AST* ReturnType; // Function, Operator
AST* InitializerList; // Constructor
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
AST* ReturnType; // Function, Operator, Typename
AST* UnderlyingType; // Enum, Typedef
AST* ValueType; // Parameter, Variable
};
union {
AST* BitfieldSize; // Varaiable (Class/Struct Data Member)
AST* Params; // Function, Operator, Template
AST* BitfieldSize; // Variable (Class/Struct Data Member)
AST* Params; // Constructor, Function, Operator, Template, Typename
};
union {
AST* ArrExpr; // Type Symbol
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
AST* Declaration; // Friend, Template
AST* Value; // Parameter, Variable
AST* ArrExpr; // Typename
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
AST* Declaration; // Friend, Template
AST* Value; // Parameter, Variable
};
union {
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature.
};
};
StringCached Content; // Attributes, Comment, Execution, Include
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
StringCached Content; // Attributes, Comment, Execution, Include
struct {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers
};
};
union {
AST* Prev;
@ -107,11 +116,13 @@ StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
union {
b32 IsFunction; // Used by typedef to not serialize the name field.
b32 IsFunction; // Used by typedef to not serialize the name field.
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
OperatorT Op;
AccessSpec ParentAccess;
s32 NumEntries;
};
s32 Token; // Handle to the token, stored in the CodeFile (Otherwise unretrivable)
```
*`CodeT` is a typedef for `ECode::Type` which has an underlying type of `u32`*
@ -142,6 +153,13 @@ Data Notes:
* The allocator definitions used are exposed to the user incase they want to dictate memory usage
* You'll find the memory handling in `init`, `deinit`, `reset`, `gen_string_allocator`, `get_cached_string`, `make_code`.
* Allocators are defined with the `AllocatorInfo` structure found in `dependencies\memory.hpp`
* Most of the work is just defining the allocation procedure:
```cpp
void* ( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags );
```
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.
* Both AST and Code have member symbols but their data layout is enforced to be POD types.
* This library treats memory failures as fatal.
@ -233,6 +251,7 @@ Interface :``
* def_operator_cast
* def_param
* def_params
* def_pragma
* def_preprocess_cond
* def_specifier
* def_specifiers
@ -382,8 +401,8 @@ The following are provided predefined by the library as they are commonly used:
* `module_global_fragment`
* `module_private_fragment`
* `fmt_newline`
* `pragma_once`
* `param_varaidc` (Used for varadic definitions)
* `pragma_once`
* `preprocess_else`
* `preprocess_endif`
* `spec_const`
@ -392,6 +411,7 @@ The following are provided predefined by the library as they are commonly used:
* `spec_constinit`
* `spec_extern_linkage` (extern)
* `spec_final`
* `spec_forceinline`
* `spec_global` (global macro)
* `spec_inline`
* `spec_internal_linkage` (internal macro)
@ -429,8 +449,8 @@ Optionally the following may be defined if `GEN_DEFINE_LIBRARY_CODE_CONSTANTS` i
* `t_u16`
* `t_u32`
* `t_u64`
* `t_sw`
* `t_uw`
* `t_sw` (ssize_t)
* `t_uw` (size_t)
* `t_f32`
* `t_f64`
@ -458,50 +478,10 @@ Editor and Scanner are disabled by default, use `GEN_FEATURE_EDITOR` and `GEN_FE
### Builder is a similar object to the jai language's string_builder
* The purpose of it is to generate a file.
* A file is specified and opened for writing using the open( file_path) ) function.
* A file is specified and opened for writing using the open( file_path) function.
* The code is provided via print( code ) function will be serialized to its buffer.
* When all serialization is finished, use the write() command to write the buffer to the file.
### Editor is for editing a series of files/asts based on a set of requests provided to it
### Scanner Auxillary Interface
**Note: Not implemented yet**
* The purpose is to overrite a specific file, it places its contents in a buffer to scan.
* If editing an AST it will generate a new ast as a result (ASTs are not edited).
* Requests are populated using the following interface:
* add : Add code.
* remove : Remove code.
* replace: Replace code.
All three have the same parameters with exception to remove which only has SymbolInfo and Policy:
* SymbolInfo:
* File : The file the symbol resides in. Leave null to indicate to search all files. Leave null to indicated all-file search.
* Marker : #define symbol that indicates a location or following signature is valid to manipulate. Leave null to indicate the signature should only be used.
* Signature : Use a Code symbol to find a valid location to manipulate, can be further filtered with the marker. Leave null to indicate the marker should only be used.
* Policy : Additional policy info for completing the request (empty for now)
* Code : Code to inject if adding, or replace existing code with.
Additionally if `GEN_FEATURE_EDITOR_REFACTOR` is defined, refactor( file_path, specification_path ) wil be made available.
Refactor is based of the refactor library and uses its interface.
It will on call add a request to the queue to run the refactor script on the file.
### Scanner allows the user to sift through a series of files/asts based on a set of requests provided to it
**Note: Not implemented yet**
* The purpose is to grab definitions to generate metadata or generate new code from these definitions.
* Requests are populated using the add( SymbolInfo, Policy ) function. The symbol info is the same as the one used for the editor. So is the case with Policy.
The file will only be read from, no writing supported.
### Additional Info (Editor and Scanner)
When all requests have been populated, call process_requests().
It will provide an output of receipt data of the results when it completes.
Files may be added to the Editor and Scanner additionally with add_files( num, files ).
This is intended for when you have requests that are for multiple files.
Request queue in both Editor and Scanner are cleared once process_requests completes.
Provides *(eventually)* `scan_file` to automatically populate a CodeFile which contains a parsed AST (`Code`) of the file, with any contextual failures that are reported from the parser.

View File

@ -8,21 +8,22 @@
<ShowEmptyFolders>true</ShowEmptyFolders>
<IsVirtual>false</IsVirtual>
<IsFolder>false</IsFolder>
<BuildCommand>powershell ./scripts/test.gen_run.ps1</BuildCommand>
<BuildCommand>pwsh ./scripts/build.ps1 msvc debug bootstrap</BuildCommand>
<RebuildCommand></RebuildCommand>
<BuildFileCommand></BuildFileCommand>
<CleanCommand>powershell ./scripts/clean.ps1</CleanCommand>
<CleanCommand>psh ./scripts/clean.ps1</CleanCommand>
<BuildWorkingDirectory></BuildWorkingDirectory>
<CancelBuild></CancelBuild>
<RunCommand>./test/gen/build/gencpp.exe</RunCommand>
<RunCommandWorkingDirectory></RunCommandWorkingDirectory>
<DebugCommand>powershell ./scripts/build.ps1</DebugCommand>
<DebugCommand>pwsh ./scripts/build.ps1</DebugCommand>
<ExePathCommand>./test/gen/build/gencpp.exe</ExePathCommand>
<DebugSln>gencpp.sln</DebugSln>
<UseVisualStudioEnvBat>false</UseVisualStudioEnvBat>
<DebugSln></DebugSln>
<UseVisualStudioEnvBat>true</UseVisualStudioEnvBat>
<Configurations>
<Configuration>Debug</Configuration>
<Configuration>Release</Configuration>
<Configuration>bootstrap debug</Configuration>
</Configurations>
<Platforms>
<Platform>x64</Platform>
@ -31,15 +32,17 @@
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\include</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\ATLMFC\include</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\VS\include</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um</AdditionalIncludePath>
</AdditionalIncludePaths>
<Defines>
<Define>GEN_TIME</Define>
<Define>GEN_SYSTEM_WINDOWS</Define>
<Define>GEN_INTELLISENSE_DIRECTIVES</Define>
</Defines>
<ConfigProperties>
<ConfigAndPlatform>
@ -47,10 +50,19 @@
<Defines></Defines>
<ForceIncludes></ForceIncludes>
</ConfigAndPlatform>
<ConfigAndPlatform>
<Name>bootstrap debug:x64</Name>
<Defines></Defines>
<ForceIncludes></ForceIncludes>
</ConfigAndPlatform>
<Config>
<Name>Debug</Name>
<Defines></Defines>
</Config>
<Config>
<Name>bootstrap debug</Name>
<Defines></Defines>
</Config>
<Platform>
<Name>x64</Name>
<Defines></Defines>

View File

@ -7,20 +7,37 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencpp", "gencpp.vcxproj",
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
bootstrap debug|x64 = bootstrap debug|x64
bootstrap debug|x86 = bootstrap debug|x86
bootstrap release|x64 = bootstrap release|x64
bootstrap release|x86 = bootstrap release|x86
singleheader debug|x64 = singleheader debug|x64
singleheader debug|x86 = singleheader debug|x86
singleheader release|x64 = singleheader release|x64
singleheader release|x86 = singleheader release|x86
test debug|x64 = test debug|x64
test debug|x86 = test debug|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x64.ActiveCfg = Debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x64.Build.0 = Debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x86.ActiveCfg = Debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x86.Build.0 = Debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x64.ActiveCfg = Release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x64.Build.0 = Release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x86.ActiveCfg = Release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x86.Build.0 = Release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.ActiveCfg = bootstrap release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.Build.0 = bootstrap release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.ActiveCfg = bootstrap debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.Build.0 = bootstrap debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x64.ActiveCfg = bootstrap release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.ActiveCfg = bootstrap release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.Build.0 = bootstrap release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.ActiveCfg = singleheader debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.Build.0 = singleheader debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.ActiveCfg = singleheader debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.Build.0 = singleheader debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.ActiveCfg = bootstrap debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.Build.0 = bootstrap debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.ActiveCfg = singleheader release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.Build.0 = singleheader release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.ActiveCfg = test debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.Build.0 = test debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.ActiveCfg = test debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.Build.0 = test debug|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,20 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<ProjectConfiguration Include="bootstrap debug|Win32">
<Configuration>bootstrap debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<ProjectConfiguration Include="bootstrap debug|x64">
<Configuration>bootstrap debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<ProjectConfiguration Include="bootstrap release|Win32">
<Configuration>bootstrap release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="bootstrap release|x64">
<Configuration>bootstrap release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader debug|Win32">
<Configuration>singleheader debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader debug|x64">
<Configuration>singleheader debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader release|Win32">
<Configuration>singleheader release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader release|x64">
<Configuration>singleheader release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="test debug|Win32">
<Configuration>test debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="test debug|x64">
<Configuration>test debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
@ -25,24 +49,54 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -50,61 +104,145 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)thirdparty;$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(ProjectDir)test;$(SourcePath)</SourcePath>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)thirdparty;$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(ProjectDir)test;$(SourcePath)</SourcePath>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug bootstrap</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug test</NMakeBuildCommandLine>
<NMakeReBuildCommandLine />
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug singleheader</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release singleheader</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release bootstrap</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;GEN_BENCHMARK;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include=".editorconfig" />
<None Include="project\components\temp\Readme.md" />
<None Include="project\enums\AttributeTokens.csv" />
<None Include="project\enums\ECode.csv" />
<None Include="project\enums\EOperator.csv" />
<None Include="project\enums\ESpecifier.csv" />
<None Include="project\enums\ETokType.csv" />
<None Include="Readme.md" />
<None Include="scripts\.clang-format" />
<None Include="scripts\build.ci.ps1" />
<None Include="scripts\build.ps1" />
<None Include="scripts\clean.ps1" />
@ -124,14 +262,14 @@
<ClInclude Include="project\auxillary\scanner.hpp" />
<ClInclude Include="project\components\ast.hpp" />
<ClInclude Include="project\components\ast_types.hpp" />
<ClInclude Include="project\components\gen\ast_inlines.hpp" />
<ClInclude Include="project\components\gen\ecode.hpp" />
<ClInclude Include="project\components\gen\eoperator.hpp" />
<ClInclude Include="project\components\gen\especifier.hpp" />
<ClInclude Include="project\components\header_end.hpp" />
<ClInclude Include="project\components\header_start.hpp" />
<ClInclude Include="project\components\inlines.hpp" />
<ClInclude Include="project\components\interface.hpp" />
<ClInclude Include="project\components\temp\ast_inlines.hpp" />
<ClInclude Include="project\components\temp\ecode.hpp" />
<ClInclude Include="project\components\temp\eoperator.hpp" />
<ClInclude Include="project\components\temp\especifier.hpp" />
<ClInclude Include="project\components\types.hpp" />
<ClInclude Include="project\dependencies\basic_types.hpp" />
<ClInclude Include="project\dependencies\containers.hpp" />
@ -153,6 +291,7 @@
<ClInclude Include="project\helpers\push_ignores.inline.hpp" />
<ClInclude Include="project\helpers\undef.macros.hpp" />
<ClInclude Include="singleheader\components\header_start.hpp" />
<ClInclude Include="test\CURSED_TYPEDEF.h" />
<ClInclude Include="test\DummyInclude.hpp" />
<ClInclude Include="test\Parsed\Buffer.Parsed.hpp" />
<ClInclude Include="test\Parsed\HashTable.Parsed.hpp" />
@ -174,14 +313,13 @@
<ClCompile Include="project\bootstrap.cpp" />
<ClCompile Include="project\components\ast.cpp" />
<ClCompile Include="project\components\ast_case_macros.cpp" />
<ClCompile Include="project\components\gen\etoktype.cpp" />
<ClCompile Include="project\components\interface.cpp" />
<ClCompile Include="project\components\interface.parsing.cpp" />
<ClCompile Include="project\components\interface.untyped.cpp" />
<ClCompile Include="project\components\interface.upfront.cpp" />
<ClCompile Include="project\components\src_start.cpp" />
<ClCompile Include="project\components\static_data.cpp" />
<ClCompile Include="project\components\temp\etoktype.cpp" />
<ClCompile Include="project\components\untyped.cpp" />
<ClCompile Include="project\dependencies\debug.cpp" />
<ClCompile Include="project\dependencies\filesystem.cpp" />
<ClCompile Include="project\dependencies\hashing.cpp" />

View File

@ -129,6 +129,9 @@
<ClCompile Include="project\components\interface.untyped.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="project\components\gen\etoktype.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="project\gen.hpp">
@ -275,6 +278,21 @@
<ClInclude Include="singleheader\components\header_start.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\ast_inlines.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\ecode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\eoperator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\especifier.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="test\CURSED_TYPEDEF.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
@ -297,6 +315,7 @@
<None Include="scripts\helpers\target_arch.psm1" />
<None Include="scripts\package_release.ps1" />
<None Include="scripts\refactor.ps1" />
<None Include="scripts\.clang-format" />
</ItemGroup>
<ItemGroup>
<Natvis Include=".vscode\gencpp.natvis" />

View File

@ -3,14 +3,29 @@
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>C:\projects\gencpp\test\gen\build\gencpp.exe</LocalDebuggerCommand>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>C:\projects\gencpp\test\gen\build\gencpp.exe</LocalDebuggerCommand>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
</Project>

View File

@ -8,8 +8,7 @@ They contain includes for its various components: `components/<component_name>.<
Dependencies are bundled into `gen.dep.<hpp/cpp>`.
Just like the `gen.<hpp/cpp>` they include their components: `dependencies/<dependency_name>.<hpp/cpp>`
The fle processors are in their own respective files. (Ex: `file_processors/<file_processor>.<hpp/cpp>` )
They directly include `depedencies/file_handling.<hpp/cpp>` as the core library does not include file processing by defualt.
Code not making up the core library is located in `auxiliary/<auxiliary_name>.<hpp/cpp>`. These are optional extensions or tools for the library.
**TODO : Right now the library is not finished, as such the first self-hosting iteration is still WIP**
Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.
@ -30,10 +29,11 @@ Feature Macros:
* `GEN_ENFORCE_STRONG_CODE_TYPES` : Enforces casts to filtered code types.
* `GEN_EXPOSE_BACKEND` : Will expose symbols meant for internal use only.
* `GEN_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves.
* `GEN_DONT_ALLOW_INVALID_CODE` (Not implemented yet) : Will fail when an invalid code is constructed, parsed, or serialized.
## On multi-threading
Currently unsupported.
Currently unsupported. I want the library to be *stable* and *correct*, with the addition of exhausting all basic single-threaded optimizations before I consider multi-threading.
## Extending the library
@ -51,5 +51,10 @@ Names or Content fields are interned strings and thus showed be cached using `ge
`def_operator` is the most sophisticated constructor as it has multiple permutations of definitions that could be created that are not trivial to determine if valid.
The library has its code segmented into component files, use it to help create a derived version without needing to have to rewrite a generated file directly or build on top of the header via composition or inheritance.
When the scanner is implemented, this will be even easier to customize.
The parser is documented under `docs/Parsing.md` and `docs/Parser_Algo.md`.
## A note on compilation and runtime generation speed
The library is designed to be fast to compile and generate code at runtime as fast as resonable possible on a debug build.
Its recommended that your metaprogam be compiled using a single translation unit (unity build).

View File

@ -1,4 +1,6 @@
#include "builder.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# include "builder.hpp"
#endif
Builder Builder::open( char const* path )
{
@ -26,8 +28,7 @@ void Builder::pad_lines( s32 num )
void Builder::print( Code code )
{
String str = code->to_string();
const sw len = str.length();
// const sw len = str.length();
// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data );
Buffer.append( str );
}

View File

@ -1,5 +1,7 @@
#pragma once
#include "gen.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "gen.hpp"
#endif
struct Builder
{

View File

@ -1,67 +0,0 @@
#pragma once
#include "gen.scanner.hpp"
struct Policy
{
// Nothing for now.
};
enum class SymbolType : u32
{
Code,
Line,
Marker
};
struct Editor
{
enum RequestType : u32
{
Add,
Replace,
Remove
};
struct SymbolData
{
Policy Policy;
SymbolInfo Info;
};
struct RequestEntry
{
union {
SymbolData Symbol;
String Specification;
};
RequestType Type;
};
struct Receipt
{
StringCached File;
Code Found;
Code Written;
bool Result;
};
static AllocatorInfo Allocator;
static void set_allocator( AllocatorInfo allocator );
Array<FileInfo> Files;
String Buffer;
Array<RequestEntry> Requests;
void add_files( s32 num, char const** files );
void add ( SymbolInfo definition, Policy policy, Code to_inject );
void remove ( SymbolInfo definition, Policy policy );
void replace( SymbolInfo definition, Policy policy, Code to_replace);
# ifdef GEN_FEATURE_EDITOR_REFACTOR
void refactor( char const* file_path, char const* specification_path );
# endif
bool process_requests( Array<Receipt> out_receipts );
};

View File

@ -1,10 +1,12 @@
#pragma once
#include "gen.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "gen.hpp"
#endif
// 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, bool skip_initial_directives = true )
Code scan_file( char const* path )
{
FileInfo file;
@ -24,63 +26,92 @@ Code scan_file( char const* path, bool skip_initial_directives = true )
file_read( & file, str, fsize );
str.get_header().Length = fsize;
if ( skip_initial_directives )
// Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks
// Its designed so that the directive should be the first thing in the file.
// Anything that comes before it will also be omitted.
{
#define current (*scanner)
StrC toks[] {
txt( "pragma once" ),
txt( "include" )
};
#define matched 0
#define move_fwd() do { ++ scanner; -- left; } while (0)
const StrC directive_start = txt( "ifdef" );
const StrC directive_end = txt( "endif" );
const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" );
char* scanner = str;
while ( current != '\r' && current != '\n' )
bool found_directive = false;
char const* scanner = str.Data;
s32 left = fsize;
while ( left )
{
for ( StrC tok : toks )
// Processing directive.
if ( current == '#' )
{
if ( current == '#' )
{
++ scanner;
}
move_fwd();
while ( left && char_is_space( current ) )
move_fwd();
if ( strncmp( scanner, tok.Ptr, tok.Len ) == 0 )
if ( ! found_directive )
{
scanner += tok.Len;
while ( scanner < ( str.Data + str.length() ) && current != '\r' && current != '\n' )
if ( left && str_compare( scanner, directive_start.Ptr, directive_start.Len ) == matched )
{
++ scanner;
scanner += directive_start.Len;
left -= directive_start.Len;
while ( left && char_is_space( current ) )
move_fwd();
if ( left && str_compare( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched )
{
scanner += def_intellisense.Len;
left -= def_intellisense.Len;
found_directive = true;
}
}
// Skip the line
sptr skip_size = sptr( scanner - str.Data );
if ( (scanner + 2) >= ( str.Data + str.length() ) )
// Skip to end of line
while ( left && current != '\r' && current != '\n' )
move_fwd();
move_fwd();
if ( left && current == '\n' )
move_fwd();
continue;
}
if ( left && str_compare( scanner, directive_end.Ptr, directive_end.Len ) == matched )
{
scanner += directive_end.Len;
left -= directive_end.Len;
// Skip to end of line
while ( left && current != '\r' && current != '\n' )
move_fwd();
move_fwd();
if ( left && current == '\n' )
move_fwd();
// sptr skip_size = fsize - left;
if ( (scanner + 2) >= ( str.Data + fsize ) )
{
sptr new_length = sptr( str.get_header().Length ) - skip_size;
mem_move( str, scanner, new_length );
str.get_header().Length = new_length;
mem_move( str, scanner, left );
str.get_header().Length = left;
break;
}
if ( current == '\r' )
{
skip_size += 2;
scanner += 2;
}
else
{
skip_size += 1;
scanner += 1;
}
mem_move( str, scanner, left );
str.get_header().Length = left;
sptr new_length = sptr( str.get_header().Length ) - skip_size;
mem_move( str, scanner, new_length );
str.get_header().Length = new_length;
scanner = str;
break;
}
}
++ scanner;
move_fwd();
}
#undef move_fwd
#undef matched
#undef current
}
@ -89,45 +120,40 @@ Code scan_file( char const* path, bool skip_initial_directives = true )
}
#if 0
struct Policy
struct CodeFile
{
// Nothing for now.
using namespace Parser;
String FilePath;
TokArray Tokens;
Array<ParseFailure> ParseFailures;
Code CodeRoot;
};
struct SymbolInfo
namespace Parser
{
StringCached File;
char const* Marker;
Code Signature;
};
struct Scanner
{
struct RequestEntry
struct ParseFailure
{
SymbolInfo Info;
String Reason;
Code Node;
};
}
struct Receipt
{
StringCached File;
Code Defintion;
bool Result;
};
CodeFile scan_file( char const* path )
{
using namespace Parser;
AllocatorInfo MemAlloc;
CodeFile
result = {};
result.FilePath = String::make( GlobalAllocator, path );
static void set_allocator( AllocatorInfo allocator );
Code code = scan_file( path );
result.CodeRoot = code;
Array<FileInfo> Files;
String Buffer;
Array<RequestEntry> Requests;
ParseContext context = parser_get_last_context();
result.Tokens = context.Tokens;
result.ParseFailures = context.Failures;
void add_files( s32 num, char const** files );
void add( SymbolInfo signature, Policy policy );
bool process_requests( Array<Receipt> out_receipts );
};
return result;
}
#endif

View File

@ -17,21 +17,19 @@ GEN_NS_END
using namespace gen;
constexpr char const* generation_notice =
"// This file was generated automatially by gen.bootstrap.cpp "
"// This file was generated automatially by gencpp's bootstrap.cpp "
"(See: https://github.com/Ed94/gencpp)\n\n";
constexpr bool DontSkipInitialDirectives = false;
int gen_main()
{
gen::init();
Code push_ignores = scan_file( "helpers/push_ignores.inline.hpp", DontSkipInitialDirectives );
Code pop_ignores = scan_file( "helpers/pop_ignores.inline.hpp", DontSkipInitialDirectives );
Code push_ignores = scan_file( "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( "helpers/pop_ignores.inline.hpp" );
// gen_dep.hpp
{
Code header_start = scan_file( "dependencies/header_start.hpp", DontSkipInitialDirectives );
Code header_start = scan_file( "dependencies/header_start.hpp" );
Code macros = scan_file( "dependencies/macros.hpp" );
Code basic_types = scan_file( "dependencies/basic_types.hpp" );
Code debug = scan_file( "dependencies/debug.hpp" );
@ -99,6 +97,15 @@ int gen_main()
src.write();
}
CodeBody gen_component_header = def_global_body( args(
def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ),
pragma_once,
def_include(txt("components/types.hpp")),
preprocess_endif,
fmt_newline,
untyped_str( to_str(generation_notice) )
));
// gen.hpp
{
Code header_start = scan_file( "components/header_start.hpp" );
@ -149,29 +156,25 @@ int gen_main()
Builder
header_ecode = Builder::open( "components/gen/ecode.hpp" );
header_ecode.print( pragma_once );
header_ecode.print_fmt( generation_notice );
header_ecode.print( gen_component_header );
header_ecode.print( ecode );
header_ecode.write();
Builder
header_eoperator = Builder::open( "components/gen/eoperator.hpp" );
header_eoperator.print( pragma_once );
header_eoperator.print_fmt( generation_notice );
header_eoperator.print( gen_component_header );
header_eoperator.print( eoperator );
header_eoperator.write();
Builder
header_especifier = Builder::open( "components/gen/especifier.hpp" );
header_especifier.print( pragma_once );
header_especifier.print_fmt( generation_notice );
header_especifier.print( gen_component_header );
header_especifier.print( especifier );
header_especifier.write();
Builder
header_ast_inlines = Builder::open( "components/gen/ast_inlines.hpp" );
header_ast_inlines.print( pragma_once );
header_ast_inlines.print_fmt( generation_notice );
header_ast_inlines.print( gen_component_header );
header_ast_inlines.print( ast_inlines );
header_ast_inlines.write();
}
@ -220,8 +223,7 @@ int gen_main()
Builder
src_etoktype = Builder::open( "components/gen/etoktype.cpp" );
src_etoktype.print_fmt( generation_notice );
src_etoktype.print( pragma_once );
src_etoktype.print( gen_component_header );
src_etoktype.print( nspaced_etoktype );
src_etoktype.write();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,10 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "types.hpp"
#include "gen/ecode.hpp"
#include "gen/eoperator.hpp"
#include "gen/especifier.hpp"
#endif
struct AST;
struct AST_Body;
@ -39,10 +41,10 @@ struct CodeBody;
// These are to offer ease of use and optionally strong type safety for the AST.
struct CodeAttributes;
struct CodeComment;
struct CodeConstructor;
struct CodeDestructor;
struct CodeClass;
struct CodeConstructor;
struct CodeDefine;
struct CodeDestructor;
struct CodeEnum;
struct CodeExec;
struct CodeExtern;
@ -65,6 +67,11 @@ struct CodeUnion;
struct CodeUsing;
struct CodeVar;
namespace Parser
{
struct Token;
}
/*
AST* wrapper
- Not constantly have to append the '*' as this is written often..
@ -80,7 +87,7 @@ struct Code
static Code Invalid;
# pragma endregion Statics
#define Using_Code( Typename ) \
# define Using_Code( Typename ) \
char const* debug_str(); \
Code duplicate(); \
bool is_equal( Code other ); \
@ -106,7 +113,7 @@ struct Code
return ast;
}
Code& operator ++();
Code& operator*()
auto& operator*()
{
return *this;
}
@ -155,7 +162,7 @@ struct Code_POD
static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
// Desired width of the AST data structure.
constexpr u32 AST_POD_Size = 128;
constexpr int const AST_POD_Size = 128;
/*
Simple AST POD with functionality to seralize into C++ syntax.
@ -212,42 +219,52 @@ struct AST
# pragma endregion Member Functions
constexpr static
uw ArrSpecs_Cap =
int ArrSpecs_Cap =
(
AST_POD_Size
- sizeof(AST*) * 3
- sizeof(Parser::Token*)
- sizeof(AST*)
- sizeof(StringCached)
- sizeof(CodeT)
- sizeof(ModuleFlag)
- sizeof(u32)
- sizeof(int)
)
/ sizeof(SpecifierT) - 1; // -1 for 4 extra bytes
/ sizeof(int) - 1; // -1 for 4 extra bytes
union {
struct
{
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
AST* Specs; // Function, Operator, Type symbol, Variable
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
AST* Specs; // Destructor, Function, Operator, Typename, Variable
union {
AST* InitializerList; // Constructor, Destructor
AST* ParentType; // Class, Struct
AST* ReturnType; // Function, Operator
AST* InitializerList; // Constructor
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
AST* ReturnType; // Function, Operator, Typename
AST* UnderlyingType; // Enum, Typedef
AST* ValueType; // Parameter, Variable
};
union {
AST* BitfieldSize; // Varaiable (Class/Struct Data Member)
AST* Params; // Function, Operator, Template
AST* BitfieldSize; // Variable (Class/Struct Data Member)
AST* Params; // Constructor, Function, Operator, Template, Typename
};
union {
AST* ArrExpr; // Type Symbol
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
AST* Declaration; // Friend, Template
AST* Value; // Parameter, Variable
AST* ArrExpr; // Typename
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
AST* Declaration; // Friend, Template
AST* Value; // Parameter, Variable
};
union {
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
};
};
StringCached Content; // Attributes, Comment, Execution, Include
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
StringCached Content; // Attributes, Comment, Execution, Include
struct {
SpecifierT ArrSpecs[ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
};
};
union {
AST* Prev;
@ -258,12 +275,14 @@ struct AST
AST* Next;
AST* Back;
};
Parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
AST* Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
union {
b32 IsFunction; // Used by typedef to not serialize the name field.
b32 IsFunction; // Used by typedef to not serialize the name field.
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
OperatorT Op;
AccessSpec ParentAccess;
s32 NumEntries;
@ -275,28 +294,36 @@ struct AST_POD
union {
struct
{
AST* Attributes; // Class, Enum, Function, Struct, Typename, Union, Using, Variable
AST* Specs; // Function, Operator, Type symbol, Variable
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
AST* Specs; // Destructor, Function, Operator, Typename, Variable
union {
AST* InitializerList; // Constructor, Destructor
AST* ParentType; // Class, Struct
AST* ReturnType; // Function, Operator
AST* InitializerList; // Constructor
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
AST* ReturnType; // Function, Operator, Typename
AST* UnderlyingType; // Enum, Typedef
AST* ValueType; // Parameter, Variable
};
union {
AST* BitfieldSize; // Varaiable (Class/Struct Data Member)
AST* Params; // Function, Operator, Template
AST* BitfieldSize; // Variable (Class/Struct Data Member)
AST* Params; // Constructor, Function, Operator, Template, Typename
};
union {
AST* ArrExpr; // Type Symbol
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
AST* Declaration; // Friend, Template
AST* Value; // Parameter, Variable
AST* ArrExpr; // Typename
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
AST* Declaration; // Friend, Template
AST* Value; // Parameter, Variable
};
union {
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
};
};
StringCached Content; // Attributes, Comment, Execution, Include
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
StringCached Content; // Attributes, Comment, Execution, Include
struct {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
};
};
union {
AST* Prev;
@ -307,18 +334,27 @@ struct AST_POD
AST* Next;
AST* Back;
};
Parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
AST* Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
union {
b32 IsFunction; // Used by typedef to not serialize the name field.
b32 IsFunction; // Used by typedef to not serialize the name field.
b32 IsParamPack; // Used by typename to know if type should be considered a parameter pack.
OperatorT Op;
AccessSpec ParentAccess;
s32 NumEntries;
};
};
struct test {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
};
constexpr int pls = sizeof(test);
// Its intended for the AST to have equivalent size to its POD.
// All extra functionality within the AST namespace should just be syntatic sugar.
static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" );

View File

@ -1,5 +1,7 @@
#pragma once
#include "ast.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "ast.hpp"
#endif
#pragma region AST Types
/*
@ -10,25 +12,27 @@
struct AST_Body
{
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Front;
Code Back;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries;
};
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Filtered is not the same size as AST");
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST");
struct AST_Attributes
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -39,11 +43,12 @@ static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is
struct AST_Comment
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -54,18 +59,21 @@ static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not th
struct AST_Class
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt; // Only supported by forward declarations
CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ];
CodeType ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
CodeType Last;
CodeType Prev;
CodeType Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -77,32 +85,37 @@ static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the sa
struct AST_Constructor
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_PROPERTIES_ [ sizeof(AST*) * 3 ];
Code InitializerList;
CodeParam Params;
Code Body;
CodeComment InlineCmt; // Only supported by forward declarations
char _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ];
CodeSpecifiers Specs;
Code InitializerList;
CodeParam Params;
Code Body;
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
char _PAD_NAME_[ sizeof(StringCached) ];
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor is not the same size as AST");
struct AST_Define
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -113,19 +126,22 @@ static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the
struct AST_Destructor
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
char _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ];
CodeSpecifiers Specs;
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
Code Body;
char _PAD_PROPERTIES_3_ [ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
char _PAD_NAME_[ sizeof(StringCached) ];
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
};
@ -134,18 +150,21 @@ static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is
struct AST_Enum
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
CodeAttributes Attributes;
char _PAD_SPEC_ [ sizeof(AST*) ];
CodeType UnderlyingType;
char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -157,14 +176,12 @@ static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same
struct AST_Exec
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
struct
{
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
};
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -175,15 +192,17 @@ static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same
struct AST_Extern
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -194,11 +213,12 @@ static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the
struct AST_Include
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -209,15 +229,18 @@ static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not th
struct AST_Friend
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
Code Declaration;
CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
Code Declaration;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -228,19 +251,22 @@ static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the
struct AST_Fn
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ReturnType;
CodeParam Params;
CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
};
};
Code Prev;
Code Parent;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
@ -250,9 +276,10 @@ static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same siz
struct AST_Module
{
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -264,14 +291,16 @@ static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the
struct AST_NS
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct {
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -283,41 +312,47 @@ static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same siz
struct AST_Operator
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ReturnType;
CodeParam Params;
CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
OperatorT Op;
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
OperatorT Op;
};
static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not the same size as AST");
struct AST_OpCast
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) ];
CodeSpecifiers Specs;
CodeType ValueType;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
CodeBody Body;
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -328,17 +363,19 @@ static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the
struct AST_Param
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 2 ];
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
CodeType ValueType;
char _PAD_PROPERTIES_[ sizeof(AST*) ];
Code Value;
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
};
};
CodeParam Last;
CodeParam Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -350,11 +387,12 @@ static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the sa
struct AST_Pragma
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -365,11 +403,12 @@ static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the
struct AST_PreprocessCond
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content;
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -380,8 +419,10 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
struct AST_Specifiers
{
SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ];
CodeSpecifiers NextSpecs;
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -393,18 +434,21 @@ struct AST_Specifiers
struct AST_Struct
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ];
CodeType ParentType;
char _PAD_PARAMS_[ sizeof(AST*) ];
CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
CodeType Last;
CodeType Prev;
CodeType Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -416,16 +460,18 @@ static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the
struct AST_Template
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
CodeParam Params;
Code Declaration;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -437,37 +483,44 @@ static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not
struct AST_Type
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_INLINE_CMT_[ sizeof(AST*) ];
CodeAttributes Attributes;
CodeSpecifiers Specs;
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
CodeType ReturnType; // Only used for function signatures
CodeParam Params; // Only used for function signatures
Code ArrExpr;
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
b32 IsParamPack;
};
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
struct AST_Typedef
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
Code UnderlyingType;
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 2 ];
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -479,16 +532,19 @@ static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not th
struct AST_Union
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
char _PAD_INLINE_CMT_[ sizeof(AST*) ];
CodeAttributes Attributes;
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
CodeBody Body;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -500,17 +556,19 @@ static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the sa
struct AST_Using
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
CodeAttributes Attributes;
char _PAD_SPECS_ [ sizeof(AST*) ];
CodeType UnderlyingType;
char _PAD_PROPERTIES_[ sizeof(AST*) * 2 ];
char _PAD_PROPERTIES_[ sizeof(AST*) * 3 ];
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
@ -522,18 +580,21 @@ static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the sa
struct AST_Var
{
union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct
{
CodeComment InlineCmt;
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeType ValueType;
Code BitfieldSize;
Code Value;
CodeVar NextVar;
};
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#endif
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace ECode
{

View File

@ -1,6 +1,9 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#endif
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace EOperator
{

View File

@ -1,6 +1,9 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#endif
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace ESpecifier
{
@ -29,6 +32,7 @@ namespace ESpecifier
Virtual,
Const,
Final,
NoExceptions,
Override,
Pure,
NumSpecifiers
@ -65,6 +69,7 @@ namespace ESpecifier
{ sizeof( "virtual" ), "virtual" },
{ sizeof( "const" ), "const" },
{ sizeof( "final" ), "final" },
{ sizeof( "noexcept" ), "noexcept" },
{ sizeof( "override" ), "override" },
{ sizeof( "= 0" ), "= 0" },
};

View File

@ -1,6 +1,9 @@
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace Parser
{
@ -128,7 +131,7 @@ namespace Parser
{ sizeof( "]" ), "]" },
{ sizeof( "(" ), "(" },
{ sizeof( ")" ), ")" },
{ sizeof( "__comemnt__" ), "__comemnt__" },
{ sizeof( "__comment__" ), "__comment__" },
{ sizeof( "__comment_end__" ), "__comment_end__" },
{ sizeof( "__comment_start__" ), "__comment_start__" },
{ sizeof( "__character__" ), "__character__" },

View File

@ -1,6 +1,8 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "inlines.hpp"
#include "gen/ast_inlines.hpp"
#endif
#pragma region Constants
@ -84,6 +86,7 @@ extern CodeSpecifiers spec_internal_linkage;
extern CodeSpecifiers spec_local_persist;
extern CodeSpecifiers spec_mutable;
extern CodeSpecifiers spec_neverinline;
extern CodeSpecifiers spec_noexcept;
extern CodeSpecifiers spec_override;
extern CodeSpecifiers spec_ptr;
extern CodeSpecifiers spec_pure;

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "interface.hpp"
#endif
void AST::append( AST* other )
{
@ -25,43 +27,6 @@ void AST::append( AST* other )
NumEntries++;
}
char const* AST::debug_str()
{
if ( Parent )
{
char const* fmt = stringize(
\nType : %s
\nParent : %s %s
\nName : %s
);
// These should be used immediately in a log.
// Thus if its desired to keep the debug str
// for multiple calls to bprintf,
// allocate this to proper string.
return str_fmt_buf( fmt
, type_str()
, Parent->Name
, Parent->type_str()
, Name ? Name : ""
);
}
char const* fmt = stringize(
\nType : %s
\nName : %s
);
// These should be used immediately in a log.
// Thus if its desired to keep the debug str
// for multiple calls to bprintf,
// allocate this to proper string.
return str_fmt_buf( fmt
, type_str()
, Name ? Name : ""
);
}
Code& AST::entry( u32 idx )
{
AST** current = & Front;
@ -102,15 +67,21 @@ Code& Code::operator ++()
void CodeClass::add_interface( CodeType type )
{
if ( ! ast->Next )
CodeType possible_slot = ast->ParentType;
if ( possible_slot.ast )
{
ast->Next = type;
ast->Last = ast->Next;
return;
// Were adding an interface to parent type, so we need to make sure the parent type is public.
ast->ParentAccess = AccessSpec::Public;
// If your planning on adding a proper parent,
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
}
ast->Next->Next = type;
ast->Last = ast->Next->Next;
while ( possible_slot.ast != nullptr )
{
possible_slot.ast = (AST_Type*) possible_slot->Next.ast;
}
possible_slot.ast = type.ast;
}
void CodeParam::append( CodeParam other )
@ -164,14 +135,21 @@ CodeParam& CodeParam::operator ++()
void CodeStruct::add_interface( CodeType type )
{
if ( ! ast->Next )
CodeType possible_slot = ast->ParentType;
if ( possible_slot.ast )
{
ast->Next = type;
ast->Last = ast->Next;
// Were adding an interface to parent type, so we need to make sure the parent type is public.
ast->ParentAccess = AccessSpec::Public;
// If your planning on adding a proper parent,
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
}
ast->Next->Next = type;
ast->Last = ast->Next->Next;
while ( possible_slot.ast != nullptr )
{
possible_slot.ast = (AST_Type*) possible_slot->Next.ast;
}
possible_slot.ast = type.ast;
}
CodeBody def_body( CodeT type )

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "ast.cpp"
#endif
internal void init_parser();
internal void deinit_parser();
@ -201,6 +203,7 @@ void define_constants()
def_constant_spec( local_persist, ESpecifier::Local_Persist );
def_constant_spec( mutable, ESpecifier::Mutable );
def_constant_spec( neverinline, ESpecifier::NeverInline );
def_constant_spec( noexcept, ESpecifier::NoExceptions );
def_constant_spec( override, ESpecifier::Override );
def_constant_spec( ptr, ESpecifier::Ptr );
def_constant_spec( pure, ESpecifier::Pure )
@ -413,15 +416,18 @@ Code make_code()
}
Code result { rcast( AST*, alloc( * allocator, sizeof(AST) )) };
// mem_set( result.ast, 0, sizeof(AST) );
result->Type = ECode::Invalid;
result->Content = { nullptr };
result->Prev = { nullptr };
result->Next = { nullptr };
result->Parent = { nullptr };
result->Name = { nullptr };
result->Type = ECode::Invalid;
result->ModuleFlags = ModuleFlag::Invalid;
result->NumEntries = 0;
result->Content = { nullptr };
result->Prev = { nullptr };
result->Next = { nullptr };
result->Token = nullptr;
result->Parent = { nullptr };
result->Name = { nullptr };
result->Type = ECode::Invalid;
result->ModuleFlags = ModuleFlag::Invalid;
result->NumEntries = 0;
return result;
}

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "ast_types.hpp"
#endif
#pragma region Gen Interface
@ -68,7 +70,7 @@ CodeFn def_function( StrC name
, CodeSpecifiers specifiers = NoCode, CodeAttributes attributes = NoCode
, ModuleFlag mflags = ModuleFlag::None );
CodeInclude def_include ( StrC content );
CodeInclude def_include ( StrC content, bool foreign = false );
CodeModule def_module ( StrC name, ModuleFlag mflags = ModuleFlag::None );
CodeNS def_namespace( StrC name, Code body, ModuleFlag mflags = ModuleFlag::None );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "interface.parsing.cpp"
#endif
sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va )
{

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "interface.cpp"
#endif
#pragma region Upfront
@ -415,12 +417,42 @@ CodeComment def_comment( StrC content )
return CodeInvalid;
}
static char line[ MaxCommentLineLength ];
String cmt_formatted = String::make_reserve( GlobalAllocator, kilobytes(1) );
char const* end = content.Ptr + content.Len;
char const* scanner = content.Ptr;
s32 curr = 0;
do
{
char const* next = scanner;
s32 length = 0;
while ( next != end && scanner[ length ] != '\n' )
{
next = scanner + length;
length++;
}
length++;
str_copy( line, scanner, length );
cmt_formatted.append_fmt( "//%.*s", length, line );
mem_set( line, 0, MaxCommentLineLength );
scanner += length;
}
while ( scanner <= end );
if ( cmt_formatted.back() != '\n' )
cmt_formatted.append( "\n" );
Code
result = make_code();
result->Type = ECode::Comment;
result->Name = get_cached_string( content );
result->Name = get_cached_string( cmt_formatted );
result->Content = result->Name;
cmt_formatted.free();
return (CodeComment) result;
}
@ -820,7 +852,7 @@ CodeFn def_function( StrC name
return result;
}
CodeInclude def_include ( StrC path )
CodeInclude def_include( StrC path, bool foreign )
{
if ( path.Len <= 0 || path.Ptr == nullptr )
{
@ -828,10 +860,14 @@ CodeInclude def_include ( StrC path )
return CodeInvalid;
}
StrC content = foreign ?
to_str( str_fmt_buf( "<%.*s>", path.Len, path.Ptr ))
: to_str( str_fmt_buf( "\"%.*s\"", path.Len, path.Ptr ));
Code
result = make_code();
result->Type = ECode::Preprocess_Include;
result->Name = get_cached_string( path );
result->Name = get_cached_string( content );
result->Content = result->Name;
return (CodeInclude) result;

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "gen.hpp"
#endif
#pragma region StaticData
@ -56,6 +58,7 @@ global CodeSpecifiers spec_inline;
global CodeSpecifiers spec_internal_linkage;
global CodeSpecifiers spec_local_persist;
global CodeSpecifiers spec_mutable;
global CodeSpecifiers spec_noexcept;
global CodeSpecifiers spec_neverinline;
global CodeSpecifiers spec_override;
global CodeSpecifiers spec_ptr;

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "header_start.hpp"
#endif
using LogFailType = sw(*)(char const*, ...);
@ -39,6 +41,15 @@ char const* to_str( AccessSpec type )
return lookup[ (u32)type ];
}
enum CodeFlag : u32
{
FunctionType = bit(0),
ParamPack = bit(1),
Module_Export = bit(2),
Module_Import = bit(3),
};
// Used to indicate if enum definitoin is an enum class or regular enum.
enum class EnumT : u8
{
@ -54,12 +65,26 @@ enum class ModuleFlag : u32
None = 0,
Export = bit(0),
Import = bit(1),
// Private = bit(2),
Num_ModuleFlags,
Invalid,
};
StrC to_str( ModuleFlag flag )
{
local_persist
StrC lookup[ (u32)ModuleFlag::Num_ModuleFlags ] = {
{ sizeof("__none__"), "__none__" },
{ sizeof("export"), "export" },
{ sizeof("import"), "import" },
};
if ( flag > ModuleFlag::Import )
return { sizeof("invalid"), "invalid" };
return lookup[ (u32)flag ];
}
ModuleFlag operator|( ModuleFlag A, ModuleFlag B)
{
return (ModuleFlag)( (u32)A | (u32)B );

View File

@ -1,5 +1,7 @@
#pragma once
#include "macros.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "macros.hpp"
#endif
#pragma region Basic Types

View File

@ -1,5 +1,7 @@
#pragma once
#include "printing.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "printing.hpp"
#endif
#pragma region Containers

View File

@ -1,4 +1,9 @@
#pragma once
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "debug.hpp"
# include "basic_types.hpp"
# include "src_start.cpp"
#endif
#pragma region Debug

View File

@ -1,5 +1,7 @@
#pragma once
#include "basic_types.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "basic_types.hpp"
#endif
#pragma region Debug

View File

@ -1,5 +1,7 @@
#pragma once
#include "strings.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "strings.cpp"
#endif
#pragma region File Handling

View File

@ -1,5 +1,7 @@
#pragma once
#include "strings.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "strings.hpp"
#endif
#pragma region File Handling

View File

@ -1,5 +1,7 @@
#pragma once
#include "memory.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "memory.cpp"
#endif
#pragma region Hashing

View File

@ -1,5 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "containers.hpp"
#endif
#pragma region Hashing

View File

@ -1,5 +1,7 @@
#pragma once
#include "header_start.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "header_start.hpp"
#endif
#pragma region Macros

View File

@ -1,5 +1,7 @@
#pragma once
#include "printing.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "printing.cpp"
#endif
#pragma region Memory
@ -206,6 +208,132 @@ void* heap_allocator_proc( void* allocator_data, AllocType type, sw size, sw ali
return ptr;
}
#pragma region VirtualMemory
VirtualMemory vm_from_memory( void* data, sw size )
{
VirtualMemory vm;
vm.data = data;
vm.size = size;
return vm;
}
#if defined( GEN_SYSTEM_WINDOWS )
VirtualMemory vm_alloc( void* addr, sw size )
{
VirtualMemory vm;
GEN_ASSERT( size > 0 );
vm.data = VirtualAlloc( addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
vm.size = size;
return vm;
}
b32 vm_free( VirtualMemory vm )
{
MEMORY_BASIC_INFORMATION info;
while ( vm.size > 0 )
{
if ( VirtualQuery( vm.data, &info, size_of( info ) ) == 0 )
return false;
if ( info.BaseAddress != vm.data || info.AllocationBase != vm.data || info.State != MEM_COMMIT || info.RegionSize > zpl_cast( uw ) vm.size )
{
return false;
}
if ( VirtualFree( vm.data, 0, MEM_RELEASE ) == 0 )
return false;
vm.data = pointer_add( vm.data, info.RegionSize );
vm.size -= info.RegionSize;
}
return true;
}
VirtualMemory vm_trim( VirtualMemory vm, sw lead_size, sw size )
{
VirtualMemory new_vm = { 0 };
void* ptr;
GEN_ASSERT( vm.size >= lead_size + size );
ptr = pointer_add( vm.data, lead_size );
vm_free( vm );
new_vm = vm_alloc( ptr, size );
if ( new_vm.data == ptr )
return new_vm;
if ( new_vm.data )
vm_free( new_vm );
return new_vm;
}
b32 vm_purge( VirtualMemory vm )
{
VirtualAlloc( vm.data, vm.size, MEM_RESET, PAGE_READWRITE );
// NOTE: Can this really fail?
return true;
}
sw virtual_memory_page_size( sw* alignment_out )
{
SYSTEM_INFO info;
GetSystemInfo( &info );
if ( alignment_out )
*alignment_out = info.dwAllocationGranularity;
return info.dwPageSize;
}
#else
# include <sys/mman.h>
# ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS MAP_ANON
# endif
VirtualMemory vm_alloc( void* addr, sw size )
{
VirtualMemory vm;
GEN_ASSERT( size > 0 );
vm.data = mmap( addr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0 );
vm.size = size;
return vm;
}
b32 vm_free( VirtualMemory vm )
{
munmap( vm.data, vm.size );
return true;
}
VirtualMemory vm_trim( VirtualMemory vm, sw lead_size, sw size )
{
void* ptr;
sw trail_size;
GEN_ASSERT( vm.size >= lead_size + size );
ptr = pointer_add( vm.data, lead_size );
trail_size = vm.size - lead_size - size;
if ( lead_size != 0 )
vm_free( vm_from_memory(( vm.data, lead_size ) );
if ( trail_size != 0 )
vm_free( vm_from_memory( ptr, trail_size ) );
return vm_from_memory( ptr, size );
}
b32 vm_purge( VirtualMemory vm )
{
int err = madvise( vm.data, vm.size, MADV_DONTNEED );
return err != 0;
}
sw virtual_memory_page_size( sw* alignment_out )
{
// TODO: Is this always true?
sw result = zpl_cast( sw ) sysconf( _SC_PAGE_SIZE );
if ( alignment_out )
*alignment_out = result;
return result;
}
#endif
#pragma endregion VirtualMemory
void* Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags )
{
Arena* arena = rcast(Arena*, allocator_data);

View File

@ -1,5 +1,7 @@
#pragma once
#include "debug.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "debug.hpp"
#endif
#pragma region Memory
@ -363,6 +365,33 @@ GEN_IMPL_INLINE void zero_size( void* ptr, sw size )
mem_set( ptr, 0, size );
}
struct VirtualMemory
{
void* data;
sw size;
};
//! Initialize virtual memory from existing data.
VirtualMemory vm_from_memory( void* data, sw size );
//! Allocate virtual memory at address with size.
//! @param addr The starting address of the region to reserve. If NULL, it lets operating system to decide where to allocate it.
//! @param size The size to serve.
VirtualMemory vm_alloc( void* addr, sw size );
//! Release the virtual memory.
b32 vm_free( VirtualMemory vm );
//! Trim virtual memory.
VirtualMemory vm_trim( VirtualMemory vm, sw lead_size, sw size );
//! Purge virtual memory.
b32 gen_vm_purge( VirtualMemory vm );
//! Retrieve VM's page size and alignment.
sw gen_virtual_memory_page_size( sw* alignment_out );
struct Arena
{
static
@ -448,6 +477,45 @@ struct Arena
}
};
// Just a wrapper around using an arena with memory associated with its scope instead of from an allocator.
// Used for static segment or stack allocations.
template< s32 Size >
struct FixedArena
{
static
FixedArena init()
{
FixedArena result = { Arena::init_from_memory( result.memory, Size ), {0} };
return result;
}
sw size_remaining( sw alignment )
{
return arena.size_remaining( alignment );
}
operator AllocatorInfo()
{
return { Arena::allocator_proc, &arena };
}
Arena arena;
char memory[ Size ];
};
using Arena_1KB = FixedArena< kilobytes( 1 ) >;
using Arena_4KB = FixedArena< kilobytes( 4 ) >;
using Arena_8KB = FixedArena< kilobytes( 8 ) >;
using Arena_16KB = FixedArena< kilobytes( 16 ) >;
using Arena_32KB = FixedArena< kilobytes( 32 ) >;
using Arena_64KB = FixedArena< kilobytes( 64 ) >;
using Arena_128KB = FixedArena< kilobytes( 128 ) >;
using Arena_256KB = FixedArena< kilobytes( 256 ) >;
using Arena_512KB = FixedArena< kilobytes( 512 ) >;
using Arena_1MB = FixedArena< megabytes( 1 ) >;
using Arena_2MB = FixedArena< megabytes( 2 ) >;
using Arena_4MB = FixedArena< megabytes( 4 ) >;
struct Pool
{
static

View File

@ -1,4 +1,6 @@
#pragma once
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
#endif
#pragma region ADT

View File

@ -1,4 +1,6 @@
#pragma once
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
#endif
#pragma region ADT

View File

@ -1,5 +1,9 @@
#pragma once
#include "string_ops.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "filesystem.hpp"
# include "strings.hpp"
# include "string_ops.cpp"
#endif
#pragma region Printing

View File

@ -1,5 +1,7 @@
#pragma once
#include "string_ops.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "string_ops.hpp"
#endif
#pragma region Printing

View File

@ -1,3 +1,7 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
# include "header_start.hpp"
#endif
#pragma region Macros and Includes
# include <stdio.h>

View File

@ -1,5 +1,8 @@
#pragma once
#include "debug.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "string_ops.hpp"
# include "debug.cpp"
#endif
#pragma region String Ops

View File

@ -1,5 +1,7 @@
#pragma once
#include "memory.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "memory.hpp"
#endif
#pragma region String Ops

View File

@ -1,5 +1,7 @@
#pragma once
#include "hashing.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "hashing.cpp"
#endif
#pragma region String

View File

@ -1,5 +1,7 @@
#pragma once
#include "hashing.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "hashing.hpp"
#endif
#pragma region Strings
@ -99,6 +101,11 @@ struct String
bool make_space_for( char const* str, sw add_len );
bool append( char c )
{
return append( & c, 1 );
}
bool append( char const* str )
{
return append( str, str_len( str ) );
@ -213,6 +220,27 @@ struct String
#undef current
}
void strip_space()
{
char* write_pos = Data;
char* read_pos = Data;
while ( * read_pos)
{
if ( ! char_is_space( *read_pos ))
{
*write_pos = *read_pos;
write_pos++;
}
read_pos++;
}
write_pos[0] = '\0'; // Null-terminate the modified string
// Update the length if needed
get_header().Length = write_pos - Data;
}
void trim( char const* cut_set )
{
sw len = 0;
@ -241,14 +269,52 @@ struct String
return trim( " \t\r\n\v\f" );
}
// Debug function that provides a copy of the string with whitespace characters visualized.
String visualize_whitespace() const
{
Header* header = (Header*)(Data - sizeof(Header));
String result = make_reserve(header->Allocator, length() * 2); // Assume worst case for space requirements.
for ( char c : *this )
{
switch ( c )
{
case ' ':
result.append( txt("·") );
break;
case '\t':
result.append( txt("") );
break;
case '\n':
result.append( txt("") );
break;
case '\r':
result.append( txt("") );
break;
case '\v':
result.append( txt("") );
break;
case '\f':
result.append( txt("") );
break;
default:
result.append(c);
break;
}
}
return result;
}
// For-range support
char* begin()
char* begin() const
{
return Data;
}
char* end()
char* end() const
{
Header const&
header = * rcast( Header const*, Data - sizeof( Header ));

View File

@ -1,5 +1,7 @@
#pragma once
#include "filesystem.cpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "filesystem.cpp"
#endif
#pragma region Timing

View File

@ -1,5 +1,7 @@
#pragma once
#include "filesystem.hpp"
#ifdef GEN_INTELLISENSE_DIRECTIVES
# pragma once
# include "filesystem.hpp"
#endif
#pragma region Timing

View File

@ -21,5 +21,6 @@ Volatile, volatile
Virtual, virtual
Const, const
Final, final
NoExceptions, noexcept
Override, override
Pure, = 0

1 Invalid INVALID
21 Virtual virtual
22 Const const
23 Final final
24 NoExceptions noexcept
25 Override override
26 Pure = 0

View File

@ -15,7 +15,7 @@ BraceSquare_Open, "["
BraceSquare_Close, "]"
Capture_Start, "("
Capture_End, ")"
Comment, "__comemnt__"
Comment, "__comment__"
Comment_End, "__comment_end__"
Comment_Start, "__comment_start__"
Char, "__character__"

1 Invalid __invalid__
15 BraceSquare_Close ]
16 Capture_Start (
17 Capture_End )
18 Comment __comemnt__ __comment__
19 Comment_End __comment_end__
20 Comment_Start __comment_start__
21 Char __character__

View File

@ -113,6 +113,39 @@ function run-linker
}
}
function run-compile-and-link
{
param( $vendor, $unit, $compiler_args, $linker_args )
write-host "`Compiling & Linking $unit"
write-host "Compiler config:"
$compiler_args | ForEach-Object {
write-host $_ -ForegroundColor Cyan
}
write-host "Linker config:"
$linker_args | ForEach-Object {
write-host $_ -ForegroundColor Cyan
}
$time_taken = Measure-Command {
& $vendor $compiler_args $linker_args 2>&1 | ForEach-Object {
$color = 'White'
switch ($_){
{ $_ -match "error" } { $color = 'Red' ; break }
{ $_ -match "warning" } { $color = 'Yellow'; break }
}
write-host `t $_ -ForegroundColor $color
}
}
# if ( Test-Path($binary) ) {
# write-host "$binary compile & link finished in $($time_taken.TotalMilliseconds) ms"
# }
# else {
# write-host "Compile & Link failed for $binary" -ForegroundColor Red
# }
}
if ( $vendor -match "clang" )
{
# https://clang.llvm.org/docs/ClangCommandLineReference.html
@ -173,7 +206,8 @@ if ( $vendor -match "clang" )
$flag_wall,
$flag_preprocess_non_intergrated,
( $flag_define + 'GEN_TIME' ),
( $flag_path_output + $object ),
# ( $flag_path_output + $object ),
( $flag_path_output + $executable )
( $flag_include + $includes )
)
if ( $release -eq $false ) {
@ -188,8 +222,8 @@ if ( $vendor -match "clang" )
# $compiler_args += $flag_preprocess
$compiler_args += $flag_compile, $unit
run-compiler $compiler $unit $compiler_args
# $compiler_args += $flag_compile, $unit
# run-compiler $compiler $unit $compiler_args
$linker_args = @(
$flag_link_win_subsystem_console,
@ -207,8 +241,12 @@ if ( $vendor -match "clang" )
$linker_args += $_ + '.lib'
}
$linker_args += $object
run-linker $linker $executable $linker_args
# $linker_args += $object
# run-linker $linker $executable $linker_args
$compiler_args += $unit
# $linker_args += $object
run-compile-and-link $compiler $unit $compiler_args
}
$compiler = 'clang++'
@ -396,6 +434,7 @@ if ( $test )
build-simple $includes $unit $executable
Push-Location $path_test
Write-Host $path_test
if ( Test-Path( $executable ) ) {
write-host "`nRunning test generator"
$time_taken = Measure-Command { & $executable
@ -458,7 +497,7 @@ if ( $singleheader -and (Test-Path (Join-Path $path_singleheader "gen/gen.hpp"))
format-cpp $path_gen $include $exclude
}
if ( $test )
if ( $test -and $false )
{
$path_gen = join-path $path_test gen
$include = @(

View File

@ -1,6 +1,4 @@
# Singleheader
`gen.singleheader.cpp` with its own `meson.build` generates the library as a single header `gen.hpp`.
Following the same convention seen in the gb, stb, and zpl libraries.
( Currently WIP )
Creates a single header file version of the library using `gen.singleheader.cpp`.
Follows the same convention seen in the gb, stb, and zpl libraries.

View File

@ -17,7 +17,7 @@ GEN_NS_END
using namespace gen;
constexpr char const* generation_notice =
"// This file was generated automatially by gen.bootstrap.cpp "
"// This file was generated automatially by gencpp's singleheader.cpp"
"(See: https://github.com/Ed94/gencpp)\n\n";
constexpr StrC implementation_guard_start = txt(R"(
@ -48,8 +48,6 @@ global bool generate_builder = true;
global bool generate_editor = true;
global bool generate_scanner = true;
constexpr bool DontSkipInitialDirectives = false;
int gen_main()
{
#define project_dir "../project/"
@ -57,7 +55,7 @@ int gen_main()
Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
Code single_header_start = scan_file( "components/header_start.hpp", DontSkipInitialDirectives );
Code single_header_start = scan_file( "components/header_start.hpp" );
Builder
header = Builder::open( "gen/gen.hpp" );
@ -71,7 +69,7 @@ int gen_main()
if ( generate_gen_dep )
{
Code header_start = scan_file( project_dir "dependencies/header_start.hpp", DontSkipInitialDirectives );
Code header_start = scan_file( project_dir "dependencies/header_start.hpp" );
Code macros = scan_file( project_dir "dependencies/macros.hpp" );
Code basic_types = scan_file( project_dir "dependencies/basic_types.hpp" );
Code debug = scan_file( project_dir "dependencies/debug.hpp" );
@ -154,13 +152,6 @@ int gen_main()
header.print_fmt( "#pragma endregion Builder\n" );
}
if ( generate_scanner )
{
header.print_fmt( "\n#pragma region Scanner\n" );
header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
header.print_fmt( "#pragma endregion Scanner\n\n" );
}
header.print_fmt( "GEN_NS_END\n" );
}
@ -212,8 +203,8 @@ int gen_main()
Code parsing = scan_file( project_dir "components/interface.parsing.cpp" );
Code untyped = scan_file( project_dir "components/interface.untyped.cpp" );
CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", project_dir "enums/AttributeTokens.csv" );
CodeNS parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", project_dir "enums/AttributeTokens.csv" );
CodeNS parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
header.print_fmt( "\nGEN_NS_BEGIN\n");
header.print( static_data );
@ -240,6 +231,14 @@ int gen_main()
header.print_fmt( "\n#pragma endregion Builder\n\n" );
}
// Scanner header depends on implementation
if ( generate_scanner )
{
header.print_fmt( "\n#pragma region Scanner\n" );
header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
header.print_fmt( "#pragma endregion Scanner\n\n" );
}
#if 0
if ( generate_scanner )
{

35
test/CURSED_TYPEDEF.h Normal file
View File

@ -0,0 +1,35 @@
#include <functional>
class MyClass;
enum class MyEnum : short { VAL1, VAL2 };
struct OuterStruct {
union NamedUnion {
struct InnerStruct {
double d;
char c;
} inner;
int i;
} unionInstance;
};
template<typename T, int N = alignof(double)>
struct TemplateStruct {
T member[N];
};
template<>
struct TemplateStruct<int, 10> {
int specialMember[10];
};
typedef decltype(nullptr) (MyClass::*InsaneComplexTypeDef)(
decltype((MyEnum::VAL1 == MyEnum::VAL2) ? 1 : 2.0)
(TemplateStruct<decltype(OuterStruct().unionInstance.inner), 5>::*ptr)[5][alignof(double)],
std::function<void *(TemplateStruct<int, 10>&&,
void (MyClass::*memFnPtr)(TemplateStruct<decltype(OuterStruct().unionInstance.inner)>))>,
int (MyClass::*&refToMemFnPtr)(TemplateStruct<int, 10>),
int (TemplateStruct<int, 10>::*memberPointer)[10],
char&&...
) volatile const && noexcept;

View File

@ -0,0 +1,13 @@
# Test : Eskil Steenberg's Game Pipeline
***Note: This validation test has not been implemented yet.***
Repo : https://github.com/valiet/quel_solaar
This is a AST reconstruction test of the gamepipeline library.
1. Download the library
2. Grab all header and source file paths
3. Generate an ast for each file and serialize it to a file called <name of file>.gen.<h/c>
4. Reconstruct the ast from the generated file
5. Compare the original ast to the reconstructed ast

View File

15
test/Godot/Readme.md Normal file
View File

@ -0,0 +1,15 @@
# Test : Godot full AST reconstruction and compile validation
***Note: This validation test has not been implemented yet.***
Repo : https://github.com/godotengine/godot
* Download the Unreal source code
* Find paths of every header and source file
* Generate an ast for each file and serialize it to a file called `<name of file>.gen.<h/c>`
* Reconstruct the ast from the generated file
* Compare the original ast to the reconstructed ast
* If all ASTs are considered valid, overwrite the original files with the generated files
* Compile the engine.
Currently the most involved test planned for the library.

View File

0
test/Godot/validate.ps1 Normal file
View File

25
test/Unreal/Readme.md Normal file
View File

@ -0,0 +1,25 @@
# Unreal Header & Source reconstruction tests
***Note: This validation test has not been implemented yet.***
Will test the following modules + plugins:
* Kismet
* Slate
* RTTI Bases
* Gameframework
* Actor & Component Bases
* Lyra
In the future I could attempt to do a similar test to that of the godot engine full compilation test.
For now it just does the following:
* Download the Unreal source code
* For each module
1. Grab all header and source file paths
2. Generate an ast for each file and serialize it to a file called `<name of file>.gen.<h/c>`
3. Reconstruct the ast from the generated file
4. Compare the original ast to the reconstructed ast
This wil most likely be the most difficult test along-side godot's full compilation test.

0
test/Unreal/validate.ps1 Normal file
View File

View File

18
test/ZPL-C/Readme.md Normal file
View File

@ -0,0 +1,18 @@
# Test : ZPL-C Reconstruction
***Note: This validation test has not been implemented yet.***
Repo : https://github.com/zpl-c/zpl
This is a AST reconstruction test of the ZPL-C library.
Much of the dependency code used in gencpp is derived from the ZPL-C library.
In the future I could directly generate that related code from the ZPL-C library.
For now it just does the following:
1. Download the ZPL-C library
2. Grab all header and source file paths
3. Generate an ast for each file and serialize it to a file called <name of file>.gen.<h/c>
4. Reconstruct the ast from the generated file
5. Compare the original ast to the reconstructed ast

0
test/ZPL-C/validate.ps1 Normal file
View File

View File

View File

@ -0,0 +1,21 @@
#ifdef GEN_TIME
#define GEN_FEATURE_PARSING
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#define GEN_BENCHMARK
#include "gen.hpp"
void check_parsing()
{
using namespace gen;
log_fmt("\nupfront: ");
gen::init();
// TODO
gen::deinit();
log_fmt("Passed!\n");
}
#endif

View File

@ -4,6 +4,11 @@
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#define GEN_BENCHMARK
#define GEN_GLOBAL_BUCKET_SIZE megabytes(10)
#define GEN_CODE_POOL_BLOCK_SIZE megabytes(32)
#define GEN_STRING_ARENA_SIZE megabytes(1)
#include "gen.hpp"
#include "gen.builder.hpp"

View File

@ -7,7 +7,7 @@
#include "gen.builder.cpp"
#include "sanity.cpp"
#include "SOA.cpp"
#include "test.singleheader_ast.cpp"
#include "validate.singleheader.cpp"
int gen_main()
{
@ -18,8 +18,7 @@ int gen_main()
// check_SOA();
check_singleheader_ast();
check_singleheader_ast();
return 0;
}
#endif

View File

@ -1,33 +0,0 @@
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#define GEN_BENCHMARK
#include "gen.hpp"
#include "gen.builder.hpp"
#include "gen.scanner.hpp"
using namespace gen;
void check_singleheader_ast()
{
#define project_dir "../"
gen::init();
log_fmt("\ncheck_singleheader_ast:\n");
FileContents file = file_read_contents( GlobalAllocator, true, project_dir "singleheader/gen/gen.hpp" );
u64 time_start = time_rel_ms();
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
log_fmt("\nAst generated. Time taken: %llu ms\n", time_rel_ms() - time_start);
log_fmt("\nSerializng ast:\n");
time_start = time_rel_ms();
Builder
builder = Builder::open( "gen/singleheader_copy.gen.hpp" );
builder.print( ast );
builder.write();
log_fmt("passed!! Time taken: %llu ms\n", time_rel_ms() - time_start);
gen::deinit();
}

View File

@ -12,7 +12,7 @@ void check_upfront()
log_fmt("\nupfront: ");
gen::init();
// TODO
gen::deinit();
log_fmt("Passed!\n");

View File

@ -0,0 +1,65 @@
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND
#define GEN_BENCHMARK
#include "gen.hpp"
#include "gen.builder.hpp"
#include "gen.scanner.hpp"
using namespace gen;
#ifdef GEN_SYSTEM_WINDOWS
#include <process.h>
#endif
void check_singleheader_ast()
{
#define root_dir "../"
gen::init();
log_fmt("\ncheck_singleheader_ast:\n");
FileContents file = file_read_contents( GlobalAllocator, true, root_dir "singleheader/gen/gen.hpp" );
u64 time_start = time_rel_ms();
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
log_fmt("\nAst generated. Time taken: %llu ms\n", time_rel_ms() - time_start);
log_fmt("\nSerializng ast:\n");
time_start = time_rel_ms();
Builder
builder = Builder::open( "gen/singleheader_copy.gen.hpp" );
builder.print( ast );
builder.write();
log_fmt("Serialized. Time taken: %llu ms\n", time_rel_ms() - time_start);
// Need to execute clang format on the generated file to get it to match the original.
#define script_path root_dir "scripts/"
#define clang_format "clang-format "
#define cf_format_inplace "-i "
#define cf_style "-style=file:" "C:/projects/gencpp/scripts/.clang-format "
#define cf_verbose "-verbose "
log_fmt("\nRunning clang-format on generated file:\n");
system( clang_format cf_format_inplace cf_style cf_verbose "gen/singleheader_copy.gen.hpp" );
log_fmt("clang-format finished reformatting.\n");
#undef script_path
#undef cf_cmd
#undef cf_format_inplace
#undef cf_style
#undef cf_verbse
FileContents file_gen = file_read_contents( GlobalAllocator, true, "gen/singleheader_copy.gen.hpp" );
log_fmt("\nReconstructing from generated file:\n");
time_start = time_rel_ms();
CodeBody ast_gen = parse_global_body( { file_gen.size, (char const*)file_gen.data } );
log_fmt("\nAst generated. Time taken: %llu ms\n\n", time_rel_ms() - time_start);
time_start = time_rel_ms();
if ( ast.is_equal( ast_gen ) )
log_fmt( "\nPassed!: AST passed validation!\n" );
else
log_fmt( "\nFailed: AST did not pass validation\n" );
log_fmt( "Time taken: %llu ms\n", time_rel_ms() - time_start );
gen::deinit();
}

View File

@ -1,3 +0,0 @@
// Constructs an AST from the singlheader generated gen files, then serializes it to a set of files.
// Using the new set of serialized files, reconstructs the AST and then serializes it again (to different set of files).
// The two sets of serialized files should be identical. (Verified by comparing the file hashes)