SlideShare a Scribd company logo
5/11/2021 Saeed Parsa 1
Compiler Design
Introduction to Compiler
Saeed Parsa
Room 332,
School of Computer Engineering,
Iran University of Science & Technology
parsa@iust.ac.ir
Winter 2021
Why compilers?
5/11/2021 Saeed Parsa 2
Compiler
Software
Quality
Measurement
Reverse
Engineering
Software
Security
Automatic
Distribution &
Parallelization
Software
Testing
A compiler structure
• Page 7 of the Aho’s Book
5/11/2021 Saeed Parsa 3
Compilation steps with an example
• Page 7 of the Aho’s Book
5/11/2021 Saeed Parsa 4
Example of compilation process
Consider the example statement:
position = initial + rate * 60
1. Lexical Analysis
There are 30 characters in the statement.
The characters are transformed by lexical analysis into a sequence of 7 tokens.
Token1.name = “position”;
Token2.name = “=“;
Token3.name = “initial“;
Token4.name = “+“;
Token5.name = “rate“;
Token6.name = “*“;
Token7.name = “60“;
5/11/2021 Saeed Parsa 5
Example of compilation process (Continued)
Consider the example statement:
position = initial + rate * 60
2. Syntax Analysis
Those tokens are then used by syntax analyzer to build a tree of height 4, representing the
correctness of the statement according to the grammar.
G1:
assignmentSt ::= identifier = expression
expression ::= expression + term | expression – term | term
term ::= term * factor | term / factor | factor
factor ::= identifier | number | (expression)
5/11/2021 Saeed Parsa 6
Example of compilation process (Continued)
Consider the example statement:
position = initial + rate * 60
2. Syntax Analysis
Those tokens are then used syntax
analyzer to build a tree of height 4,
representing the correctness of the
statement according to the grammar.
5/11/2021 Saeed Parsa 7
Example of compilation process (Continued)
Consider the example statement:
position = initial + rate * 60
3. Semantics Analysis
Semantic analysis may transform the tree into one of height 5, that includes a type conversion
necessary for real addition on an integer operand.
4. Intermediate code generation
Intermediate code generation uses a simple traversal algorithm to linearize the tree back into a
sequence of machine-independent three-address-code instructions.
t1 = inttoreal(60)
t2 = id3 * t1
t3 = id2 + t2
id1 = t3
5/11/2021 Saeed Parsa 8
position = initial + rate * 60
Example of compilation process (Continued)
5/11/2021 Saeed Parsa 9
t1 = inttoreal(60)
t2 = id3 * t1
t3 = id2 + t2
id1 = t3
position = initial + rate * 60
t1 = id3 * 60.0
id1 = id2 + t1
http://www.personal.kent.edu/~rmuhamma/Compilers/compnotes.html
Consider the example statement:
position = initial + rate * 60
5. Optimization
Optimization of the intermediate code allows the four instructions to be reduced to two
machine-independent instructions.
Example of compilation process (Continued)
5/11/2021 Saeed Parsa 10
Consider the example statement:
position = initial + rate * 60
7. Final code generation
Final code generation might implement these two instructions using 5 machine instructions,
in which the actual registers and addressing modes of the CPU are utilized.
t1 = inttoreal(60)
t2 = id3 * t1
t3 = id2 + t2
id1 = t3
position = initial + rate * 60
t1 = id3 * 60.0
id1 = id2 + t1
MOVF id3, R2
MULF #60.0,
R2
MOVF id2, R1
ADDF R2, R1
MOVF R1, id1
http://www.personal.kent.edu/~rmuhamma/Compilers/compnotes.html
Compiler construction tools
5/11/2021 Saeed Parsa 11
On-line documentation is available for the following compiler tools:
• Scanner generators for C/C++: Flex (pdf), Lex (pdf).
• Parser generators for C/C++: Bison (in HTML), Bison (pdf), Yacc (pdf).
• Available scanner generators for Java:
• JLex, a scanner generator for Java, very similar to Lex.
• JFLex, flex for Java.
http://www.personal.kent.edu/~rmuhamma/Compilers/compnotes.html
Compiler construction tools
5/11/2021 Saeed Parsa 12
• Available parser generators for Java:
• CUP, a parser generator for Java, very similar to YACC.
• BYACC/J, a different version of Berkeley YACC for Java. It is an extension of the standard
YACC (a -j flag has been added to generate Java code).
• Other compiler tools:
• JavaCC, a parser generator for Java, including scanner generator and parser generator. Input
specifications are different than those suitable for Lex/YACC. Also, unlike YACC, JavaCC
generates a top-down parser.
• ANTLR, a set of language translation tools (formerly PCCTS). Includes scanner/parser
generators for C, C++, and Java.
Compiler construction tools
5/11/2021 Saeed Parsa 13
1. Parser Generators
2. Scanner Generators
3. Syntax-directed Translation Engines
4. Automatic Code Generators
5. Data-flow Analysis Engines
6. Compiler Construction Toolkits
1. Parser Generators
5/11/2021 Saeed Parsa 14
 It produces syntax analyzers (parsers) from the input that is based on a grammatical description
of programming language or on a context-free grammar.
 It is useful as the syntax analysis phase is highly complex and consumes more manual and
compilation time.
 Example: PIC, EQM, ANTLR, YACC
2. Scanner Generators
5/11/2021 Saeed Parsa 15
 It generates lexical analyzers from the input that consists of regular expression description based
on tokens of a language.
 It generates a finite automaton to recognize the regular expression.
 Example: Lex, Flex, ANTLR
Compiler construction tools
5/11/2021 Saeed Parsa 16
3. Syntax-directed translation engines that produce collections of routines for walking a parse tree
and generating intermediate code.
4. Code-generator generators that produce a code generator from a collection of rules for
translating each operation of the intermediate language into the machine language for a target
machine.
5. Data-flow analysis engines that facilitate the gathering of information about how values are
transmitted from one part of a program to each other part. Data-flow analysis is a key part of
code optimization.
6. Compiler-construction toolkits that provide an integrated set of routines for constructing various
phases of a compiler.
Page 8 of the Aho’s Book
Compiler construction tools
5/11/2021 Saeed Parsa 17
https://link.springer.com/content/pdf/10.1007%2F3-540-53669-8_77.pdf
What is ANTLR?
5/11/2021 Saeed Parsa 18
What is ANTLR?
5/11/2021 Saeed Parsa 19
 ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a language tool that
provides a framework for constructing recognizers, compilers, and translators from
grammatical descriptions.
 ANTLR is a parser generator.
 ANTLR is open source, written in JAVA.
 ANTLR provides a “tree walker” to traverse parse tress.
 There are two tree walking mechanism provided by the ANTLR library - Listener & Visitor.
What is ANTLR?
5/11/2021 Saeed Parsa 20
 There are 3 primary differences between the Listener and Visitor libraries:
1. Listener methods are called automatically by the ANTLR provided walker object,
whereas visitor methods must walk their children with explicit visit calls. Forgetting to
invoke visit() on a node’s children means those subtrees don’t get visited
2. Listener methods can’t return a value, whereas visitor methods can return any custom
type. With listener, you will have to use mutable variables to store values, whereas with
visitor there is no such need.
3. Listener uses an explicit stack allocated on the heap, whereas visitor uses call stack to
manage tree traversals. This might lead to Stack Overflow exceptions while using visitor
on deeply nested ASTs.
What is ANTLR?
5/11/2021 Saeed Parsa 21
Antlr is a public-domain, software tool developed by Terence Parr
to assist with the development of translators and compilers.
ANTLR automatically generates the lexical analyzer and parser for
you by analyzing the grammar you provide.
Grammar
ANRLR Parser
Generator
Lexer
Parser
What is ANTLR?
5/11/2021 Saeed Parsa 22
A parse tree walker allows walking through the parse tree and perform any action
at each node.
Why to use ANTLR?
5/11/2021 Saeed Parsa 23
ANTLR is extremely popular with 5,000 downloads a month and is included on
all Linux and OS X distributions. It is widely used because it:
 Generates human-readable code that is easy to fold into other applications
 Generates powerful recursive-descent recognizers using LL(*), an extension to
LL(k) that uses arbitrary look ahead to make decisions
 Tightly integrates StringTemplate,5 a template engine specifically designed to
generate structured text such as source code
 Has a graphical grammar development environment called ANTLRWorks6 that
can debug parsers generated in any ANTLR target language
Why to use ANTLR?
5/11/2021 Saeed Parsa 24
1. Is actively supported with a good project website and a high-traffic mailing list7
• Comes with complete source under the BSD license
2. Is extremely flexible and automates or formalizes many common tasks
3. Supports multiple target languages such as Java, C#, Python, Ruby, Objective-C, C,
and C++.
See:
• http://www.stringtemplate.org
• http://www.antlr.org/works
• http://www.antlr.org:8080/pipermail/antlr-interest/
https://doc.lagout.org/programmation/Pragmatic%20Programmers/The%20Definitive%20ANTLR%20Reference.pdf
Install ANTLR
5/11/2021 Saeed Parsa 25
ANTLR is written in Java, so you must have Java installed on your machine even if you are
going to use ANTLR with, say, Python. ANTLR requires a Java version of 1.6 or higher.
Step 1: Install Java
1.1 Download and install Java JDK 13.0.2 (64-bit). Java Development Kit (64-bit).
Date released 2018. Free Download. (159.8 MB).
https://www.filehorse.com/download-java-development-kit-64/old-versions/page-2/
Step 2: Download the tool
2.1 Download antlr-4.8-complete.jar (or whatever version) from https:
https://www.antlr.org/download/
2.2 Save antlr-4.8-complete.jar to your directory for 3rd party Java libraries, say:
C:Javalib
Install ANTLR
5/11/2021 Saeed Parsa 26
Step 3: Set paths
3.1 Create three text files antlr.txt, grun.txt and class.txt and save then to c:java.lib
3.2 Rename the above files to antlr.bat, grun.bat and class.bat
3.3 Copy the following commands into the batch files:
class.bat: SET CLASSPATH=.; %CLASSPATH%
grun.bat: java org.antlr.v4.gui.TestRig %*
antlr.bat: java org.antlr.v4.Tool %*
3.4 Add antlr-4.8-complete.jar to CLASSPATH, either:
Permanently: Using Control Panel > System > Advanced system settings > Environment variables
3.5 Use the windows search, to look for “environment”.
Install ANTLR
5/11/2021 Saeed Parsa 27
3.6 Click on “Edit Environment Variables” > “Environment Variables”
3.7 The following widow will pop up on the screen.
Install ANTLR
5/11/2021 Saeed Parsa 28
3.8 Click on “New”. The following window will be displayed
Install ANTLR
5/11/2021 Saeed Parsa 29
3.9 Add Java path to Path by clicking on the “Path” option
Install ANTLR
5/11/2021 Saeed Parsa 30
3.10 The following window will be opened. Click on the push-button, labeled “New”.
Install ANTLR
5/11/2021 Saeed Parsa 31
3.11 Enter java compiler path and the Class Path entered before.
Install ANTLR
5/11/2021 Saeed Parsa 32
3.12.1 Now by doing such settings it will be possible to access the downloaded jar file.
The above image is from the javalib folder, which contains the antlr-4.8-complete.jar software
we downloaded from www.antlr.org.
Running ANTLR
5/11/2021 Saeed Parsa 33
Step 2: Add or create a grammar file (*.g4) in your project
2.1 Download the desired Grammar from the following URL and save it in the
C:javalib directory
https://github.com/antlr/grammars-v4/blob/master/cpp/CPP14.g4
2.2 Run Antlr to create lexer and parser
Create two batch files as follows:
(1) antlr4.bat: java org.antlr.v4.Tool%*
(2) grun.bat: antlr4 -listener -visitor -Dlanguage=CSharp CPP14.g4
Or run the following commands:
java org.antlr.v4.Tool -Werror -o {outputdirectory} -Dlanguage=CSharp input.g4 -visitor
java -jar antlr-4.8-complete.jar -Dlanguage=CSharp input.g4 -visitor
Running ANTLR
5/11/2021 Saeed Parsa 34
• In antlr4.bat the command java org.antlr.v4.Tool% is included. This command
actually invokes the antlr.v4 software.
• The second batch file, grun.bat, includes the command:
antlr4 -listener -visitor -Dlanguage=CSharp CPP14.g4.
• In this command:
• Using the -listener -visitor switches we have actually requested that this
command generate both these files in addition to the parser and lexer.
• Dlanguage = CSharp tells antlr to generate the files generated from CPP14.G4
should be in C#.
Running ANTLR
5/11/2021 Saeed Parsa 35
After executing this batch file, all the required files will be generated and saved
in the JAVALIB folder.
Running ANTLR
5/11/2021 Saeed Parsa 36
Alternatively:
2.2 Run Antlr to create listener and visitor
java org.antlr.v4.Tool -Werror -o {outputdirectory} -Dlanguage=CSharp input.g4 -visitor
java -jar antlr-4.5.1-complete.jar -Dlanguage=CSharp input.g4 –visitor -listener
2.3 As a result the Parser, Lexer, Visitor and Listener classes will be created
Running ANTLR
5/11/2021 Saeed Parsa 37
Install ANTLR in C#
5/11/2021 Saeed Parsa 38
Adding ANTLR plugin:
 A JRE needs to be on the executable search path (i.e. the absolute path is in
the %PATH% environment variable)
 Installation of the ANTLR4 packages is via the NuGet Package Manager
 Grammar file(s)’ compilation options need(s) to be customized manually by editing
the project’s configuration file (*.csproj)
 The latest stable version of ANTLR4 (version 4.3.0) is only supported on .NET
Framework 4.5 and below, therefore there is a need to change the target framework
from the default (if the default version is higher)
 References to the ANTLR namespaces are required
Install ANTLR in C#
5/11/2021 Saeed Parsa 39
1. First, create a Windows Form App project in Visual Studio.
2. Right click on the project name in the solution explorer and add a folder,
Antlor4.
Install ANTLR in C#
5/11/2021 Saeed Parsa 40
3. Copy the content of javalib into the Antlor4 folder.
Install ANTLR in C#
5/11/2021 Saeed Parsa 41
• Now after adding the folder to the visual
environment we need to add a package to use
Antlr in the .net environment.
• To do so, right-click on References and then in the
popup window click on the Manage NuGet
package option and then add a package called
antlr4.rantime.standard to the project.
Install ANTLR in C#
5/11/2021 Saeed Parsa 42
NuGet:
• NuGet is a package and dependency manager.
• Helps to find, install, update and remove packages.
• Focuses primarily on package and dependency management.
• Lists all available packages for download.
• Adding a NuGet package to a Visual Studio project is similar to adding a reference.
• Go to Solution Explorer,
• Right-click on the References folder,
• Click Manage NuGet Packages.
Install ANTLR in C#
5/11/2021 Saeed Parsa 43
For Visual Studio 2017:
1. Right click the top-level solution node in the Solution Explorer window and
select Manage NuGet Packages for Solution.
2. In the upper left, choose Browse and then choose nuget.org as the Package
source
3. Next to the Search box, check Include prerelease
4. In the Search box, type Antlr4 to search for the package
5. In the search results, locate and select the package called Antlr4. Verify that the
name is listed as Antlr4.
6. In the right pane, select the C# projects you want to use ANTLR4 by clicking their
checkboxes
7. Click Install under the list of projects
8. Approve changes and accept license agreements, if prompted.
Install ANTLR in C#
5/11/2021 Saeed Parsa 44
Install ANTLR in C#
5/11/2021 Saeed Parsa 45
After adding the packages to our project, we use their namespaces and use the capabilities of
these packages in our project.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using Antlr4.Runtime;
using Antlr4.Runtime.Misc;
using Antlr4.Runtime.Tree;
using static CPP14Parser;
Assignment 1
5/11/2021 Saeed Parsa 46
Subject : Install & use ANTLR
Deadline: Two weeks
Mark: 5 out of 100.
Assignment 1
5/11/2021 Saeed Parsa 47
Write a program to accept a C++ program as input and generate parse tree for the
program
1. Run ANTLR to generate a lexical analyzer (lexer) and a parser for C++ .
2. Give a C++ program to your C++ compiler to generate parse and depict the
parse tree for the program.
3. Provide a report describing the installation step and your program.
You may generate lexer and parser for other languages such as C# , Java, and
Python.
Your code could be either in Python, or C# language.
Assignment 1
5/11/2021 Saeed Parsa 48
Steps to install ANTLR:
1. Download Java JDK 13.0.2 (64-bit). Java Development Kit (64-bit).
Date released 2018. Free Download. (159.8 MB).
https://www.filehorse.com/download-java-development-kit-64/old-versions/page-2/
2. Download Antlr 4.8-complete.jar (or whatever version) from https:
https://www.antlr.org/download/
3. Create a directory for 3rd party Java libraries :
C:Javalib
4. Save antlr-4.8-complete.jar to C:Javalib.
Assignment 1
5/11/2021 Saeed Parsa 49
Steps to install ANTLR:
5. Add the followings to ’environment variables’ in windows 10.
 C:Program FilesJavajdk-13.0.2bin
 C:Javalib
 %CLASSPATH%
6. Add C:Javalibantlr-4.8-complete.jar as the variable value of the environment variable
named CLASSPATH.
7. Download the CPP grammar from the following URL address into “C:javalib” folder:
https://github.com/antlr/grammars-v4/tree/master/cpp
Similarly the Python grammar could be downloaded from:
https://github.com/antlr/grammars-v4/tree/master/python
Assignment 1
5/11/2021 Saeed Parsa 50
Steps to install ANTLR:
8. Generate parser and lexer
java -jar antlr4-4.8.jar -Dlanguage=CSharp CPP14.g4
or
java -jar antlr4-4.8.jar -Dlanguage=Phyton3 CPP14.g4
or
java -jar antlr4-4.8.jar -Dlanguage=Cpp grammar.g4
For instance suppose you choose to generate Python3 code:
java -jar ./antlr-4.8-complete.jar -Dlanguage=Python3 CPP14.g4
Assignment 1
5/11/2021 Saeed Parsa 51
Steps to install ANTLR:
 This will generate the following files, which you can then integrate in your project
CPP14Lexer.py: including the source of a class, CPP14Lexer.
CPP14Parser.py: including the source of a class, CPP14Parser.
CPP14Listener.py: including the source of a class, CPP14Listener.
9. In addition to the above three files, four other files are generated that are used by ANTLR.
All these files should be copied into the folder where you save your Python program.
Assignment 1
5/11/2021 Saeed Parsa 52
Steps to install ANTLR:
10. To access the ANLR-4 runtime library within a Python project, MyProject, in the PyChram
environment select:
File > Setting > MyProject > Project interpreter > + (add)
Search for “ANTR4” in the popped up window, select “ANTLR4 runtime Python3” option,
and click on the “install package” button.
http://ati.ttu.ee/~kjans/antlr/pycharm_antlr4_guide.pdf
Assignment 1
5/11/2021 Saeed Parsa 53
Steps to install ANTLR:
11. Write a program to generate and display Parse tree for a given C++ program.
https://www.thetopsites.net/article/50064110.shtml
https://github.com/antlr/antlr4/blob/master/runtime/Python3/src/antlr4/Parser.py
Assignment 1
5/11/2021 Saeed Parsa 54
Note: CLASSPATH is a parameter in the Java Virtual Machine or the Java compiler
that specifies the location of user-defined classes and packages. The parameter may
be set either on the command-line, or through an environment variable.
 To add ANTLR to class path,
• Click on ‘Windows search’ key and enter “environment”
• go to the following address (you may click on the following address to
get access to the related document):
• Control Panel > System > Advanced system settings > Environment variables
 Under Environment Variables, you can see two sections.
 The top section shows User variables,
 The bottom section shows System Variables.
Assignment 1
5/11/2021 Saeed Parsa 55
 In either of them, find for Variable name PATH or path.
 If it is available click on path in the system variable window and then press edit.
 Pressing the “Edit” button a new window labeled ‘Edit system variable’ will pop up.
 Press the “new” button, and add the following three items to the list”
1. The path for accessing Java: C:Program FilesJavajdk-13.0.2bin
2. The 3rd party Java libraries address: C:javalib
3. Class path: %CLASSPATH%
Assignment 1
5/11/2021 Saeed Parsa 56
Assignment 1
5/11/2021 Saeed Parsa 57
Assignment 1
5/11/2021 Saeed Parsa 58
Assignment 1
5/11/2021 Saeed Parsa 59
The place of IUST in the world
5/11/2021 Saeed Parsa 60
https://www.researchgate.net/publication/328099969_Software_Fault_Localisation_A_Systematic_Mapping_Study
5/11/2021 Saeed Parsa 61

More Related Content

PPT
Hash crypto
PPTX
Blockchain : A Key Player in Metaverse.pptx
PPTX
DAOs on Ethereum: The Future of Venture Finance
PPTX
Basic introduction in blockchain, smart contracts, permissioned ledgers
PPTX
Types of Blockchains
PDF
The Potential of Blockchain Technology
PDF
Understanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
PDF
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Hash crypto
Blockchain : A Key Player in Metaverse.pptx
DAOs on Ethereum: The Future of Venture Finance
Basic introduction in blockchain, smart contracts, permissioned ledgers
Types of Blockchains
The Potential of Blockchain Technology
Understanding Proof of Work (PoW) and Proof of Stake (PoS) Algorithms
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...

What's hot (20)

PDF
Smart Contracts Programming Tutorial | Solidity Programming Language | Solidi...
PDF
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
PDF
Introduction To Solidity
PDF
Hyperledger Fabric Application Development 20190618
PPTX
Transformers AI PPT.pptx
PPTX
Blockchain 2.0
PDF
Programming Decentralized Application
PDF
Blockchains and databases a new era in distributed computing
PPTX
Block chain technology
PDF
Blockchain
PPTX
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
PDF
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
PPTX
BLOCKCHAIN
PDF
Understanding hd wallets design and implementation
PDF
01 - Introduction to Hyperledger : A Blockchain Technology for Business
PDF
Consensus Algorithms: An Introduction & Analysis
PPTX
Block cipher modes of operation
PPTX
EVM - The Heart of Ethereum
Smart Contracts Programming Tutorial | Solidity Programming Language | Solidi...
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Introduction To Solidity
Hyperledger Fabric Application Development 20190618
Transformers AI PPT.pptx
Blockchain 2.0
Programming Decentralized Application
Blockchains and databases a new era in distributed computing
Block chain technology
Blockchain
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
BLOCKCHAIN
Understanding hd wallets design and implementation
01 - Introduction to Hyperledger : A Blockchain Technology for Business
Consensus Algorithms: An Introduction & Analysis
Block cipher modes of operation
EVM - The Heart of Ethereum
Ad

Similar to 2. introduction to compiler (20)

PPTX
2. introduction
PDF
Declare Your Language: What is a Compiler?
PDF
Compiler construction lecture 01 .pptx.pdf
PPT
Compiler Construction introduction
PPT
Petapath HP Cast 12 - Programming for High Performance Accelerated Systems
PPT
Chapter One
ODP
Code Analysis and Refactoring with CDT
PDF
ApiDesign
PDF
API design
PPTX
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
PPT
Cpcs302 1
PDF
Scale Up Performance with Intel® Development
PDF
WhitePaper - Implementing a Porting Automation Tool as an Eclipse Plugin
PPT
A basic introduction to compiler design.ppt
PPT
A basic introduction to compiler design.ppt
PPTX
Cockatrice: A Hardware Design Environment with Elixir
PPTX
Lecture 1 introduction to language processors
DOC
Ghoshal_resume_LinkedIn_20160705
PDF
Software Development Automation With Scripting Languages
2. introduction
Declare Your Language: What is a Compiler?
Compiler construction lecture 01 .pptx.pdf
Compiler Construction introduction
Petapath HP Cast 12 - Programming for High Performance Accelerated Systems
Chapter One
Code Analysis and Refactoring with CDT
ApiDesign
API design
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
Cpcs302 1
Scale Up Performance with Intel® Development
WhitePaper - Implementing a Porting Automation Tool as an Eclipse Plugin
A basic introduction to compiler design.ppt
A basic introduction to compiler design.ppt
Cockatrice: A Hardware Design Environment with Elixir
Lecture 1 introduction to language processors
Ghoshal_resume_LinkedIn_20160705
Software Development Automation With Scripting Languages
Ad

Recently uploaded (20)

PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
01-Introduction-to-Information-Management.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Pre independence Education in Inndia.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
master seminar digital applications in india
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
RMMM.pdf make it easy to upload and study
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Lesson notes of climatology university.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
01-Introduction-to-Information-Management.pdf
Anesthesia in Laparoscopic Surgery in India
Pre independence Education in Inndia.pdf
Basic Mud Logging Guide for educational purpose
master seminar digital applications in india
102 student loan defaulters named and shamed – Is someone you know on the list?
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GDM (1) (1).pptx small presentation for students
RMMM.pdf make it easy to upload and study
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Insiders guide to clinical Medicine.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Lesson notes of climatology university.
Final Presentation General Medicine 03-08-2024.pptx
Microbial diseases, their pathogenesis and prophylaxis

2. introduction to compiler

  • 1. 5/11/2021 Saeed Parsa 1 Compiler Design Introduction to Compiler Saeed Parsa Room 332, School of Computer Engineering, Iran University of Science & Technology parsa@iust.ac.ir Winter 2021
  • 2. Why compilers? 5/11/2021 Saeed Parsa 2 Compiler Software Quality Measurement Reverse Engineering Software Security Automatic Distribution & Parallelization Software Testing
  • 3. A compiler structure • Page 7 of the Aho’s Book 5/11/2021 Saeed Parsa 3
  • 4. Compilation steps with an example • Page 7 of the Aho’s Book 5/11/2021 Saeed Parsa 4
  • 5. Example of compilation process Consider the example statement: position = initial + rate * 60 1. Lexical Analysis There are 30 characters in the statement. The characters are transformed by lexical analysis into a sequence of 7 tokens. Token1.name = “position”; Token2.name = “=“; Token3.name = “initial“; Token4.name = “+“; Token5.name = “rate“; Token6.name = “*“; Token7.name = “60“; 5/11/2021 Saeed Parsa 5
  • 6. Example of compilation process (Continued) Consider the example statement: position = initial + rate * 60 2. Syntax Analysis Those tokens are then used by syntax analyzer to build a tree of height 4, representing the correctness of the statement according to the grammar. G1: assignmentSt ::= identifier = expression expression ::= expression + term | expression – term | term term ::= term * factor | term / factor | factor factor ::= identifier | number | (expression) 5/11/2021 Saeed Parsa 6
  • 7. Example of compilation process (Continued) Consider the example statement: position = initial + rate * 60 2. Syntax Analysis Those tokens are then used syntax analyzer to build a tree of height 4, representing the correctness of the statement according to the grammar. 5/11/2021 Saeed Parsa 7
  • 8. Example of compilation process (Continued) Consider the example statement: position = initial + rate * 60 3. Semantics Analysis Semantic analysis may transform the tree into one of height 5, that includes a type conversion necessary for real addition on an integer operand. 4. Intermediate code generation Intermediate code generation uses a simple traversal algorithm to linearize the tree back into a sequence of machine-independent three-address-code instructions. t1 = inttoreal(60) t2 = id3 * t1 t3 = id2 + t2 id1 = t3 5/11/2021 Saeed Parsa 8 position = initial + rate * 60
  • 9. Example of compilation process (Continued) 5/11/2021 Saeed Parsa 9 t1 = inttoreal(60) t2 = id3 * t1 t3 = id2 + t2 id1 = t3 position = initial + rate * 60 t1 = id3 * 60.0 id1 = id2 + t1 http://www.personal.kent.edu/~rmuhamma/Compilers/compnotes.html Consider the example statement: position = initial + rate * 60 5. Optimization Optimization of the intermediate code allows the four instructions to be reduced to two machine-independent instructions.
  • 10. Example of compilation process (Continued) 5/11/2021 Saeed Parsa 10 Consider the example statement: position = initial + rate * 60 7. Final code generation Final code generation might implement these two instructions using 5 machine instructions, in which the actual registers and addressing modes of the CPU are utilized. t1 = inttoreal(60) t2 = id3 * t1 t3 = id2 + t2 id1 = t3 position = initial + rate * 60 t1 = id3 * 60.0 id1 = id2 + t1 MOVF id3, R2 MULF #60.0, R2 MOVF id2, R1 ADDF R2, R1 MOVF R1, id1 http://www.personal.kent.edu/~rmuhamma/Compilers/compnotes.html
  • 11. Compiler construction tools 5/11/2021 Saeed Parsa 11 On-line documentation is available for the following compiler tools: • Scanner generators for C/C++: Flex (pdf), Lex (pdf). • Parser generators for C/C++: Bison (in HTML), Bison (pdf), Yacc (pdf). • Available scanner generators for Java: • JLex, a scanner generator for Java, very similar to Lex. • JFLex, flex for Java. http://www.personal.kent.edu/~rmuhamma/Compilers/compnotes.html
  • 12. Compiler construction tools 5/11/2021 Saeed Parsa 12 • Available parser generators for Java: • CUP, a parser generator for Java, very similar to YACC. • BYACC/J, a different version of Berkeley YACC for Java. It is an extension of the standard YACC (a -j flag has been added to generate Java code). • Other compiler tools: • JavaCC, a parser generator for Java, including scanner generator and parser generator. Input specifications are different than those suitable for Lex/YACC. Also, unlike YACC, JavaCC generates a top-down parser. • ANTLR, a set of language translation tools (formerly PCCTS). Includes scanner/parser generators for C, C++, and Java.
  • 13. Compiler construction tools 5/11/2021 Saeed Parsa 13 1. Parser Generators 2. Scanner Generators 3. Syntax-directed Translation Engines 4. Automatic Code Generators 5. Data-flow Analysis Engines 6. Compiler Construction Toolkits
  • 14. 1. Parser Generators 5/11/2021 Saeed Parsa 14  It produces syntax analyzers (parsers) from the input that is based on a grammatical description of programming language or on a context-free grammar.  It is useful as the syntax analysis phase is highly complex and consumes more manual and compilation time.  Example: PIC, EQM, ANTLR, YACC
  • 15. 2. Scanner Generators 5/11/2021 Saeed Parsa 15  It generates lexical analyzers from the input that consists of regular expression description based on tokens of a language.  It generates a finite automaton to recognize the regular expression.  Example: Lex, Flex, ANTLR
  • 16. Compiler construction tools 5/11/2021 Saeed Parsa 16 3. Syntax-directed translation engines that produce collections of routines for walking a parse tree and generating intermediate code. 4. Code-generator generators that produce a code generator from a collection of rules for translating each operation of the intermediate language into the machine language for a target machine. 5. Data-flow analysis engines that facilitate the gathering of information about how values are transmitted from one part of a program to each other part. Data-flow analysis is a key part of code optimization. 6. Compiler-construction toolkits that provide an integrated set of routines for constructing various phases of a compiler. Page 8 of the Aho’s Book
  • 17. Compiler construction tools 5/11/2021 Saeed Parsa 17 https://link.springer.com/content/pdf/10.1007%2F3-540-53669-8_77.pdf
  • 18. What is ANTLR? 5/11/2021 Saeed Parsa 18
  • 19. What is ANTLR? 5/11/2021 Saeed Parsa 19  ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a language tool that provides a framework for constructing recognizers, compilers, and translators from grammatical descriptions.  ANTLR is a parser generator.  ANTLR is open source, written in JAVA.  ANTLR provides a “tree walker” to traverse parse tress.  There are two tree walking mechanism provided by the ANTLR library - Listener & Visitor.
  • 20. What is ANTLR? 5/11/2021 Saeed Parsa 20  There are 3 primary differences between the Listener and Visitor libraries: 1. Listener methods are called automatically by the ANTLR provided walker object, whereas visitor methods must walk their children with explicit visit calls. Forgetting to invoke visit() on a node’s children means those subtrees don’t get visited 2. Listener methods can’t return a value, whereas visitor methods can return any custom type. With listener, you will have to use mutable variables to store values, whereas with visitor there is no such need. 3. Listener uses an explicit stack allocated on the heap, whereas visitor uses call stack to manage tree traversals. This might lead to Stack Overflow exceptions while using visitor on deeply nested ASTs.
  • 21. What is ANTLR? 5/11/2021 Saeed Parsa 21 Antlr is a public-domain, software tool developed by Terence Parr to assist with the development of translators and compilers. ANTLR automatically generates the lexical analyzer and parser for you by analyzing the grammar you provide. Grammar ANRLR Parser Generator Lexer Parser
  • 22. What is ANTLR? 5/11/2021 Saeed Parsa 22 A parse tree walker allows walking through the parse tree and perform any action at each node.
  • 23. Why to use ANTLR? 5/11/2021 Saeed Parsa 23 ANTLR is extremely popular with 5,000 downloads a month and is included on all Linux and OS X distributions. It is widely used because it:  Generates human-readable code that is easy to fold into other applications  Generates powerful recursive-descent recognizers using LL(*), an extension to LL(k) that uses arbitrary look ahead to make decisions  Tightly integrates StringTemplate,5 a template engine specifically designed to generate structured text such as source code  Has a graphical grammar development environment called ANTLRWorks6 that can debug parsers generated in any ANTLR target language
  • 24. Why to use ANTLR? 5/11/2021 Saeed Parsa 24 1. Is actively supported with a good project website and a high-traffic mailing list7 • Comes with complete source under the BSD license 2. Is extremely flexible and automates or formalizes many common tasks 3. Supports multiple target languages such as Java, C#, Python, Ruby, Objective-C, C, and C++. See: • http://www.stringtemplate.org • http://www.antlr.org/works • http://www.antlr.org:8080/pipermail/antlr-interest/ https://doc.lagout.org/programmation/Pragmatic%20Programmers/The%20Definitive%20ANTLR%20Reference.pdf
  • 25. Install ANTLR 5/11/2021 Saeed Parsa 25 ANTLR is written in Java, so you must have Java installed on your machine even if you are going to use ANTLR with, say, Python. ANTLR requires a Java version of 1.6 or higher. Step 1: Install Java 1.1 Download and install Java JDK 13.0.2 (64-bit). Java Development Kit (64-bit). Date released 2018. Free Download. (159.8 MB). https://www.filehorse.com/download-java-development-kit-64/old-versions/page-2/ Step 2: Download the tool 2.1 Download antlr-4.8-complete.jar (or whatever version) from https: https://www.antlr.org/download/ 2.2 Save antlr-4.8-complete.jar to your directory for 3rd party Java libraries, say: C:Javalib
  • 26. Install ANTLR 5/11/2021 Saeed Parsa 26 Step 3: Set paths 3.1 Create three text files antlr.txt, grun.txt and class.txt and save then to c:java.lib 3.2 Rename the above files to antlr.bat, grun.bat and class.bat 3.3 Copy the following commands into the batch files: class.bat: SET CLASSPATH=.; %CLASSPATH% grun.bat: java org.antlr.v4.gui.TestRig %* antlr.bat: java org.antlr.v4.Tool %* 3.4 Add antlr-4.8-complete.jar to CLASSPATH, either: Permanently: Using Control Panel > System > Advanced system settings > Environment variables 3.5 Use the windows search, to look for “environment”.
  • 27. Install ANTLR 5/11/2021 Saeed Parsa 27 3.6 Click on “Edit Environment Variables” > “Environment Variables” 3.7 The following widow will pop up on the screen.
  • 28. Install ANTLR 5/11/2021 Saeed Parsa 28 3.8 Click on “New”. The following window will be displayed
  • 29. Install ANTLR 5/11/2021 Saeed Parsa 29 3.9 Add Java path to Path by clicking on the “Path” option
  • 30. Install ANTLR 5/11/2021 Saeed Parsa 30 3.10 The following window will be opened. Click on the push-button, labeled “New”.
  • 31. Install ANTLR 5/11/2021 Saeed Parsa 31 3.11 Enter java compiler path and the Class Path entered before.
  • 32. Install ANTLR 5/11/2021 Saeed Parsa 32 3.12.1 Now by doing such settings it will be possible to access the downloaded jar file. The above image is from the javalib folder, which contains the antlr-4.8-complete.jar software we downloaded from www.antlr.org.
  • 33. Running ANTLR 5/11/2021 Saeed Parsa 33 Step 2: Add or create a grammar file (*.g4) in your project 2.1 Download the desired Grammar from the following URL and save it in the C:javalib directory https://github.com/antlr/grammars-v4/blob/master/cpp/CPP14.g4 2.2 Run Antlr to create lexer and parser Create two batch files as follows: (1) antlr4.bat: java org.antlr.v4.Tool%* (2) grun.bat: antlr4 -listener -visitor -Dlanguage=CSharp CPP14.g4 Or run the following commands: java org.antlr.v4.Tool -Werror -o {outputdirectory} -Dlanguage=CSharp input.g4 -visitor java -jar antlr-4.8-complete.jar -Dlanguage=CSharp input.g4 -visitor
  • 34. Running ANTLR 5/11/2021 Saeed Parsa 34 • In antlr4.bat the command java org.antlr.v4.Tool% is included. This command actually invokes the antlr.v4 software. • The second batch file, grun.bat, includes the command: antlr4 -listener -visitor -Dlanguage=CSharp CPP14.g4. • In this command: • Using the -listener -visitor switches we have actually requested that this command generate both these files in addition to the parser and lexer. • Dlanguage = CSharp tells antlr to generate the files generated from CPP14.G4 should be in C#.
  • 35. Running ANTLR 5/11/2021 Saeed Parsa 35 After executing this batch file, all the required files will be generated and saved in the JAVALIB folder.
  • 36. Running ANTLR 5/11/2021 Saeed Parsa 36 Alternatively: 2.2 Run Antlr to create listener and visitor java org.antlr.v4.Tool -Werror -o {outputdirectory} -Dlanguage=CSharp input.g4 -visitor java -jar antlr-4.5.1-complete.jar -Dlanguage=CSharp input.g4 –visitor -listener 2.3 As a result the Parser, Lexer, Visitor and Listener classes will be created
  • 38. Install ANTLR in C# 5/11/2021 Saeed Parsa 38 Adding ANTLR plugin:  A JRE needs to be on the executable search path (i.e. the absolute path is in the %PATH% environment variable)  Installation of the ANTLR4 packages is via the NuGet Package Manager  Grammar file(s)’ compilation options need(s) to be customized manually by editing the project’s configuration file (*.csproj)  The latest stable version of ANTLR4 (version 4.3.0) is only supported on .NET Framework 4.5 and below, therefore there is a need to change the target framework from the default (if the default version is higher)  References to the ANTLR namespaces are required
  • 39. Install ANTLR in C# 5/11/2021 Saeed Parsa 39 1. First, create a Windows Form App project in Visual Studio. 2. Right click on the project name in the solution explorer and add a folder, Antlor4.
  • 40. Install ANTLR in C# 5/11/2021 Saeed Parsa 40 3. Copy the content of javalib into the Antlor4 folder.
  • 41. Install ANTLR in C# 5/11/2021 Saeed Parsa 41 • Now after adding the folder to the visual environment we need to add a package to use Antlr in the .net environment. • To do so, right-click on References and then in the popup window click on the Manage NuGet package option and then add a package called antlr4.rantime.standard to the project.
  • 42. Install ANTLR in C# 5/11/2021 Saeed Parsa 42 NuGet: • NuGet is a package and dependency manager. • Helps to find, install, update and remove packages. • Focuses primarily on package and dependency management. • Lists all available packages for download. • Adding a NuGet package to a Visual Studio project is similar to adding a reference. • Go to Solution Explorer, • Right-click on the References folder, • Click Manage NuGet Packages.
  • 43. Install ANTLR in C# 5/11/2021 Saeed Parsa 43 For Visual Studio 2017: 1. Right click the top-level solution node in the Solution Explorer window and select Manage NuGet Packages for Solution. 2. In the upper left, choose Browse and then choose nuget.org as the Package source 3. Next to the Search box, check Include prerelease 4. In the Search box, type Antlr4 to search for the package 5. In the search results, locate and select the package called Antlr4. Verify that the name is listed as Antlr4. 6. In the right pane, select the C# projects you want to use ANTLR4 by clicking their checkboxes 7. Click Install under the list of projects 8. Approve changes and accept license agreements, if prompted.
  • 44. Install ANTLR in C# 5/11/2021 Saeed Parsa 44
  • 45. Install ANTLR in C# 5/11/2021 Saeed Parsa 45 After adding the packages to our project, we use their namespaces and use the capabilities of these packages in our project. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Text; using System.Windows.Forms; using Antlr4.Runtime; using Antlr4.Runtime.Misc; using Antlr4.Runtime.Tree; using static CPP14Parser;
  • 46. Assignment 1 5/11/2021 Saeed Parsa 46 Subject : Install & use ANTLR Deadline: Two weeks Mark: 5 out of 100.
  • 47. Assignment 1 5/11/2021 Saeed Parsa 47 Write a program to accept a C++ program as input and generate parse tree for the program 1. Run ANTLR to generate a lexical analyzer (lexer) and a parser for C++ . 2. Give a C++ program to your C++ compiler to generate parse and depict the parse tree for the program. 3. Provide a report describing the installation step and your program. You may generate lexer and parser for other languages such as C# , Java, and Python. Your code could be either in Python, or C# language.
  • 48. Assignment 1 5/11/2021 Saeed Parsa 48 Steps to install ANTLR: 1. Download Java JDK 13.0.2 (64-bit). Java Development Kit (64-bit). Date released 2018. Free Download. (159.8 MB). https://www.filehorse.com/download-java-development-kit-64/old-versions/page-2/ 2. Download Antlr 4.8-complete.jar (or whatever version) from https: https://www.antlr.org/download/ 3. Create a directory for 3rd party Java libraries : C:Javalib 4. Save antlr-4.8-complete.jar to C:Javalib.
  • 49. Assignment 1 5/11/2021 Saeed Parsa 49 Steps to install ANTLR: 5. Add the followings to ’environment variables’ in windows 10.  C:Program FilesJavajdk-13.0.2bin  C:Javalib  %CLASSPATH% 6. Add C:Javalibantlr-4.8-complete.jar as the variable value of the environment variable named CLASSPATH. 7. Download the CPP grammar from the following URL address into “C:javalib” folder: https://github.com/antlr/grammars-v4/tree/master/cpp Similarly the Python grammar could be downloaded from: https://github.com/antlr/grammars-v4/tree/master/python
  • 50. Assignment 1 5/11/2021 Saeed Parsa 50 Steps to install ANTLR: 8. Generate parser and lexer java -jar antlr4-4.8.jar -Dlanguage=CSharp CPP14.g4 or java -jar antlr4-4.8.jar -Dlanguage=Phyton3 CPP14.g4 or java -jar antlr4-4.8.jar -Dlanguage=Cpp grammar.g4 For instance suppose you choose to generate Python3 code: java -jar ./antlr-4.8-complete.jar -Dlanguage=Python3 CPP14.g4
  • 51. Assignment 1 5/11/2021 Saeed Parsa 51 Steps to install ANTLR:  This will generate the following files, which you can then integrate in your project CPP14Lexer.py: including the source of a class, CPP14Lexer. CPP14Parser.py: including the source of a class, CPP14Parser. CPP14Listener.py: including the source of a class, CPP14Listener. 9. In addition to the above three files, four other files are generated that are used by ANTLR. All these files should be copied into the folder where you save your Python program.
  • 52. Assignment 1 5/11/2021 Saeed Parsa 52 Steps to install ANTLR: 10. To access the ANLR-4 runtime library within a Python project, MyProject, in the PyChram environment select: File > Setting > MyProject > Project interpreter > + (add) Search for “ANTR4” in the popped up window, select “ANTLR4 runtime Python3” option, and click on the “install package” button. http://ati.ttu.ee/~kjans/antlr/pycharm_antlr4_guide.pdf
  • 53. Assignment 1 5/11/2021 Saeed Parsa 53 Steps to install ANTLR: 11. Write a program to generate and display Parse tree for a given C++ program. https://www.thetopsites.net/article/50064110.shtml https://github.com/antlr/antlr4/blob/master/runtime/Python3/src/antlr4/Parser.py
  • 54. Assignment 1 5/11/2021 Saeed Parsa 54 Note: CLASSPATH is a parameter in the Java Virtual Machine or the Java compiler that specifies the location of user-defined classes and packages. The parameter may be set either on the command-line, or through an environment variable.  To add ANTLR to class path, • Click on ‘Windows search’ key and enter “environment” • go to the following address (you may click on the following address to get access to the related document): • Control Panel > System > Advanced system settings > Environment variables  Under Environment Variables, you can see two sections.  The top section shows User variables,  The bottom section shows System Variables.
  • 55. Assignment 1 5/11/2021 Saeed Parsa 55  In either of them, find for Variable name PATH or path.  If it is available click on path in the system variable window and then press edit.  Pressing the “Edit” button a new window labeled ‘Edit system variable’ will pop up.  Press the “new” button, and add the following three items to the list” 1. The path for accessing Java: C:Program FilesJavajdk-13.0.2bin 2. The 3rd party Java libraries address: C:javalib 3. Class path: %CLASSPATH%
  • 60. The place of IUST in the world 5/11/2021 Saeed Parsa 60 https://www.researchgate.net/publication/328099969_Software_Fault_Localisation_A_Systematic_Mapping_Study