A C program analysis toolkit with two utilities.
Designed to remove comments and check basic syntax errors in C source files while handling strings, character literals, and non-nesting comments correctly.
- Removes all C comments (
//and/* */) from source files. - Correctly handles:
- Quoted strings (
"...") - Character constants (
'a') - Escape sequences (
\",\',\\)
- Quoted strings (
- Usage:
./strip_comments < input.c > output.c-
Checks C programs for rudimentary syntax errors:
-
Unmatched parentheses ()
-
Unmatched brackets []
-
Unmatched braces {}
-
-
Ignores:
-
Strings and character literals
-
Comments and escape sequences
-
-
Usage:
./check_syntax < input.c- Using GCC directly
# Build strip_comments
gcc src/main_strip.c src/lexer.c -o strip_comments# Build check_syntax
gcc src/main_check.c src/lexer.c src/stack.c -o check_syntax- Using Makefile
make- Remove comments from a file
./strip_comments < example_input.c > example_output.c- Check for basic syntax errors
./check_syntax < example_input.c- MIT license