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:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user