CoBrA (Code Browsing Analyzer) PDF
CoBrA (Code Browsing Analyzer) PDF
ABDUL HANAN
MUHAMMAD UMER
SESSION 2016-2020
CoBrA (Code Browsing Analyzer)
Undertaken By:
ABDUL HANAN
REG.NO. CIIT/FA16-BCS-145/WAH
MUHAMMAD UMER
REG.NO. CIIT/FA16-BCS-116/WAH
Supervised By:
DR. FAISAL AZAM
SESSION 2016-2020
DEDICATION
To our beloved parents and helping teachers who supported us in every step
of our life. Without their support, we would not able to complete our project.
We specially thank to our teachers who always motivated and helped us out
in our difficult times. Special dedication to all the current successors of Chistia
Order for their blessings and prayers for me. Special Thanks to Almighty Allah
who has blessings upon us and with His help we are able to complete our
project within stipulated time.
Abdul Hanan
Muhammad Umer
i
ACKNOWLEDGEMENT
All the deepest sense of gratitude to Almighty ALLAH, the most
compassionate and merciful who is omnipotent and omnipresent, and has
divulged His knowledge to man, without His help and blessings, we wouldn’t
have completed this project.
We are highly obliged to our teachers especially Sir Faisal Azam and Sir
Naveed Zaidi, who helped in improvising project idea as well as motivated us
time to time and made us work hard to complete and present our project in a
better way, especially the trust of our supervisor upon our skills, which enabled
us to complete our project.
ii
PROJECT BRIEF
PROJECT NAME: CoBrA (Code Browsing Analyzer Windows
based).
PROJECT OBJECTIVE: OBJECTIVE OF SYSTEM IS TO HELP CPP
PROGRAMMERS TO ANALYZE THEIR CODE
IN SENSE OF NUMBER OF LINE OF CODE,
FUNCTIONS, LOCAL AND GLOBAL
VARIABLES AND ALSO MAKING REPORT
OF THE WHOLE PROGRAM.
UNDERTAKEN BY: ABDUL HANAN
MUHAMMAD UMER
SUPERVISED BY: DR. FAISAL AZAM
DEPARTMENT OF COMPUTER SCIENCES
CUI, WAH CAMPUS
PAKISTAN
STARTED IN: SEPTEMBER 2019
COMPLETED ON: AUGUST, 2020
SOURCE LANGUAGE: C#
iii
ABSTRACT
CoBrA (Code Browsing Analyzing) is a Windows-based application which help the
programmers to see overview of their program while removing comment and detecting
functions and variables in their program. Comment removing is done by reading whole code
line by line all comments are detected and removed by self-written code. Macros are detected
by reading all lines in user-written program and resolve all macros by replacing all macros
with its values all work is done by self-written code. Variables and functions are detected by
reading whole program line by line. All modules have code written by our team no single
external library is used in implementation of whole project.
iv
Table of Contents
CHAPTER 1 ................................................................................................................................................. 1
INTRODUCTION ......................................................................................................................................... 1
1.1. Introduction.................................................................................................................................. 2
1.2. Project Overview .............................................................................................................................. 2
1.2.1. Product Features and Functions ......................................................................................... 2
1.2.2. Remove Comment................................................................................................................. 2
1.2.3. Manage Macros..................................................................................................................... 3
1.2.4. Identify functions and variables .......................................................................................... 3
1.2.5. Populate Database ................................................................................................................ 3
1.2.6. Generate Report.................................................................................................................... 3
1.3.1 Program’s Report generation ............................................................................................... 4
1.3.2 Understanding Overall code details ..................................................................................... 4
1.4. Similar system information .............................................................................................................. 4
1.4.1. Sourcetrail ............................................................................................................................. 4
1.4.2. Source Insight ....................................................................................................................... 4
1.5. Scope of the project .......................................................................................................................... 4
1.6. Area of application ........................................................................................................................... 5
1.7. Machinery .......................................................................................................................................... 5
1.8. Goal .................................................................................................................................................... 5
1.9. Software Requirements .................................................................................................................... 5
1.10. Hardware Involved ......................................................................................................................... 5
1.11. Target users ..................................................................................................................................... 5
CHAPTER 2 ................................................................................................................................................. 7
BACKGROUND RESEARCH ................................................................................................................... 7
2.1. Existing Systems................................................................................................................................ 8
2.2. Sourcetrail ......................................................................................................................................... 8
2.3. Source Insight.................................................................................................................................... 8
2.4. Idea generation.................................................................................................................................. 8
2.5. Software development ...................................................................................................................... 9
2.6. Hardware development .................................................................................................................... 9
2.7. Limitations and constraints ............................................................................................................. 9
2.7.1. Software constraint............................................................................................................... 9
2.7.2. Hardware constraint ............................................................................................................ 9
2.8. Language constraint ......................................................................................................................... 9
2.9. Conclusion ......................................................................................................................................... 9
CHAPTER 3 ...............................................................................................................................................10
DESIGN ......................................................................................................................................................10
3.1. Introduction.....................................................................................................................................11
3.2. Requirements ..................................................................................................................................11
3.2.1. Software requirements .......................................................................................................11
3.2.2. Hardware Requirements ....................................................................................................11
3.3. Functional Requirements ...............................................................................................................11
3.4. Other non-functional attributes ....................................................................................................14
3.5. UML Diagrams ...............................................................................................................................16
3.5.3. Class Diagram .....................................................................................................................19
3.5.4. Sequence Diagram: .............................................................................................................19
3.5.6. Activity Diagram: ...............................................................................................................22
CHAPTER 4 ...............................................................................................................................................24
IMPLEMENTATION ..................................................................................................................................24
4.1. Introduction.....................................................................................................................................25
4.2. Connectivity with Database ...........................................................................................................25
4.3. Application Development ...............................................................................................................26
CHAPTER 5 ...............................................................................................................................................33
TESTING AND INTEGRATION ..............................................................................................................33
5.1. Introduction.....................................................................................................................................34
5.2. Types of testing ...............................................................................................................................34
5.2.1. Unit testing ..........................................................................................................................34
5.2.2. Integration testing...............................................................................................................34
5.2.3. System testing ......................................................................................................................35
5.3. Testing Strategies ............................................................................................................................35
5.4. Test Cases ........................................................................................................................................35
5.4.1. Test Case 1 ...........................................................................................................................35
5.4.2. Test Case 2 ...........................................................................................................................36
5.4.3. Test Case 3 ...........................................................................................................................36
5.4.4. Test Case 4 ...........................................................................................................................36
5.4.5. Test Case 5 ...........................................................................................................................36
5.4.6. Test Case 6 ...........................................................................................................................37
5.4.7. Test Case 7 ...........................................................................................................................37
5.5. Ease of use .......................................................................................................................................37
CHAPTER 6 ...............................................................................................................................................38
CONCLUSION ...........................................................................................................................................38
6.1. Conclusion ...........................................................................................................................................39
REFERENCES & APPENDICES ...........................................................................................................40
References...................................................................................................................................................... i
Appendix A Abbreviations........................................................................................................................... i
Appendix B Code Schematics ..................................................................................................................... ii
List of Figures
Figure 3.1. Use Case ...................................................................................................................................18
Figure 3.2. Class Diagram ..........................................................................................................................18
Figure 3.3. Sequence Diagram....................................................................................................................21
Figure 3.4. Activity Diagram ......................................................................................................................23
Figure 4.1. Database ...................................................................................................................................25
Figure 4.2. Database Connection ................................................................................................................26
Figure 4.3. Main Interface of Application ..................................................................................................27
Figure 4.4. Browse ......................................................................................................................................16
Figure 4.5. Folder Selected .........................................................................................................................28
Figure 4.6. Remove Comments ..................................................................................................................19
Figure 4.7. Resolve Macros ........................................................................................................................21
Figure 4.8. Analyze.....................................................................................................................................29
Figure 4.9. After Analyze ............................................................................................................................30
Figure 4.10. Results .....................................................................................................................................30
Figure 4.11. Variables..................................................................................................................................31
Figure 4.12. Functions .................................................................................................................................31
Figure 4.13. Libraries ..................................................................................................................................32
List of Tables
Table 3.1. Browse ........................................................................................................................................11
Table 3.2. Syntax .........................................................................................................................................12
Table 3.3. Tokenization ...............................................................................................................................12
Table 3.4. Populating database ....................................................................................................................13
Table 3.5. Definition ....................................................................................................................................14
Table 3.6. Report Generation.......................................................................................................................14
Table 5.1. Testing of Browsing ...................................................................................................................35
Table 5.2. Testing Browsed Data ................................................................................................................36
Table 5.3. Testing Macros ...........................................................................................................................36
Table 5.4. Testing Macros are Resolved .....................................................................................................36
Table 5.5. Testing variables .........................................................................................................................36
Table 5.6. Testing functions ........................................................................................................................37
Table 5.7. Testing database .........................................................................................................................37
CHAPTER 1
INTRODUCTION
Introduction
1.1. Introduction
In today’s world, programmers face difficulty while making large projects and making test cases
for white box testing of their project. They make great effort to understand code of project to find
out all variables and function. There have been many technological advancements for
programmers. But some of these products are either highly expensive or some of these products
are offering less features. So, it is a dream of every programmer to have a such product which can
offer maximum support to them in an economical cost.
CoBrA is designed to offer the following things to programmer community to make their lives
much easier:
• Remove Comment
• Manage Macros
• Identify functions and variables
• Populate Database
• Generate Report
CoBrA 2
Introduction
CoBrA 3
Introduction
All the applications or projects have some objectives. These objectives are achieved using tools
and continuous working on the target goal. The main objectives of CoBrA Windows Based User
& Assistant App are as follows:
1.4.1. Sourcetrail
Source Insight parses your source code and maintains its own database of symbolic
information dynamically while you work and presents useful contextual information to
you automatically. Source Insight also can display reference trees, class inheritance
diagrams, and function call trees. Source Insight has a group of auxiliary panel windows
that work together to give you quick and useful navigation of source code and source
information.
CoBrA 4
Introduction
project planning that involves determining and documenting a list of specific project goals,
deliverables, features, functions, tasks, deadlines, and ultimately costs. The application
performs Remove Comment, Manage Macros, identify functions and variables, Populate Database,
Generate Report. Report generation is of variables and functions details from database is 1st time done
for the ease of programmer community.
Area of application is necessary to take into consideration to determine whether device is going to
be useable and helpful for someone or it is just useless. Windows-based application has vast area
of deployment for the programmer community as they were our primary target to facilitate them.
1.7. Machinery
Due to rapidly changing technologies, latest software today will become the old version of
tomorrow. So latest tools and technologies have being used which will enable the user and
developer to work efficiently and to meet the future requirements.
1.8. Goal
Goal is to facilitate maximum to the programmer community after coding their program to keep
informed about their overall code to know about their logic while making a large program.
CoBrA 5
Introduction
CoBrA 6
CHAPTER 2
BACKGROUND RESEARCH
Background Research
2.2. Sourcetrail
Sourcetrail is a cross-platform source explorer that helps you get productive on unfamiliar source
code. It uses static analysis on C, C++ source code and lets you navigate the collected
information within a user interface that interactively combines graph visualization and code
display
Source Insight parses your source code and maintains its own database of symbolic information
dynamically while you work and presents useful contextual information to you automatically.
Source Insight also can display reference trees, class inheritance diagrams, and function call
trees. Source Insight has a group of auxiliary panel windows that work together to give you
quick and useful navigation of source code and source information.
• Sourcetrail is a cross-platform source explorer that helps you get productive on unfamiliar
source code. It uses static analysis on C, C++ source code and lets you navigate the
collected information within a user interface that interactively combines graph
visualization and code display
CoBrA 8
Background Research
• Source Insight parses your source code and maintains its own database of symbolic
information dynamically while you work and presents useful contextual information to
you automatically. Source Insight also can display reference trees, class inheritance
diagrams, and function call trees. Source Insight has a group of auxiliary panel windows
that work together to give you quick and useful navigation of source code and source
information.
2.9. Conclusion
In this chapter we have discussed the various products which are available in the market for the
target community. As each product varies from one to another with difference in the features
provided to user community which always lefts a room for the improvement. So, our product is
basically a step forward to improve the feature quality within an affordable cost.
CoBrA 9
CHAPTER 3
DESIGN
Design
3.1. Introduction
CoBrA is a Windows based application build to facilitate programmers. It has some system requirements to
facilitate. For proper functioning of system this chapter will provide all the knowledge about system.
3.2. Requirements
As whenever we are going to develop a product, it has some requirements related to the system on which it is
being to be developed.
3.2.1. Software requirements
As every product is developed with the use of tools and software. So, the software which are
involved during the development of this product are as follows:
• Visual Studio IDE
• Local Database
• Windows OS
• Adobe Photoshop
• Dev IDE.
3.2.2. Hardware Requirements
N/A
1. User should be able to browse their project folder containing C++ file.
Criteria Remarks
Criticality This requirement is most essential in our project, as project name
shows our main task is to browse code for its analysis. If this
requirement is missing from the project the project will collapse and
became a garbage for user.
Technical Issues Designing is not a complicated task, but implementation of this
requirement involves some issues such as checking whether the selected
folder is C++ project or not, folder contains many different files, so we
must extract (.cpp) file.
CoBrA 11
Design
Cost The cost applied for the above discussed issue are we just added if
conditions that increases the compilation time of software.
Risk There are two main circumstances in which this functionality will not work:
2. Checking syntax of C++ code file that the code written is file is according to C++ syntax.
Table 3.2. Syntax
Criteria Remarks
Criticality This requirement is an essential in our project, as project name shows our main
task is to browse code for its analysis. If this requirement is missing from the
project the project will unable to perform actual functionality as if the syntax is
not correct according to C++ the variables and function will surely not be
extracted correctly and then system will have no value.
Technical Issues Implementation of this requirement involves some issues such as
identifying whether C++ language have only one syntax for a statement
or there exist different syntax.
Cost The cost applied for the above discussed issue are we studied this
language from different websites
Risk There are some circumstances in which this functionality will not work:
The selected folder is empty or does not have any C++ file.
3. Extract every word written in C++ code file (Tokenization) .
Table 3.3. Tokenization
Criteria Description
Criticality This requirement is an essential in our project, as project name shows
our main task is to browse code for its analysis. If this requirement is
missing from the project the project will be unable to perform actual
CoBrA 12
Design
Criteria Description
Criticality This requirement is an essential in our project, as project name shows our main
task is to browse code for its analysis database is important for stubbing. If this
requirement is missing from the project the project will unable to perform some
functionalities like stubbing and report generation.
Technical Issues Implementation of this requirement involves some issues such as data is
dependent on each other that is why for populating data sometimes we
first must extract data from database.
Cost The cast applied for the above discussed issue are we made extra function that
increases the compilation time as well as run time of system.
Risk i. The selected folder has one or more file that have some syntax
error. User must clear the syntax error for perfect working.
ii. The selected folder is empty or does not contain any C++ file.
iii. Syntax Analyzer ignore syntax error.
5. Defining declared but undefined functions and variable.
CoBrA 13
Design
Criteria Description
Criticality This requirement is an essential in our project, as project name shows
our main task is to browse code for its analysis stubbing is required. If
this requirement is missing from the project the project will unable to
perform some functionalities in case if the project is embedded system.
Technical Issues Implementation of this requirement involves some issues such as
function is declared in header file but defined in source file.
Cost The cast applied for the above discussed issue are we used database
every time function is checked from database that function is defined or
not.
Risk i. The selected folder has one or more file that have some syntax
error. User must clear the syntax error for perfect working.
ii. The selected folder is empty or does not contain any C++ file.
iii. Syntax Analyzer ignore syntax error.
iv. Tokens are not extracted perfectly.
6. Report generation using database.
Table 3.6. Report Generation
Criteria Description
Criticality This requirement is an essential in our project as one of our main tasks is report
generation of project.
Technical Issues There is no as such issue in report generation.
Cost No cost is involved.
Risk No risk.
CoBrA 14
Design
Attributes Description
Reliability Our system is reliable in its environment it will work perfectly and achieve its
goal.
Maintainability The system is maintainable we will give our services to maintain the
system.
Portability System is portable, if user want to change their computer, they can
install the system on another computer and simply analyze their project,
but it cannot be converted to another platform.
Extensibility System is extensible if user want another functionality, we can add that
functionality easily to some extent.
Reusability The system is reusable every time. If system analyzed the project after
that it will be ready to analyze another project
Application System is compatible with windows platform
Affinity/Compatibility
Resource Utilization The system will use some resources of computer as RAM and Hard disk
for database
Serviceability The system is serviceable if system fails in some unknown
circumstances, we will give our service to check error.
CoBrA 15
Design
A use case diagram is a dynamic or behavior diagram in UML. Use case diagrams model the
functionality of a system using actors and use cases. Use cases are a set of actions, services, and
functions that the system needs to perform. In this context, a "system" is something being
developed or operated, such as a web site. The "actors" are people or entities operating under
defined roles within the system.
CoBrA 16
Design
Interfaces are model elements that define sets of operations that other
model elements, such as classes, or components must implement.
CoBrA 17
Design
CoBrA 18
Design
A sequence diagram simply depicts interaction between objects in a sequential order i.e. the
order in which these interactions take place. We can also use the terms event diagrams or event
scenarios to refer to a sequence diagram. Sequence diagrams describe how and in what order the
objects in a system function. These diagrams are widely used by businessmen and software
developers to document and understand requirements for new and existing systems.
Actors – An actor in a UML diagram represents a type of role where it interacts with the system
and its objects. It is important to note here that an actor is always outside the scope of the system
we aim to model using the UML diagram.
We use actors to depict various roles including human users and other external subjects. We
represent an actor in a UML diagram using a stick person notation. We can have multiple actors
in a sequence diagram.
CoBrA 19
Design
We display a lifeline in a rectangle called head with its name and type. The head is located on
top of a vertical dashed line (referred to as the stem) as shown above. If we want to model an
unnamed instance, we follow the same pattern except now the portion of lifeline’s name is left
blank.
CoBrA 20
Design
CoBrA 21
Design
We use Activity Diagrams to illustrate the flow of control in a system and refer to
the steps involved in the execution of a use case. We model sequential and
concurrent activities using activity diagrams. So, we basically depict workflows
visually using an activity diagram. An activity diagram focuses on condition of flow
and the sequence in which it happens. We describe or depict what causes a event
using an activity diagram.
An activity diagram portrays the control flow from a start point to a finish point
showing the various decision paths that exist while the activity is being executed.
We can depict both sequential processing and concurrent processing of activities
using an activity diagram. They are used in business and process modelling where
their primary use is to depict the dynamic aspects of a system.
CoBrA 22
Design
CoBrA 23
CHAPTER 4
IMPLEMENTATION
Implementation
4.1. Introduction
In the software development, implementation phase comes right after the design phase. It is a most
critical phase of development where we have to integrate software modules.
Here we will divide the development of the device into two phases which are as follows:
• Software Implementation
• Connectivity with Database
So, the above-mentioned phases are the most important phases that are involved in software
development.
CoBrA 25
Implementation
CoBrA 26
Implementation
CoBrA 27
Implementation
Below interface is the interface after selecting folder containing C++ files.
CoBrA 28
Implementation
CoBrA 29
Implementation
CoBrA 30
Implementation
CoBrA 31
Implementation
CoBrA 32
CHAPTER 5
TESTING AND INTEGRATION
Testing and Integration
5.1. Introduction
Testing is an investigation conducted to provide information about the quality of the product or
service under test. It can also provide an objective, independent view of the product and
understand the risks of products. Test techniques include, but are not limited to, the process of
executing a program or application with the intent of finding bugs (errors or other defects).
Testing has been done step by step after the completion of each module of the hardware and
android application. The development of hardware and application is divided in small chunks
which have been tested as they are developed so they can be ready and bug free for use. Testing
can be stated as the process of validating and verifying that a product.
• Meets the requirements that guided its design and development.
• Works as expected.
• Can be implemented with the same characteristics.
CoBrA 34
Testing and Integration
working properly. Any person has to signup first before login. Either hardware is working
properly or not. We have to check either hardware data is being stored in the real time
database or not. We have to check either the data is being correctly displayed in the
android application or not. All of this is done in the integration testing.
5.2.3. System testing
Entire system is tested as per the requirements. Black-box type testing that is based on
overall requirements specifications, covers all integrated parts of a system.
Complete testing is done after completion of hardware and android application. We go
through all the scripts of project and all functionalities, interfaces and databases. Features
and functionality and working is viewed and tested separately.
Test case This test checks if the algorithm is browsing folder or not.
Test Procedure Folder is selected to check browsing results.
Expected Result C++ files are detecting properly.
Actual Result Yes, browsing is performed accurately.
CoBrA 35
Testing and Integration
Test case This test checks whether browse function is working properly or not.
Test Procedure Check the browse function results in the application.
Expected Result Files extracted by browse function have cpp code showed in application.
Actual Result Browse function fetched data properly.
Comment Result function is working fine.
Accuracy Accuracy is achieved.
5.4.3. Test Case 3
Table 5.3. Testing Macros
Test case This test checks whether macros are resolved properly or not.
Test Procedure Check the macros are resolved in application.
Expected Result Macros are resoling properly.
Actual Result Result is correct.
Comment Result function is working fine.
Accuracy Accuracy is achieved.
5.4.5. Test Case 5
Table 5.5. Testing variables
CoBrA 36
Testing and Integration
Test case This test checks whether functions are detected properly.
Test Procedure User click function detection button.
Expected Result functions are detected properly.
Actual Result Result is correct.
Comment Result function is working fine.
Accuracy Accuracy is achieved.
Test case This test checks whether functions are detected properly.
Test Procedure User click update database function.
Expected Result Database is populated properly.
Actual Result Result is correct.
Comment Result function is working fine.
Accuracy Accuracy is achieved.
CoBrA 37
Testing and Integration
Furthermore, in addition to this, the application can be easily moved from one computer
to another because this application has its own local database that will also copy with this
application.
CHAPTER 6
CONCLUSION
CoBrA 38
Conclusion
6.1. Conclusion
CoBrA is windows-based application developed for programmers and students of computer
programming specifically which helps them most in their work. Further improvements in
this project can be made. That is use for hardware-based programs in different languages.
Until now we have achieved Browsing Code, Detecting, and resolving macros, detecting
variables and functions, Creating Database and populating it. The future versions of this project
can include multiple features like language detection etc.
So, we have multiple opportunities for CoBrA. As it is an economical product due to its low
development cost. So, this product can become a successful venture in the market and it will be
a true achievement.
CoBrA 39
REFERENCES & APPENDICES
References & Appendices
Appendix A Abbreviations
Definition, Acronym & Abbreviations
Acronym &Abbreviations Meanings
CoBrA Code Browsing Analyzer
SRS Software Requirement Specification
UML Unified Modeling Language
GUI Graphical User Interface
CLI Command Line Interface
API Application Program Interface
RAM Random Access Memory
GB Giga Byte
GHz Gigahertz
ROM Read Only Memory
ER Entity Relationship
Let’s Move i
References & Appendices
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CoBra_revise
class variable_function
string[] tokens;
this.line = line;
this.line = line;
this.lines = null;
Let’s Move ii
References & Appendices
//split line by ;
if (line.Contains(";"))
this.lines = this.line.Split(';');
return true;
return false;
string[] sep_v_of_same_t;
if (variable_line.Contains(","))
if (data_type.Contains("*")) {
data_type = data_type.Trim('*');
sep_v_of_same_t_list.Add(data_type+" pointer");
sep_v_of_same_t = variable_line.Split(',');
sep_v_of_same_t[i] = sep_v_of_same_t[i].Trim('*');
sep_v_of_same_t[i] = sep_v_of_same_t[i].Trim();
if (sep_v_of_same_t[i].Contains(data_type))
sep_v_of_same_t_list.Add(sep_v_of_same_t[i]);
else if (data_type.Contains("["))
sep_v_of_same_t = variable_line.Split(',');
sep_v_of_same_t[i] = sep_v_of_same_t[i].Trim();
if (sep_v_of_same_t[i].Contains(data_type))
sep_v_of_same_t_list.Add(sep_v_of_same_t[i]);
else
sep_v_of_same_t_list.Add(data_type);
Let’s Move iv
References & Appendices
sep_v_of_same_t = variable_line.Split(',');
sep_v_of_same_t[i] = sep_v_of_same_t[i].Trim();
if (sep_v_of_same_t[i].Contains(data_type))
sep_v_of_same_t_list.Add(sep_v_of_same_t[i]);
//seprate it
else
if (data_type.Contains("*"))
data_type = data_type.Trim('*');
variable_line = variable_line.Trim('*');
variable_line = variable_line.Trim();
sep_v_of_same_t_list.Add(data_type);
sep_v_of_same_t_list.Add(variable_line);
else if (variable_line.Contains("["))
Let’s Move v
References & Appendices
//variable_line = variable_line.Trim('[');
//variable_line = variable_line.Trim(']');
variable_line = variable_line.Trim();
sep_v_of_same_t_list.Add(data_type);
sep_v_of_same_t_list.Add(variable_line);
else
variable_line = variable_line.Trim();
sep_v_of_same_t_list.Add(data_type);
sep_v_of_same_t_list.Add(variable_line);
return sep_v_of_same_t_list;
string datatype="";
if (this.lines == null)
Let’s Move vi
References & Appendices
datatype = check_for_premitive_dt(line);
if (datatype!=null)
if (!line.Contains("("))
variable_lines.Add(seprate_v_of_same_type(this.line, datatype));
else {
datatype = check_for_premitive_dt(lines[i]);
if (datatype!= null)
if (!lines[i].Contains("(")) {
variable_lines.Add(seprate_v_of_same_type(this.lines[i], datatype));
return variable_lines ;
if(str.Contains("short")) {
if (str.Contains("*"))
if (indexs.Count > 0)
return "short*";
else {
if (indexs.Count > 0) {
return "short"; }
if (str.Contains("long"))
if (str.Contains("*"))
//long int
else
//long int
//long double
if (str.Contains("*")) {
else {
else
Let’s Move ix
References & Appendices
if (str.Contains("*")) {
} else {
//simple long
if (str.Contains("int"))
if (str.Contains("*")) {
//MessageBox.Show(" i am called");
else
//MessageBox.Show(" i am called");
//remaining typess
if (str.Contains("float"))
Let’s Move x
References & Appendices
if (str.Contains("*"))
else
//remaining typess
if (str.Contains("double"))
if (str.Contains("*"))
//remaining typess
else
//remaining typess
if (str.Contains("char"))
Let’s Move xi
References & Appendices
if (str.Contains("*"))
else
//remaining typess
if (str.Contains("bool"))
if (str.Contains("*"))
//remaining typess
else
//remaining typess
if (str.Contains("wchar_t"))
if (str.Contains("*"))
else
//remaining typess
else
//remaining typess
return null;
if (String.IsNullOrEmpty(value))
if (str.Contains(value))
if (index == -1)
return indexes;
indexes.Add(index);
return indexes;
if (index != 0)
//middle case
return false;
else
return true;
//last case
return false;
else
return true;
else if (index == 0)
if (isalphabet_numb(str[index + value.Length]))
return false;
else
return true;
Let’s Move xv
References & Appendices
else
return true;
return false;
!(c == '_'))
return false;
//is alphanumeric
return true;
return false;
//get libraries
if (this.lines == null)
return false;
{ if (this.lines == null)
return false;
Data handler:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CoBra_revise
{
public class DataHandler
{
public bool addvariable(string nam, string typ, int dec, int def)
{
string query = @"INSERT INTO variable VALUES(@vname, @vtype, @vdef, @vdec)";
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("@vname", nam);
cmd.Parameters.AddWithValue("@vtype", typ);
cmd.Parameters.AddWithValue("@vdef", def);
cmd.Parameters.AddWithValue("@vdec", dec);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
MessageBox.Show(row["vname"].ToString()+ row["vtype"].ToString() +
row["vdef"].ToString() + row["vdec"].ToString());
}*/
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
}
public bool addfunction(string nam, string type, int dec, int def, int fuse)
{
cmd.Parameters.AddWithValue("@fname", nam);
cmd.Parameters.AddWithValue("@ftype", type);
cmd.Parameters.AddWithValue("@fdec", dec);
cmd.Parameters.AddWithValue("@fdef", def);
cmd.Parameters.AddWithValue("@fuse", fuse);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
string query = @"UPDATE functions SET fuse ='" +1+ "' Where fname =
'"+nam+"'";
// cmd.Parameters.AddWithValue("@fuse", 1);
//cmd.Parameters.AddWithValue("@fname", nam);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
}
cmd.Parameters.AddWithValue("@lname", nam);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
Let’s Move xx
References & Appendices
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
}
cmd.Parameters.AddWithValue("@mname", nam);
cmd.Parameters.AddWithValue("@mtype", type);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
}
}
}
}