You are on page 1of 24

Chapter-1 PROBLEM DEFINATION

As we know LINUX operating system is one of the popular and open source systems. A basic goal of the project is to improve the interaction between user and compiler by making compiler more useable and respective to the user’s need. It provides effective cross platform management. It includes designing of more users friendly and attractive GUI which comes along with interactive cross platform compiler. It also includes better features of both C and JAVA compiler. As we see that the Linux operating system has different terminal prompt for compile program of many programming language, but it causes problem like time consuming and userfriendness.General programmer has habit to use GUI editor. But still there is another problem we have to go for two different editors for java and c programming, today require to provide cross platform and reliability to Linux system. The objective of the application is to provide an integrated-development environment comprising of editing, compiling and debugging tools for C-C++ and JAVA programs on LINUX platform. The project will have a user-friendly GUI. The project shall support source- file editing and save changes to the LINUX system. The editor will support Syntax highlighting, data type recognition, error reporting and other features desirable for a program editor. The LINUX system compiler and debugger will be used for the interface libraries.

1

Chapter-2 LITERATURE SURVEY
While gathering information about the cross platform compiler for LINUX operating system, we came across the following points:

2.1 Existing C and JAVA GUI for LINUX OS:
In current Linux operating system, if we want to make C or JAVA programming then we has to do it in different editor window. At the time of running or compiling these programs we have to switch terminal prompts. Though the new version of LINUX provides compatibility to the software for c and java i.e. GNU LINUX version 2.95.3 and net beans for LINUX still we have to shift two different editor.

2.2 Existing compiler for LINUX OS:
Though the C and JAVA have many things in common in them (syntax: e.g.Controll statement) still LINUX provides two different libraries for both the technologies.

2.3 Limitations:
There are certain inconveniences with the access of editor of LINUX programming language which is been used by the current operating system. • • • • Time Consuming Provide complex environment Difficult for maintenance Difficult to handle error

2

2.4. New design of GUI
The most interesting part of this design is that user is provided with the both C and JAVA technology in single editor window. It would give the user effectiveness, efficiency, satisfaction, and save his precious time. Here the editor is provided with the facilities of error detection, output window etc. on same GUI. Shortcut icons will be provided for the functions which are mostly used like new, save, print, etc. HELP function will be provided which will help the user to get clear his queries like functions, syntax, etc.

2.5. New design of Cross platform compiler
Here a single compiler will be provided which will use the libraries of the existing compiler. During the phase of synthesis analyzer, cross compiler will call the existing compiler to use the lib. Files of the respective program. Compilation carried out by the compiler will be easy which will make the user easily identify his error and correct it.

Chapter-3 SOFTWARE REQURIMENT SPECIFICATION
3

3.1 Introduction
Compiler construction principles course is a core foundation stone in the computer science curriculum. It aims at researching the principles and technique in the design and construction of the compiler. With the wide application of electronic products and usage of Linux operating system, the integrated development environment bases on Linux operating system is becoming more and more widely applied in scientific research institutions. The cross-compiler on the platform can compile executable code for another platform. It’s a necessary tool in the integrate development environment. Although many works have been conducted on compilers little is done on their impact on software reliability. We select types of metrics in our study: time for compilation, user friendly environment, general framework of the compiler, relationship between cross compiler, compiler library. In this study, efficiency comparison of compilers and performance comparison of the binaries generated by that particular compiler for the same source code is considered as overall reliability concept of comparison. This basic conceptual idea is illustrated in Figure 3. 1 below.

Figure 3.1 Reliability concept of compiler

3.1.1 Project Objective: A system shall not waste your time or require you to do more work than is strictly necessary. Almost all of the user interface design principles are used in this GUI and compiler. It is to be designed with the objective of making it more user-friendly, time
4

saving for user, efficient traceability, and data modification can do easily, easy for maintenance. Data is secure, less time consuming, easy to handle error. The system will provide all the functionality of Turbo C and java editor ,status of the various activities to manage to facilitate the user of the system. These paper follow general framework of compiler and able to simulate the detail process of cross platform compiler. Student can learn the step by step phases of compiler. At the same time, it is great help to the improvement of student’ interest in programming and their capability. 3.1.2 User Characteristics: The users of the system are student or programmer who requires the system for essential work. The user who uses this system is assumed to have basic knowledge of the C and JAVA programming language along with LINUX operating system. The administrators of the system to have more knowledge of the internals of the system and is able to rectify the small problems that may arise due to disk crashes, power failures and other catastrophes to maintain the system. The proper user interface, users manual, online help and the guide to install and maintain the system must be sufficient to educate the users on how to use the system without any problems.

3.1.3 Operating Environment: The hardware and software requirements for the project are as follows: • Hardware Requirements: Hardware RAM Hard Disk
5

Sr. No. 1. 2.

Specification 512 MB 20GB

3.

Processor

Intel Pentium IV

Table 3.1 Hardware requirements • Software Requirements: Software Operating System C/C++ JAVA Description FEDORA 11 GNU C/C++ JDK 1.4 or higher

Sr. No. 1. 2. 3.

Table 3.2 Software requirements 3.1.4 Implementation Constraints

The system must be compatible with LINUX operating system. A programmer can focus on to logic only due to simplification in programming environment and productivity can be increased with most system efficiency utilization.

Editor will automatically detect the program compiler based on the syntax and format of the program. Cross platform compiler call corresponding existing libraries when desirable.

3.1.5 Assumptions and Dependencies: • •

User should be familiar with LINUX operating system. User must know basic knowledge of C and JAVA programming language. User necessity acquainted with use of compiler in programming software. System must support features of LINUX operating system. GUI of cross platform compiler contains all tools of programming language. Current system compiler must be link with required programming language compiler libraries.
6

• • •

System must be error free.

3.2 System Features:
The cross platform management comes with bulk of various features. These are explained as follows: 3.2.1 User-friendly: The design will provide user friendly environment to the user. Editor will be easy and simple to handle just as the editors used in windows, whereas the compilation part will also be easy which will make the user identify and clear the errors. Short cut icons will be provided for the instructions which are needed mostly. HELP function will be provided which will help the user to get clear his queries like functions, syntax, etc. 3.2.2 Affordance: The majority of Linux variants are available for free or at a much lower price, also many of the available software programs, utilities, and games available on Linux are freeware or open source. So as being a part of Linux this software will also be available as a freeware and hence will affordable to everyone who wants to use it.

3.3 External Interface Requirements:
The external interface requirements of the system are as follows: 3.3.1 User Interface: The interface must be capable of providing all requirements. User must familiar with the current operating system and has knowledge of C/C++ and JAVA programming language. 3.3.2 Software Interface: • OS: LINUX Fedora 12.4
7


Platform: C/C++, JAVA Link libraries of c and java existing compiler.

3.3.3 Hardware Interface: • • •
3.4

Intel Pentium IV or Higher processor 1.80 GHz 128 MB of RAM

Non-functional requirements
3.4.1 1. 2. 3. Performance requirements The system should be easy to handle. System should give expected performance results. The response time should be small.

3.4.2 1.

Security Requirements This application is used for particular technologies.

3.4.3 1. 2.

Software Quality Attributes The application is easy to interact and communicate with any user. This application provides better user interface for ease of working.

3.5 Analysis Model:
Data flow diagram shows the static view of the project. It also shows that what will be the output for given input. The main purpose of this diagram is to show fluency of the project. 3.5.1 Data Flow Diagram:

8

Write C/ JAVA Source code User

Save & compile Cross
Editor File Compiler

Cross

Generate Corresponding output
Output

Figure 3.2 Level 0 Data Flow Diagram

9

User

Write c/java Source code

Compile the file
Cross Editor Cross Platform Compiler

Analysis phase
Lexical Analyzer

Call
Syntax Analyzer

C Library

Call

Java Library

Semantic Analyzer

Partial code
Existing Compiler

C Compiler
Target Code

Java Compiler

Generate Output

Figure 3.3 Level1 DFD

10

3.5.2 Class Diagram:

Figure 3.4 Class Diagram

11

3.5.3 State transition (State Chart) Diagram:

Write a Source Program

Is .c or .java file

Compile a Program Java Program Lexical Analysis

C program

Syntax Analysis

Semantic Analysis Symbol Table Intermediate Code Generation Error Handling

Code Generation Code Optimization Target m/c Code

Figure 3.5 State chart diagram

12

