Skip to content

lokkdevv/C-Source-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C Source Analyzer

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.


Features

1. strip_comments

  • Removes all C comments (// and /* */) from source files.
  • Correctly handles:
    • Quoted strings ("...")
    • Character constants ('a')
    • Escape sequences (\", \', \\)
  • Usage:
./strip_comments < input.c > output.c

2. check_syntax

  • 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

Compilation

  • 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

Example Usage

  • Remove comments from a file
./strip_comments < example_input.c > example_output.c
  • Check for basic syntax errors
./check_syntax < example_input.c

License

  • MIT license

About

C Source Analyzer, A C program analysis toolkit with two utilities built on a shared lexer core, Designed to remove comments and check basic syntax errors in C source files while handling strings, character literals, escape sequences, and non-nesting comments correctly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages