working on expression evaluation for fuckscript++, im gonna give yall a rough explanation of how im implementing it
basically, theres a function called evaluate_expression(). This takes in a couple args, but the only relevant one is the expression itself, represented as a string.
first off, the expression gets parsed, meaning it gets separated into a list of individual tokens using whitespace as a separator (meaning you need to do 2 + 2 instead of 2+2 as 2+2 will get counted as a single token). It then searches for the first operator, so +, -, ==, != or || and stops separating, so the resulting list contains a variable or number in the first position, the operator in the second, but for the third one its a bit more complicated. Since it stops separating after an operator, something like 2 + 2 + 3 will get separated into [“2”, “+”, “2 + 3”]. so. a number, an operator and another expression.
if this is the case, the function will call itself on this newly found expression. This repeats until the entire expression has been reduced to just 2 memory addresses (this includes just numbers too since numbers get stored in temporary memory) and an operator, which can then easily be evaluated with basic brainfuck algorithms