Skip to content
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

Weird for loop #4

Closed
Th3F4nd1t opened this issue Dec 14, 2024 · 5 comments
Closed

Weird for loop #4

Th3F4nd1t opened this issue Dec 14, 2024 · 5 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Th3F4nd1t
Copy link

image
Highlighted line returns syntax error, same if I replace result * i with 1.
Does Brainrot have the ability to reassign?
Any help would be sigma.

@Somespi
Copy link

Somespi commented Dec 14, 2024

After some investigation (only scanning the source code) , i don't think it supports that.

in evaluate_expression function, it includes:

case NODE_IDENTIFIER:
        return get_variable(node->data.name);

where if I'm correct, it only deals with the variable as immutable, as it does not count for the case where the grammar could be IDENTIFIER = VALUE;

Not so sure, but I think we could add an if statement in the evaluate_expression function to handle that case, so not a big deal.

@araujo88
Copy link
Collaborator

Nice catch! I'll look into that sus for loop and see if I could fix it and add more rizz to the language.

@araujo88 araujo88 added the bug Something isn't working label Dec 14, 2024
@araujo88 araujo88 self-assigned this Dec 14, 2024
@SolsticeSpectrum
Copy link

SolsticeSpectrum commented Dec 14, 2024

It doesn't support multiple things.
If you wanna assign integer itself you can't do

int i = 2;
i = i + 2;

Instead you have to do

int i = 2;
int i = i + 2;

Also for debugging purposes I recommend doing the brainrot keyword assignment on release build,
otherwise for test use normal keywords

arrays don't exist, should be implemented to allow at least basic tasks
should allow some sort of user input too to make at least a functional calculator
lastly comments should be allowed, that should require only a simple regex

function calling would be legendary

@araujo88
Copy link
Collaborator

I plan on implementing these features you mentioned, but feel free to contribute and show all your rizz.

@araujo88 araujo88 added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 17, 2024
@araujo88
Copy link
Collaborator

This is now working, with a minor change on how the yapping function works:

skibidi main {
    rizz number = 5;
    rizz result = 1;

    flex (rizz i = 1; i <= number; i = i + 1) {
        result = result * i;
    }

    yapping("%d", result);
    bussin 0;
}

This prints the following:

[leonardo@archlinux brainrot]$ ./brainrot < examples/test.brainrot 
120

Fixed in #14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants