Commit Graph

92 Commits

Author SHA1 Message Date
Ed_
f67f9547df WIP: Improvements to parser, updated docs
Trying to get support for typename keyword soon
2023-11-21 21:27:33 -05:00
Ed_
772db608be Added support for predefining preprocessor defines before parsing strings of code.
This prevents issues for preprocessor defines not getting treated properly for specific circumstances (such as macro wrappers for specifiers).
2023-11-21 20:09:14 -05:00
Ed_
be023325a9 Added AST & Code definitions segemnted code defs to separate file
For upcoming statements & expression types, just beginning to lay things out for the future.
2023-11-21 20:07:49 -05:00
Ed_
6ad0ae97bc Added bool type keyword to ETokType, move volatile pos in ESpecifier
volatile can be applied to a function so I moved it there.
2023-11-21 20:05:38 -05:00
Ed_
9d27c7d37e Lexer improvement prep, segmentation of lexer and parser. 2023-11-20 21:24:27 -05:00
Ed_
5c73fbee83 WIP : AST serialization improvements
Code untestd its an initial draft
2023-11-19 20:35:21 -05:00
Ed_
212d907d73 Fixed bug with inline comments for variables not parsing correctly. 2023-10-25 23:44:25 -04:00
Ed_
c1ab233686 Fix for bug with comma separated declaration list vars
Known Bug: Inline comments are not printing now
2023-10-25 21:43:22 -04:00
Ed_
b42b224c0d Forgot to push some parser fixes 2023-10-25 03:33:35 -04:00
Ed_
041671762b Got through parsing raylib.h, started to do some major refactors. 2023-10-25 03:26:25 -04:00
Ed_
d0f3b6187e Added initial support for comma-separated variable declaration lists. 2023-10-25 00:25:35 -04:00
Ed_
912cc6b538 Bugfixes during hiatus
Found while doing some metaprogramming for day 42 of handmade hero.
2023-10-22 21:41:36 -04:00
Ed_
6498b13658 Fix for non-foreign include content not getting parsed correctly. 2023-10-01 12:16:15 -04:00
Ed_
3a0e971ebf Bugfix for parse_variable, const check for prefix specifiers causing infinite loop. 2023-09-28 20:35:20 -04:00
Ed_
729c891cbd Last fixes before handmade hero hiatus 2023-09-25 17:48:16 -04:00
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_
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_
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_
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_
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_
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
Ed_
a6c6574390 More formatting fixes 2023-08-22 02:09:20 -04:00
Ed_
c4846dad26 Formatting fixes 2023-08-22 01:51:59 -04:00
Ed_
a61a28b778 Fixx to bitfield variables
Related to https://github.com/Ed94/gencpp/issues/25
2023-08-22 00:40:38 -04:00
Ed_
d0c995893d Lower inital memory allocation amounts. (Lower latency iteration for running generator)
I need to change it so that they all use one big arena allocation for the initial. This can be done when the global allocator is changed to a growable arena.
2023-08-21 23:49:23 -04:00
Ed_
a42e241afb Got rid of the temp compoonent files, they are now generated via bootstrapping.
This isn't the last step though everything in the main project directory that isn't md files needs to be generated only.
Can't do that till testing is robust enough...
2023-08-21 23:28:39 -04:00
Ed_
db6e8b33eb got intellisense working for the most part...
VScode works withs some issues.
VS2022 fails.
10xEditor works fine.
JetBrains Rider fails due to it not supporting <push/pop>_macro pragmas
2023-08-21 23:07:03 -04:00
Ed_
5c47777972 compiles agian... 2023-08-21 21:40:23 -04:00
Ed_
050b00f28a WIP - Broken Compile : Added pragma once and includes to all files + Parser fixes, and String improvements
Adding the pragma once and includes the files broke compilation, still diagnosing why.

- Some string functions were moved to the cpp, still need to do some more evaluation of it and the containers...
- Added support for forceinline and neverinline to parsing (untested)
- Added support for specifiers in operator cast such as explicit, inline/forceinline/neverinline, etc.
    - Before it only support const.
    - Still need to support volatile.
- Forceinline was not supported at all for tokenization, fixed that.
2023-08-21 20:30:13 -04:00
Ed_
37d9782cf2 Singleheader now compiles with new build script on both clang & msvc 2023-08-20 10:17:55 -04:00
Ed_
11679ba8b4 New build script works for clang and msvc!
Need to update singleheader and test to use it.
2023-08-19 21:33:01 -04:00