1 / 15

C Program Checker

C Program Checker . By: Advisor: Mike Burgio Dr. Fischbach Chris Addis. Goals . Make a program that detects potential errors in freshman C programs Specifically errors not detected by the gcc compiler. Includes syntax and semantic errors

stasia
Télécharger la présentation

C Program Checker

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C Program Checker By: Advisor: Mike Burgio Dr. Fischbach Chris Addis

  2. Goals • Make a program that detects potential errors in freshman C programs • Specifically errors not detected by the gcc compiler. • Includes syntax and semantic errors • Print out the line numbers where the potential error has occurred.

  3. Syntax Errors • Syntax is a set of rules that define the sequence of symbols that are considered to be correctly structured programs in that language • The gcc compiler finds all syntax errors.

  4. In terms of our project • We are looking for errors that do not violate the syntax of the language, but might not be what the programmer intended. • Ex. Using scanf statement without an “&” • scanf(“%d”, x);

  5. What is printf / scanf

  6. Syntax Example • A simple control structure int x = 2, y = 4; if(x = y) { printf(“Same!\n”); } else { printf(“Not Same\n!”); }

  7. Semantic Errors • Semantics of a program are what the actual statements do and what the expressions mean when the program is executed. • Specific examples of semantic errors: • Failure to initialize variable • Proper type conversion • Ex. Truncating a real number unintentionally

  8. Semantic Example A common while loop int i; while(i<5) { printf(“Hello World”); i = i + 1; }

  9. Grammar • Grammar for C defines what is acceptable code to be read by a compiler • In our grammar, we define what is acceptable and unacceptable for specific cases, and skip the rest • This is an extendable project, allowing us to add more errors as we progress

  10. JavaCC • To make our C Checker, we used JavaCC • JavaCC is a parser generator and lexical analyzer that allows us to define our grammar • JavaCC analyzes the program as follows: • Breaking up each line into tokens • Tokens are processed to determine the structure of the program • Checks to see if the sequence of tokens matches our correct case, or matches our incorrect case

  11. Our Program checks… • Only one equal sign in if statements, for/while loops • Scanf/printf statements containing improper ampersand • Inconsistent amount of variables and percent codes • Truncation from real number to integer • Variables being used before being initialized • Ensuring the types match with variables • Performs a usage analysis at the end of the program and prints any unused variables • And more!

  12. What is a GUI • GUI is a graphical user interface • This allows users to interact with electronic devices with images rather than text commands • GUI’s have become very common in modern programming

  13. Our GUI • In order to make our program easy to use, we implemented a GUI • Our program can also run as a text command if the user prefers.

  14. GUI

  15. Questions???

More Related