3.6 System Implementation Plan:
Schedule of system implementation pan is displayed as following: Task Project research and analysis. Submission of synopsis. 2011 Requirement analysis and prepare system requirement specification. Prepare the user scenario, data design. Prepare analysis model: Use case, Activity, class, DFD diagrams. Prepare behavioral model: sequence, State chart diagrams. Prepare project schedule and tracking the project work. Preparation of partial project work for Semester I. Approval and submission of partial project report for the Semester I. 2011 6th September 2011 14th September 2011 th 26 September 2011 1st October 2011 th 10 October 2011 2011 12th September 2011 19th September 2011 th 30 September 2011 6th October 2011 th 15 October 2011 8th August 2011 22nd August From Date 11th July 2011 25th July To Date 18th July 2011 1st August 2011 16th August 2011 29th August Completed Completed Completed Completed Completed Completed Status Completed Completed

Completed

Table 3.3 System Implementation Plan

Chapter-4 SYSTEM DESIGN
4.1 System Architectures:
13

Figure 4.1 Block Diagram of Cross platform compilers The above figure present competitive analyses of ‘C and JAVA compiler’ impact on single cross platform compiler under LINUX based Fedora operating system (OS). The compiler considered includes GNU Compiler Collection (GCC), C/C++ Compiler, JAVA compiler, Graphical user Interface (GUI), and Run-time environment. We select five types of metrics in our study: User friendly environment, generated code size, compilation time, error handling, and compiler phases. In this study efficiency comparison of cross platform compiler and performance comparison of intermediate code generation of two different compiler in single unit. This basic conceptual idea is illustrated in Figure. Cross-compilation can also be applied to the compiler itself. This is referred to as Canadian Cross compilation which is technique for building a (cross-) compiler on different host different form the one the compiler should be run on. In this case have three different platforms: 1. The platform the compiler is built on (build). 2. The platform which hosts the compiler (host). 3. The platform for which the compiler generates code (target). These project follow general framework of compiler and able to simulate the detail process of cross platform compiler. Student can learn the step by step phases of
14

compiler. At the same time, it is great help to the improvement of student’ interest in programming and their capability.

4.1.1 Phase I :( Analysis Phase)
A. Lexical Analysis: This will split the source code up into tokens, i.e. names, numbers, operators and so on. It discards comments and white-space (i.e. blanks and newlines). A sequence of characters into subsequences called tokens. The process of searching for matched tokens is typically described using finite automata (FA) and regular expression (RE). a. Finite Automata (FA): One can compile any regular expression into a recognizer by constructing a generalized transition diagram called a finite automation. A finite automation can be deterministic means that more than one transition out of a state may be possible on a same input symbol. b. Deterministic Finite Automata (DFA): A deterministic finite automation is a special case of a non-deterministic finite automation (NFA) in which, no state has an -transition for each state s and input symbol a, there is at most one edge labeled a leaving s. A set of states: An initial state: A set of final states: A transition function: i.e. function that takes as input a state and a symbol, and returns a state. c. Non Deterministic Finite Automata (NFA): A nondeterministic finite automation is a mathematical model consists of 1. A set of states S 2. A set of input symbol, ∑, called the input symbols alphabet.
3. A transition function move that maps state-symbol pairs to sets of states.

4. A state so called the initial or the start state. 5. A set of states F called the accepting or final state.
15

d. Regular Expression: Regular expression is used to describe a set of strings. There are three basic operators: for options, ``*'' for repeating zero or more times, and ``+'' for repeating one or more times. B. Syntax Analysis: In syntax analysis phase compiler verify whether or not the tokens generated by lexical analyzer are grouped according to the syntactic rules of the language. e.g. x = (2+3) ∗ 9); // mismatched parentheses if x>y x = 2; // missing parentheses While (x==3) do f1(); // invalid keyword do Syntax-structure specification for the programming language uses context-free grammar (CFG). a. Context Free Grammar: A context-free grammar G is a quadruple, Where, V is an alphabet, (The set of terminals) is a subset of V, R (the set of rules) is a finite subset of S (the start symbol) is an element of. E→E*E E→E+E Backus Naur notation E: = E * E | E + E b. Syntax tree (Parse Tree): The output of the syntax analysis phase is a stream of atoms or syntax trees (Parser). A parse tree is a graphical representation of a derivation. In general, a parse tree is a tree where each node is labeled with The parser uses symbol-look-ahead and an approach called top-down parsing without backtracking. Top-down parsers check to see if a string generated by a grammar by creating a parse tree starting from the initial symbol and working down. Bottom-up
16

