CS347 – ASSIGNMENT 2: (Solution)

$ 20.99
Category:

Description

Question 1:
Write a C language Code Analyzer Program (in any language of your choice), that determines in an input file, the total number of lines containing each of the following categories:
1) Source code statements
2) Comments
3) Blank Lines
4) Macro Definitions
5) Variable Declarations
6) Function Declarations7) Function Definitions.
Note that a single line could contain instances from more than one categories listed above, and hence must be counted in all the categories to which it belongs. Eg. Line 1 in the below example shall be counted in the macro category as well as under the comments category and also under source code statements. Further, the program must read the input code (for counting) from an external file (input.txt), and write the results into an output file (output.txt) Example:
————————————————————
#define EOI 0 /* End of input */
#define SEMI 1 /* ; */
#define PLUS 2 /* + */
#define TIMES 3 /* * */
#define LP 4 /* ( */
#define RP 5 /* ) */ #define NUM_OR_ID 6 /* Decimal Number or Identifier */
extern char *yytext; /* in lex.c */ extern int yyleng; extern yylineno;
int main()
{
/* statement_block */
return 0;

}
—————————————————————-
The expected output for the above code should be:
1) Source code statements : 19
2) Comments : 09
3) Blank Lines : 04
4) Macro Definitions : 07
5) Variable Declarations : 03
6) Function Declarations : 00
7) Function Definitions : 01
2nd and 3rd Questions are in 2nd Page
Question 2:
Write a C++ language Code Analyzer Program (in any language of your choice) that determines in an input file, the total number of lines containing each of the following categories : 1) Objects declaration
2) Class definition
3) Constructor definition
4) Inherited Class definition
5) Operator Overloaded function definition
Note that a single line could contain instances from more than one categories listed above, and hence must be counted in all the categories to which it belongs. Eg an inherited class definition would be counted in both categories 2 and 4. The program must read the input code (for counting) from an external file (input.txt), and write the results into an output file (output.txt)
Question 3:
Write a Java Code Analyzer Program (in any language of your choice) that determines in an input file, the total number of lines containing each of the following categories:
1) Objects declaration
2) Class definition
3) Constructor definition
4) Inherited Class definition
Note that a single line could contain instances from more than one categories listed above, and hence must be counted in all the categories to which it belongs. Eg an inherited class definition would be counted in both categories 2 and 4. The program must read the input code(for counting) from an external file (input.txt), and write the results into an output file (output.txt)

Reviews

There are no reviews yet.

Be the first to review “CS347 – ASSIGNMENT 2: (Solution)”

Your email address will not be published. Required fields are marked *