Tuesday, March 2, 2004

Source Code Formatter, Painter, and Validation

This is my Computing Theory Project. In this project, I choose to create program that takes an input of a source code (SC) of valid C language (can be compiled one). Then, no matter how miserable the source code is, my program would parse the source code, and reformat it. Meaning that the indentation of the SC will be corrected, the keywords will be colored, and hopefuly will notify every errors that occurs during the parsing.

The algorithm I use is a recursive descent parser. It's a top down parser. Unfortunately, because C language can be quite complex, I cannot guarantee that my program can parse tricky SC. Since sometimes, the error / validity is determined by the syntax, not the parser :O

Additional feature would be : the formatter supports new data types created by "typedef" keyword. My program would be able to allocate this new data type and remember it, so it can color the new data type with different color. WARNING: ALL structure must be defined before it can be used! -> although C compiler allows otherwise.

Try put ONLY valid (can be compiled) C source code in the textarea below, and click "Format, Paint and Validate" button to format it. Or just try with the sample SC (solution for Problem number 489). I haven't put any prevention of NON VALID Source Code! Also remember that I use Javascript for this project! Means that this program is Open Source. Also note that Javascript can be executed offline (for many browsers). So, you are able to use this page offline :) I Love Javascript!

My program is not full yet. I'm still trying finding bugs.

Note: my program leaves comment as it is. Maybe the comment would look miserable :)

No comments:

Post a Comment