Normal CFG notation

parsers check to see a string can be generated from a grammar by creating a parse tree from the leaves, and working is illustrated in Figuare.3.

Figure 4.2 Parse Tree C. Semantic Analysis It Ensure that program obeys certain kinds of sanity checks i.e. all used variables are defined, types are used correctly, method calls have correct number and types of parameters and return value and store variable in symbol table. a .Symbol table management: An essential function of a compiler is to record the identifiers used in the source program and collect information about various attributes of each identifier. A symbol table is a data structure containing a record for each identifier, with fields for the attributes of the identifier. The data structure allows us to find the record for each identifier quickly and to store or retrieve data from that record quickly. When an identifier in the source program is detected by the lex analyzer, the identifier is entered into the symbol table as shown in Figure.4.3.

17

Figure 4.3: Symbol Table Storage Management for name b. Error Detection and Reporting: Each phase can encounter errors. A compiler that stops when it finds the first error is not as helpful as it could be. The syntax and semantic analysis phases usually handle a large fraction of the errors detectable by the compiler. The lexical phase can detect errors where the characters remaining in the input do not form any token of the language. Errors when the token stream violates the syntax of the language are determined by the syntax analysis phase. During semantic analysis the compiler tries to detect constructs that have the right syntactic structure but no meaning to the operation involved.

4.1.2 Synthesis Phase:
This phase will be executed by calling the existing compilers library files. It requires the interfacing of libraries.

4.2 UML diagram (Behavioral Diagram):
18

UML diagram shows dynamic view of model. 4.1.1 Use Case Diagram: It describes functional requirements of system, the manner that outside things interact at system boundary and the response of system. It captures use cases and actor interaction.

Figure 4.4 Use Case Diagram

4.1.2 Activity Diagram:
19

Activity diagram are model of behavioral system and they show the way in which behaviors are related in overall flow of system.

Figure 4.5 Activity Diagram Along With Swim lane

4.2.3 Sequence Diagram:
20

Sequence diagram is a structured representation of behavior as a series of sequential steps over a time.

Figure 4.6 sequence Diagram

Chapter -5 Technical Specification:
21

5.1. Advantages:
• • • • • • • • • Provide user friendly environment Time saving for user Efficient traceability Data modification can do easily Easy for maintenance Data is secure Less time consuming Easy to handle error The system will provide all the functionality of Turbo C and java editor ,status of the various activities to manage to facilitate the user of the system.

5.2 Disadvantage:
• Construction of cross compiler is time consuming.

Chapter-5 Appendix A: Glossary [Define terms, acronyms, and abbreviations used in the FRD]
22

Compiler A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).

Cross-Compiler A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is run.

GUI (GRAPHICAL USER INTERFACE) In computing GUI is a type of user interface that allows user to interact with electronic devices with images rather than text commands.

GCC (GNU Compiler Collection) The GCC is a compiler system produced by the GNU project supporting various programming languages

GNU Project It is free software, mass collaboration project announced on sep 27,1983.by Richard Stallman at MIT. GNU GNU is a UNIX like operating system developed by GNU project UML It means Unified Modeling Language. It enables system developers to specify, visualize, construct and document models.

Chapter-6 Bibliography
[1] Youtian QU, Huilai ZOU, Lili ZHONG ,“Design and Application of Assisted
23

Instruction Software for the Compiler Construction Principles with Java “, 978-0-7695-3825-9/09 $26.00 © 2009 IEEE DOI 10.1109/Embedded ComScalCom.2009.117 [2] Anil Kumar Karna, Hengming Zou, “Cross Comparison on C Compilers’ Reliability Impact on UNIX Based Fedora”, 978-0-7695-4108-2/10 $26.00 © 2010 IEEE. [3] “A New Construction Method of Common Embedded Cross Compiler Tool Based on Newlib” YUYang CAl Qixian GUO Sen, 978-1-4244-6585 9/10/$26.00 @2010 IEEE [4] “Linux Programming Bible” by John Goerzen ISBN #764546570, Hungry Minds. [5]”Principles of Compiler Design” of Technical Publications by A.A.Puntambker. [6] WeiDongShan. Embedded Linux application development entirely manual Beijing: Posts & Telecom Press, 2008. [7] ALFRED V AHO,RAVI SETHI,D ULLMAN, “Compilers:Priciples,Techniquies & Tools “.

24