r/C_Programming • u/Sewter0 • Jul 28 '26
Looking for feedback on my C interpreter project.
Hi everyone!
I’ve been learning C and built a small interpreter from scratch. It currently supports arithmetic expressions, variables, conditionals, user-functions, dynamic arrays, and few built-in functions.
I’m mainly looking for feedback on the code quality, architecture, parser design, and memory management. Any suggestions are welcome.
Github: https://github.com/0sewter0/Interpreter.git
(I am new in reddit, and I am from kazakhstan, so I am not speak english well)
15
Upvotes
•
u/mikeblas Jul 28 '26
What role did AI have in the creation of your project?
What issues did you struggle with in development, and how did you resolve them? What is your purpose for sharing this code with the community?
7
u/skeeto Jul 29 '26 edited Jul 29 '26
Neat project! Compile with warnings (
-Wall -Wextra) to reveal a couple of bugs statically: comparing an array with null, and an uninitialized variable. Also test with sanitizers when available, particularly Address Sanitizer (ASan) and Undefined Behavior Sanitizer (UBSan), via (-fsanitize=address,undefined). Per your README.md, with GCC on Windows you only have access to UBSan, and only in trap mode (-fsanitize-trap), so you won't get a diagnostic message, just a crash to inspect under GDB.Some interesting inputs:
The lack of unary
-makes those expressions a little difficult. I suggest using two's complement overflow as a simple solution. For addition, subtraction, and multiplication cast the operands to unsigned, do the operation unsigned, then cast back to signed. Division requires more care.There are some buffer overflows, but it's not possible to hit them from the REPL because it silently truncates lines to 255 bytes (leading to confusing parse errors). Adjusting that:
Then:
Another buffer overflow:
Another:
Infinite loop:
Buffer overflow:
Buffer overflow on
strcat(which has zero legitimate uses) plus it's unnecessary quadratic time:I found all these in a moment's effort using fuzz testing. While a more advanced topic, it's a lot easier to use than it seems.
-4
u/github-guard Jul 28 '26
🔍 GitHub Guard: Trust Report
⚠️ This project scored 0/6 — below this subreddit's threshold of 3.
Audit Breakdown: