EE308_Lab1-2

Gen_power 2022-10-28 01:37:48

目录

  • Links
  • Github link
  • 1. PSP form
  • 2. Problem-solving ideas
  • 3. Code description
  • testcode.cpp
  • Keywords
  • Count
  • Output
  • 4. Summary

Links

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZU202201
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/608734907
The Aim of This AssignmentTo achieve a program function, it can extract keywords of different levels from the C or C++ code files that are read in.
MU STU ID and FZU STU ID20123116_832001212

Github link

1. PSP form

Personal Software Process StagesEstimated time/minutesCompleted Time/minutes
Planning3040
Estimate1530
Development3030
Analysis90120
Design Spec1020
Design Review2020
Coding Standard3035
Design5090
Coding120180
Code Review1015
Test2020
Postmortem & Process Improvement Plan3060
Total455660

2. Problem-solving ideas

img

3. Code description

testcode.cpp

#include <iostream>  
using namespace std;
int main() {  
    int i = 1;  
    double j = 0;  
    long f;  
    switch(i) {  
        case 0:  
        break;  
        case 1:  
        break;  
        case 2:  
        break;  
        default:  
        break;  
    }  
    switch(i) {  
        case 0:  
        break;  
        case 1:  
        break;  
        default:  
        break;  
    }  
    if (i < 0) {  
        if (i < -1) {}  
        else {}  
    }  
    else if (i > 0) {  
        if (i > 2){}  
        else if (i == 2) {}  
        else if (i > 1) {}  
        else {}  
    }  
    else {  
        if (j != 0) {}  
        else{}  
    }  
    return 0;  
}

Keywords

string Keyword[32]=
{
    "auto", "break", "case", "char", "const", "continue", "default", "double", 
    "do", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", 
    "register", "return", "short", "signed", "sizeof", "static", "struct", 
    "switch", "typedef", "union", "unsigned", "void", "volatile", "while"
};

Count

for (int i = 0; i < 32; i++ ) {
        if (match(str, Keyword[i]) == 1) {
            total_num++;
            break;
        }
    }
    for (int i = 0; i < 32; i++ ) {
        if (match(str, Keyword[i]) == 1){
            if (match(str, "switch") ) {
                Case_num.push_back(case_num);
                switch_num++;
                case_num = 0;
            }
            if (match(str, "case")){
                case_num++;
            }
            break;
        }
    }
if (match(str, "else if" )){
        top++;
        stack[top] = 2;
    }    
    else {
        if (match(str, "else")) {
            if (stack[top] == 1 ) {
                if_else_num++;
                top--;
            }
            else {
                if (stack[top] == 2 ) {
                    if_elseif_else_num++;
                    top--;
                }
            }
        }
        else {
            if (match(str, "if")) {
                top++;
                stack[top] = 1;
            }
        }
    }

Output

img

4. Summary

I think this task is difficult. The time I finish the report is beyond the estimated time but I have learnt a lot, such as C++ programing and github.

...全文
98 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
FASMARM v1.42 This package is an ARM assembler add-on for FASM. FASMARM currently supports the full range of instructions for 32-bit and 64-bit ARM processors and coprocessors up to and including v8. Contents: 1. ARM assembly compatibility 2. UAL and pre-UAL syntaxes 3. IT block handling 4. Alternate encodings 5. Output formats 6. Control directives 7. Data definitions 8. Defining registers lists inside macros 9. Half-precision number formatting 10. Variants supported 11. Further information 12. Version history _______________________________________________________________________________ 1. ARM assembly compatibility There are a few restrictions how the ARM instruction set is implemented. The changes are minor and mostly have a minor impact. For the most part the basic instruction outline is the same. Where possible the original style is used but there are some differences: Not everything matches the ARM ADS assembly style, where possible the original style is used but there are some differences 1) label names cannot begin with a digit 2) CPSIE and CPSID formats are changed, use "iflags_aif" form instead of "aif" (eg. "CPSIE iflags_i" instead of "CPSID i") 3) SRS with writeback must have a separating space after the mode number and before "!" (eg. "SRSDB 16 !" instead of "SRSDB 16!") 4) macro, rept, irp, format, if, virtual etc. are all significant changes from the ARM ADS, so you will need to re-write those sections of existing code Original ARM Syntax | fasmarm Syntax ----------------------+---------------------- cpsie a | cpsie iflags_a | srsdb #29! | srsdb #29 ! ;or, | srsdb 29 ! _______________________________________________________________________________ 2. UAL and pre-UAL syntaxes fasmarm supports the original pre-UAL syntax and the newer UAL syntax. These two syntaxes only affect THUMB encodings. UAL stands for: Universal Assembly Language. pre-UAL syntax is selected wi

285

社区成员

发帖
与我相关
我的任务
社区描述
福州大学 梅努斯国际工程学院 软件工程(2022秋) 教学
软件工程 高校
社区管理员
  • LinQF39
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