EE308_LAB1-2

m0_51284439 2022-10-27 20:41:57

EE308_LAB1-2

ways of solving a problem

First of all, the general reading topic is divided into two parts. The first part is to identify the statistical keywords, and the second part is to identify the statistical code structure.
The first part is the first part. For the extraction of code keywords and statistics I think usinghash tables will be very easy to complete this part of the work.The specific idea is to retrieve the keywords in the hash table, and then add the counter if present. 1. Add a new key value pair if not present.
The second part is the structure identification specifically divided into three structures of the identification.
However, the identification idea of several structures is roughly the same.
Ststack the keywords and "{" and "}". Clear when the "}" heap goes into the stack, clear to the previous "{", and heap the cleared portion into the buffer.
The structure is analyzed into multi-level conditions, and the subsequent conditions will start to verify when the preconditions are completed.

1.switch case

Here the switch case structure is set to a two-level condition, with a precondition of switch stacking into the stack..
Turn on the switch when the precondition is reached, and count when the case enters the stack. And turn off the switch when the switch enters the buffer.
prefix condition : switch
decide condition : case

2.if else

The structure takes if as a precondition and counts and switches off when the else enters the stack.
prefix condition : if
decide condition : else

3.if else if else

This part will switch to the second structure, which I analyze as a three-level condition.
first condition : if else
second condition : else if
third condition :else
The first condition will use the judgment of the ifelse structure. Switch 1 will open as the counter of the ifelse increases.
The second switch tube will be open in the else if {} in the buffer.
The decision criteria will verify that the next entry keyword is else when the second switch is on.

The above is through the analysis after reading the problem.

the flow chart of the key functions

请添加图片描述

Code descriptionHashMap<String, Integer> map = new HashMap<String,Integer>();

    for (String li : lists) { 
        if(li.length()<=1) continue;
        if(!map.containsKey(li)) {//Detects if it is already in the table
            map.put(li, 1);
        }else {
            Integer count = map.get(li);
            map.put(li, ++count);
        }
    }



//type1 switch case
                //Open the switch after switch enters the stack
                if(i==0) {
                  sw1=true;
                  sw++;
                }
                if(sw1==true&&i==1) ca++;//Start the case counting after the switch is on
                //Turn off the switch after "}" enters the stack and return to the zero counter
                if(sw1==true&&i==5) {
                    System.out.println("number of switch"+sw+" case = "+ca);
                    ca=0;
                    sw1=false;
                }



//type2 if else
                //The if else only has an else decision condition, so it does not set up a switch
                if(i==3) type2++;


//type3 if, else if, else
                //Determine the precondition and complete the precondition and close the switch
                if(sw2==true) {
                    if(i==3) type3++;
                    sw2=false;
                }


if(li.equals(table[5])) {
            //type3 if, else if, else
             List<String> buffer = new ArrayList<String>();//Create the buffer judgment preconditions
            sw2=true;
            //Eliminate after the "}" goes into the stack 
            while(true) { 
                if(!st.empty()&&!st.peek().equals(table[4])) {
                    buffer.add(st.peek());
                    st.pop();
                }else break;
            }
            if(!st.empty()) {
                buffer.add(st.peek());
                st.pop();
            }
            while(true) { 
                if(!st.empty()&&!st.peek().equals(table[4])) {
                    buffer.add(st.peek());
                    st.pop();
                }else break;
            }
            //Judge the preconditions, the condition of the switch on
            if(buffer.size()==4) {
            for(int i=0;i<buffer.size();i++) {
                if(!buffer.get(i).equals(type3buffer[i])) {
                    sw2=false;
                    break;
                }
            }
            }else sw2=false;
        }
      
     }

psp

psptime
Planning10
Estimate60
Development50
Analysis30
Design Spec20
Design Review20
Coding Standard10
Design20
Coding20
Code Review40
Test10
Reporting50
Test Report30
Size Measurement10
Postmortem & Process Improvement Plan10
390
The Link Your Class
The Link of Requirement of This Assignmenthttps://github.com/if-ish/EE308FZ-Lab1-2-Individual-programing-work
The Aim of This AssignmentKeyword statistics and structure identification
MU STU ID and FZU STU ID<20124635_832002210>
...全文
201 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用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创作助手写篇文章吧