Skip to content

Conversation

@nt-devilboi
Copy link

No description provided.

[InlineData("-10 > 9", false)]
[InlineData("-10 < 9", true)]
[InlineData("-10 < -9", true)]
[InlineData("-9 == -9", true)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for <= >= too. so we can test that these cases coverted too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you check that -10 < 0x10 for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, i added

if (Regex.IsMatch(macrosValue, $"^(0|[1-9][0-9]*)$"))
return int.Parse(macrosValue);

if (Regex.IsMatch(macrosValue, $"^(-[1-9][0-9]*)$"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the change should be in CPreprocessorExpresisonParser I think that's change not applicable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. We belive should not have negative numbers as tokens, expression can have them just fine. Negaive numbers can be treated as unary expression - Token, for example. So likely you should expand expression grammar in the CPreprocessorExpressionParser

Copy link
Author

@nt-devilboi nt-devilboi Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if unary expression with minus exists, I left it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suspect that we have other issue here. Numbers are tokens without sign. Sign + or - handled by Unary expression, but that does not work for some reasons.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So probably something wrong with out Regex for PreprocessorToken

[Regex("[^ \t\v\f\r\n#;+\\-*/()=!<>\",.|\\[\\]&\\\\]+")]
PreprocessingToken,

Also I found issue in Yoakke, which generates lexer for us. LanguageDev/Yoakke#186 maybe that's related.

Copy link
Author

@nt-devilboi nt-devilboi Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suspect that we have other issue here. Numbers are tokens without sign. Sign + or - handled by Unary expression, but that does not work for some reasons.

currently, PreprocessorToken recognize number with operator - (sub) here.
Now Numbers are tokens without sign but with operator sub and etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's not, otherwise how do you get token -10 so you need to handle it here.

Copy link
Author

@nt-devilboi nt-devilboi Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think error here

double \ is incorrect.
{ACF4787D-B634-4504-8CBF-1760896C6799}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, the unary expression looks like this
{8B91DF64-F0D4-489C-82C0-453A783A70F4}
the Result from this function will be -10. is it not correct?
I don't understand how should be

|| Regex.IsMatch(searchValue, "^0[0-7]+$")
|| Regex.IsMatch(searchValue, "^0b[01]+$"))
|| Regex.IsMatch(searchValue, "^0b[01]+$")
|| Regex.IsMatch(searchValue, "^(-[1-9][0-9]*)$"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the change should be in CPreprocessorExpresisonParser I think that's change not applicable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

int Parse(Location location, string macrosValue)
{
if (Regex.IsMatch(macrosValue, $"^(0|[1-9][0-9]*)$"))
if (Regex.IsMatch(macrosValue, $"^(0|-*[1-9][0-9]*)$"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are --0 allowed in C ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we probably should support -0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, -0 is supported by c.
fix

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about +0 ?

Copy link
Author

@nt-devilboi nt-devilboi Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too.
+-...+-+0 and -+...-+-0 are supported. in these cases the result will be 0.
In other words, the result will always be without a sign.
+-+4 => 4

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,
If count of - is even then number otherwise -number

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.

2 participants