EE302 Lab2 Extract the Keyword from a C/C++ file,
Program Requirements
-
Basic requirement: output "keyword" statistics
-
Advanced requirement: output the number of "switch case" structures, and output the number of "case" corresponding to each group
-
Uplifting requirement: output the number of "if else" structures
-
Ultimate requirement: output the number of "if, else if, else" structures
More info in CSDN Blog:
https://blog.csdn.net/Waiting_fade/article/details/120354565?spm=1001.2014.3001.5501
- For this time, we first care about the annotation and inCode (String, variable name) keyword, we should make judgement under these situation.
- After searching from the Internet, I decide using re module in python to match the basic function
- After Compelting level 1, the level can be easily extended if I design the logic clearly.
- For Worse considerasion, dealling with the code with not annotation is needed (struct in one line)
- Easy way to think, dealling line by line is not good for complexity
- Level 1 using dynamic array
Variable Name:
- abbreviation for loop iter name, not exactly meaning
- dash(_) for verb combination Indentation
- python standard
initial version for coding 20min ,debug input builded
bug fixed: string and Multiline-string ignore
bug fixed: do and double will rematch
bug fixed: annotation ignore
function add: input layer finished
function added: level 1 simple realization, debug output layer finished
function added: level 2 simple realization
function added:'switch num' output formatted
function added: level 3 logical realization, simple and incorret
remake for level 3&4 method(detail in blog), match the problem requirement basicaly cancel the debug output
bug fixed:
- ignore the variable name
- optimize the output layer
- ignore the
#include'
and#define
Thank you for readiing here! Program still have bug, keep updating utill ddl and found question