chore: add increment/decrement operators and test suite to parser and tokenizer

Implement prefix and postfix ++/-- operators in the tokenizer (Inc/Dec token types) and parser (factor/unary functions) with correct pre/post semantics. Add increment_decrement_test.rc covering all four operator forms. Update Makefile to include the new test file in TESTS, add run-increment-decrement-test target, and fix .PHONY and TARGET dependency on dirs.
This commit is contained in:
2025-11-22 23:17:01 +00:00
parent 82722a757a
commit eb3d29ac8d
12 changed files with 69 additions and 4 deletions
+30
View File
@@ -0,0 +1,30 @@
int main() {
int a;
int b;
a = 5;
b = a++;
printf("a = %d, b = %d\n", a, b);
a = 5;
b = ++a;
printf("a = %d, b = %d\n", a, b);
a = 5;
b = a--;
printf("a = %d, b = %d\n", a, b);
a = 5;
b = --a;
printf("a = %d, b = %d\n", a, b);
a = 5;
a++;
printf("a = %d\n", a);
a = 5;
a--;
printf("a = %d\n", a);
return 0;
}