Professional Documents
Culture Documents
ON
“MOUSE : A PROGRAMMING LANGUAGE COMPILER IN C ”
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE AND ENGINEERING
Submitted by
SANJU M [ ENG16CS160139 ]
SEEMA S [ ENG16CS0144 ]
SHAMANTH B M [ ENG16CS0146 ]
SRINISHA S [ ENG16CS0164 ]
VI Semester, 2018
Under the supervision of
Karishma Chavan
professor, Department of CSE,
Dayananda Sagar University.
Page 1 of 14
DAYANANDA SAGAR UNIVERSITY
School of Engineering, Kudlu Gate, Bangalore-560068
CERTIFICATE
_____________________
Chairman
Department of Computer Science and Engineering
Page 2 of 14
ACKNOWLEDGEMENT
It gives us a great sense of pleasure to present the report of the B. Tech. Project undertaken during
B. Tech fourth year. We owe special debt of gratitude to Prof. Karishma Chavan, Professor, De-
partment of Computer Science & Engineering, DSU, Karnataka for her constant support and guid-
ance through- out the course of our work. Her sincerity, thoroughness and perseverance have been a
constant source of inspiration for us. It is only her cognisant efforts that our endeavours have seen
light of the day.
We also take the opportunity to acknowledge the contribution of Dr. M K Banga, Chairman, De-
partment of Computer Science & Engineering, DSU, Karnataka for his full support and assistance
during the development of the project.
We also do not like to miss the opportunity to acknowledge the contribution of all faculty members
of the department for their kind assistance and cooperation during the development of our project.
Last but not the least; we acknowledge our family and friends for their contribution in the comple-
tion of the project.
Page 3 of 14
DECLARATION
We hereby declare that this submission is our own work and that, to the best of our knowledge and
belief, it contains no material previously published or written by another person nor material which
to a substantial extent has been accepted for the award of any other degree or diploma of the uni-
versity or other institute of higher learning, except where due acknowledge has been made in the
text.
Name:
SANJU M [ ENG16CS160139 ]
SEEMA S [ ENG16CS0144 ]
SHAMANTH B M [ ENG16CS0146 ]
SRINISHA S [ ENG16CS0164 ]
Page 4 of 14
TABLE OF CONTENTS
DECLARATION 4
ABSTRACT 6
INTRODUCTION 7
2. INTRODUCTION TO COMPILER 9
3. PROBLEM STATEMENT 10
LITERATURE REVIEW 11
DESIGN 12
IMPLEMENTATION 13
CONCLUSION 14
REFERENCES 14
Page 5 of 14
ABSTRACT
Compiler construction is a widely used software engineering exercise, and hence this paper presents
a compiler system for adaptive computing.
The final result of this project is to provide a general knowledge about compiler design and its im-
plementation. In order to develop effective compilation techniques, it is important to understand the
common characteristics of the programs during compilation. Although this paper concentrates on
the implementation of a compiler, an outline that builds upon the compiler is also presented. Mouse
has revolutionised the computer world. In GUI mouse is very essential for user interaction. it is a
simple input device which allows you to point and execute interface in a random and faster manner
than the keyboard which provides sequential interface. Mouse Programming is a topic which every
C programmer needs to have in his toolbox to have a cutting edge.It will be used almost every-
where.
This project describes optimisation techniques that have been implemented in a compiler which was
designed to produce code comparable to that produced by hand.
Additional optimisation methods were incorporated into successive versions of the compiler. It was
found that no single method was effective with all compiled programs but that each of the tech-
niques described was effective for some programs.
Page 6 of 14
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION
The Mouse programming language is a small computer programming language developed
by Dr. Peter Grogono in the late 1970s and early 1980s.[1][2][3] It was developed as an extension
of an earlier language called MUSYS, which was used to control digital and analog devices in an
electronic music studio.
Mouse was originally intended as a small, efficient language for microcomputers with limited
memory. It is an interpreted, stack-based language and uses Reverse Polish notation. To make an
interpreter as easy as possible to implement, Mouse is designed so that a program is processed as a
stream of characters, interpreted one character at a time.
The elements of the Mouse language consist of a set of (mostly) one-character symbols, each of
which performs a specific function (see table below). Since variable names are limited to one char-
acter, there are only 26 possible variables in Mouse (named A-Z). Integers and characters are the
only available data types.
Despite these limits, Mouse includes a number of relatively advanced features, including:
• Conditional branching
• Loops
• Pointers
• Arrays
• Code tracing
The design of the Mouse language makes it ideal for teaching the design of a simple interpreter.
Much of the book describing Mouse[3] is devoted to describing the implementation of two inter-
preters, one in Z80 assembly language, the other in Pascal.
1.2 DETAILS
The language described here is the later version of Mouse, as described in the Mouse book.
[3] This version is an extension of the language described in the original magazine article.[1]
1.3 EXPRESSIONS
Common idioms
These expressions appear frequently in Mouse programs.
Page 7 of 14
Figure 1 [1]
Figure 2 [1]
1.4 INPUT
Mouse may input integers or characters. When a character is input, it is automatically con-
verted to its ASCII code.
1.5 OUTPUT
Mouse may print integers, characters, or string constants, as shown in these examples. If an
exclamation point appears in a string constant, a new line is printed.
1.6 CONDITIONALS
A conditional statement has the general form:
B [ S ] ~ equivalent to: if B then S
Here B is an expression that evaluates to 1 (true) or 0 (false), and S is a sequence of statements.
Page 8 of 14
1.7 EXAMPLE PROGRAM
This short program prints 'Hello world.'
"Hello world."
$
2. INTRODUCTION TO COMPILER
2.1 INTRODUCTION
Computer programs are formulated in a programming language and specify classes of com-
puting processes. This paper provides an introduction to the new learning method for compiler con-
struction and designing, which aims at learning compiler design. Computers however, interpret se-
quences of instructions, but not the program texts. Therefore, the program text needs to be inter-
preted into a suitable instruction sequence before it is processed by a computer. This paper is aimed
at people interested in new learning approaches for understanding basis in computer science engi-
neering. Compilers and operating systems constitute the basic interfaces between a programmer and
the machine. Basically, Compiler is a program which converts high level programming language
into low level programming language or is converts source code into machine code.
The core compiler reads a program described in a high-level programming language. The compiler
then analyses the program, partitions it into hardware and software, and then generates data paths
for the reconfigurable hardware.[4] It focuses on the basic relationships between languages and ma-
chines. Therefore, the relationships ease the inevitable transitions to new hardware and program-
ming languages. In parallel, the software part is instrumented with functions for configuring and
exchanging with the reconfigurable hardware.
The term compilation denotes the conversion of an algorithm expressed in a human-oriented source
language to an algorithm expressed in a hardware-oriented target language. Also consider Conven-
tional programs give priority to knowledge in which competency is flexible and adaptable and can-
not be reduced to an algorithm.
Programming languages are the tools used to construct formal descriptions consists of finite compu-
tations (algorithms), in which each computation further consists of operations that transform a given
initial state into the final state. In the context of factual information that can consist of, for example,
a definition, a theorem, a hypothesis, a rule, or an algorithm. We shall be concerned with the engi-
neering of compilers.
2.2 LEXICAL
The lexical syntax (token structure), which is processed by the lexer and the phrase syntax,
which is processed by the parser. The lexical syntax is usually a regular language, whose alphabet
consists of the individual characters of the source code text. The phrase syntax is usually a context-
free language, whose alphabet consists of the tokens produced by the lexer.
2.3 PARSER
Within computational linguistics the term is used to refer to the formal analysis by a
computer of a sentence or other string of words into its constituents, resulting in a parse tree
showing their syntactic relation to each other which may also contain semantic and other
information.
Page 9 of 14
The term has slightly different meanings in different branches of linguistics and computer science.
In order to parse natural language data, researchers must first agree on the grammar to be used. The
choice of syntax is affected by both linguistic and computational concerns; traditional sentence
parsing is often performed as a method of understanding the exact meaning of a sentence, some-
times with the aid of devices such as sentence diagrams. It usually emphasizes the importance of
grammatical divisions such as subject and predicate.
Parsing or syntactic analysis is the process of analysing a string of symbols, either in natural lan-
guage or computer language.
3. PROBLEM STATEMENT
Make a compiler that translates computer code written in Mouse programming language
(the source language) into C programming language (the target language). The compiler is primarily
used for programs that translate source code from a high-level programming language to a lower
level language to create an executable program.
CHAPTER 2
Page 10 of 14
LITERATURE REVIEW
[1] Grogono, Peter (July 1979) on "Mouse / A Language for Microcomputers”, The paper describes
that The Mouse programming language is a small computer programming language developed by
Dr. Peter Grogono in the late 1970s and early 1980s.It was developed as an extension of an earlier
language called MUSYS, which was used to control digital and analog devices in an electronic mu-
sic studio.
[2] Lane, Tom; Grogono, Peter (June 1980) on "Comment and Correction for Mouse”, The paper
describes that a major benefit of a high-level programming language is that is is more easily under-
stood and debugged than that equivalent assembly language.
[3] Grogono, Peter on “ Mouse: A Language for Microcomputers”, The paper describes that The
elements of the Mouse language consist of a set of (mostly) one-character symbols, each of which
performs a specific function (see table below). Since variable names are limited to one character,
there are only 26 possible variables in Mouse (named A-Z). Integers and characters are the only
available data types.
[4] Charu Arora, Chetna Arora, Monika Jaitwal on “ RESEARCH PAPER ON PHASES OF COM-
PILER” , The paper describes that A compiler is a computer program (or set of programs) that
transforms source code written in a programming language (the source language) into another com-
puter language (the target language, often having a binary form known as object code). The most
common reason for wanting to transform source code is to create an executable program.
[5] Mahak Jain, Nidhi Sehrawat, Neha Muns on “ COMPILER BASIC DESIGN AND CON-
STRUCTION”, The paper describes that Compiler construction is a widely used software engineer-
ing exercise, and hence this paper presents a compiler system for adaptive computing. The final re-
sult of this paper is to provide a general knowledge about compiler design and its implementation.
In order to develop effective compilation techniques, it is important to understand the common
characteristics of the programs during compilation.
[6] Jatin Chhabra, Hiteshi Chopra, Abhimanyu Vats on “ Research paper on Compiler Design”, The
paper describes that A compiler translates and/or compiles a program written in a suitable source
language into an equivalent target language through a number of stages. Starting with recognition of
token through target code generation provide a basis for communication interface between a user
and a processor in significant amount of time.
[7] Aastha Singh, Sonam Sinha, Archana Priyadarshi on “Compiler Construction”, The paper de-
scribes that Compiler construction is a widely used software engineering exercise, but because
most students will not be compiler writers, care must be taken to make it relevant in a core curricu-
lum. The course is suitable for advanced undergraduate and beginning graduate students. Auxiliary
tools, such as generators and interpreters, often hinder the learning: students have to fight tool idio-
syncrasies, mysterious errors, and other poorly educative issues.
Page 11 of 14
CHAPTER 3
DESIGN
Figure 3 [1]
Page 12 of 14
CHAPTER 4
IMPLEMENTATION
OUTPUT:
Figure 5
Page 13 of 14
CONCLUSION
Besides covering basic compilation issues, the course yields an implemented compiler that
can serve as a test bed for coursework implementation for compiler. We described an improved ap-
proach for a compiler which partitions a high-level language program. Further research will actually
quantify the advantages in relation to the current system. The implementation and source language
is Mouse, and the target language is C code.
REFERENCES
[1] Grogono, Peter (July 1979) on "Mouse / A Language for Microcomputers”, Retrieved 18 Octo-
ber 2013.
[2] Lane, Tom; Grogono, Peter (June 1980) on "Comment and Correction for Mouse”, Retrieved 18
October 2013.
[4] Charu Arora, Chetna Arora, Monika Jaitwal on “ RESEARCH PAPER ON PHASES OF COM-
PILER” ,2014 IJIRT , Volume 1 Issue 5 , ISSN : 2349-6002.
[5] Mahak Jain, Nidhi Sehrawat, Neha Muns on “ COMPILER BASIC DESIGN AND CON-
STRUCTION”, IJCSMC, Vol. 3, Issue. 10, October 2014, ISSN 2320–088X.
[6] Jatin Chhabra, Hiteshi Chopra, Abhimanyu Vats on “ Research paper on Compiler Design”,
2014 IJIRT , Volume 1 Issue 5 , ISSN : 2349-6002.
[7] Aastha Singh, Sonam Sinha, Archana Priyadarshi on “Compiler Construction” , International
Journal of Scientific and Research Publications, Volume 3, Issue 4, April 2013, ISSN 2250-3153.
Page 14 of 14