Skip to content

Advanced preprocessor features #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Redar13
Copy link

@Redar13 Redar13 commented Mar 3, 2025

  • Allows the use of the operators ==, !=, <=, <, >= and >.
  • Fixed an error of taking variables 0 and false as true.
  • Fixed an error with empty expression body.
  • Added SemVer support.
  • Added an option to call an error.

@NeeEoo
Copy link
Member

NeeEoo commented Mar 3, 2025

Version check uses string comparisons instead of semver comparison, makes it have higher risk of false matches

@Redar13
Copy link
Author

Redar13 commented Mar 3, 2025

Oh, I guess then I'd have to redo the method of getting variables in dynamic instead of string and do a version of the conversion via semver, only then you might have to duplicate the converter in hscript if the user doesn't have the semver library, but I don't know.

@NeeEoo
Copy link
Member

NeeEoo commented Mar 3, 2025

You can include the semver in the code directly just credit the original source

also i recommend checking the haxe source code because it assumes its a version iirc

@TBar09
Copy link

TBar09 commented Mar 8, 2025

This is peak.

@TBar09
Copy link

TBar09 commented Mar 9, 2025

Okay so I tried out the pull request, and overall, everything works fairly well! preprocessors that
compare versions and such or the usage of different operators works as intended.

Though there is a bug that i've noticed when trying to do the basic method of checking, similar to
this:
image
...this doesn't trace anything,but the target is a c++ target. While doing
this:
image
image
...does trace something. It's a minor bug, but a fix I found for this is doing #if(cpp == '1'), but I'm
pretty sure it's just a matter of changing the if statement in the preprocessor condition functions.

(Also a little kerfuffle that I found while testing was that doing something like this:
image
gives an Unexpected token: "#end" error.)

Sorry for the giant text blurb, just thought it was nice to give a good test and give any results I found.

@NeeEoo
Copy link
Member

NeeEoo commented Mar 9, 2025

Fyi you need the defines macro, you might be missing it, check codename for that

@Redar13
Copy link
Author

Redar13 commented Mar 9, 2025

Okay so I tried out the pull request, and overall, everything works fairly well! preprocessors that compare versions and such or the usage of different operators works as intended.

Though there is a bug that i've noticed when trying to do the basic method of checking, similar to this: image ...this doesn't trace anything,but the target is a c++ target. While doing this: image image ...does trace something. It's a minor bug, but a fix I found for this is doing #if(cpp == '1'), but I'm pretty sure it's just a matter of changing the if statement in the preprocessor condition functions.

(Also a little kerfuffle that I found while testing was that doing something like this: image gives an Unexpected token: "#end" error.)

Sorry for the giant text blurb, just thought it was nice to give a good test and give any results I found.

Thanks for testing the pull request.
As for the #if (cpp == "1") trick, it looks like the definitions are saved as strings, there are no strings in the parser check yet.

@TBar09
Copy link

TBar09 commented Mar 10, 2025

Fyi you need the defines macro, you might be missing it, check codename for that

I used that in this test build. I'm pretty sure that the reason why it was not being ran was because of the different types (the defines macro usually puts stuff as strings, while the parser checks for both booleans and integers. I think doing something like this should fix the issue:
image

@Redar13 Redar13 marked this pull request as draft March 25, 2025 06:44
@Redar13 Redar13 marked this pull request as ready for review March 25, 2025 13:53
@Redar13 Redar13 marked this pull request as draft March 26, 2025 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants