iustcompiler
IUST Compiler Design: Principles, Techniques, and Tools
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.3%) to scientific vocabulary
Keywords
Repository
IUST Compiler Design: Principles, Techniques, and Tools
Basic Info
- Host: GitHub
- Owner: m-zakeri
- License: mit
- Language: Python
- Default Branch: master
- Homepage: https://m-zakeri.github.io/IUSTCompiler/
- Size: 8.8 MB
Statistics
- Stars: 7
- Watchers: 1
- Forks: 25
- Open Issues: 13
- Releases: 2
Topics
Metadata Files
README.md
Compiler Course Code Snippets
Welcome to the repository containing course materials and code snippets developed for teaching the compiler at Iran University of Science and Technology (UST). This repository includes various language grammars written in ANTLR v4 format. For each grammar, the source code of the generated Lexer and Parser is available in Python 3.8.x.
Please note that this repository is intended to be updated regularly. It would be appreciated if you use our repository by forking it.
For any queries or concerns, feel free to reach out to me at m-zakeri[at]live.com. Alternatively, you can refer to the documentation for more details.
Examples
This section provides examples of the outputs that can be generated by the code snippets in this repository.
Three Address Codes
Figure 1 illustrates how a single pass compiler can generate three address code for assignment statements with the minimum number of temporary variables, starting with T:

Fig 1: Examples of three address codes generated by ANTLR for AssignmentStatement grammar.
Abstract Syntax Tree (AST)
Figure 2 demonstrates how a single pass compiler can generate an abstract syntax tree (AST) for assignment statements:

Fig 2: Examples of abstract syntax trees (AST) generated by ANTLR for AssignmentStatement grammar.
The above tree corresponds to the following expressions:
python
a1 := (2 + 12 * 3) / (6 - 19)
a2 := 2 + 3 * 4
Repository Structure
This section describes the structure of the repository:
Grammars
The grammars directory contains various grammar files:
gram1: ANTLR hello world grammar.Expr1: Simple grammar for handling mathematical expressions without any attribute and action.Expr2: Simple attributed grammar for handling mathematical expressions withcode()attribute.Expr3: Same asExpr2grammar.AssignmentStatement1.g4: Grammar to handle multiple assignment statements and mathematical expressions in languages like Pascal and C/C++.AssignmentStatement2.g4: Same asAssignmentStatement1.g4grammar with attributes for holding rule code and rule type.AssignmentStatement3.g4: Grammar to handle multiple assignment statements and mathematical expressions in languages like Pascal and C/C++. It provides semantic rules to perform type checking and semantic routines to generate intermediate representation.AssignmentStatement4.g4: Similar toAssignmentStatement3.g4grammar but designed to generate intermediate representation (three addresses codes) with the minimum number of "temp" variables.CPP14_v2: ANTLR grammar for C++14 forked from the official ANTLR website. Some bugs have been fixed and also the rule identifiers have been added to the grammar rules.EMail.g4: Lexical grammar to validate email addresses.EMail2.g4: Lexical grammar to validate email addresses, fixing bugs inEMail.g4.
Language Applications
The language_apps package contains Lexer and Parser codes for each grammar in the grammars directory, along with a main driver script to demonstrate the type checking and intermediate code generation based on semantic rules and semantic routines.
Terminal Batch Scripts
The terminal_batch_script directory contains several batch scripts to run ANTLR in terminal (Windows) to generate target code in JAVA language. These code snippets belong to my early experiences with ANTLR.
Lecture & Tutorials
The Lectures section of this repository offers comprehensive resources for learning Compiler Design. Each lecture is designed to simplify complex concepts and explain them in an intuitive manner through practical examples. The aim is to make the subject matter accessible and engaging for students, regardless of their prior knowledge or experience with compiler design.
Further Reading
ANTLR slides: - Introduction - Getting started in Java - Getting started in C#
For Reading Compiler Design Lectures: See HERE
Owner
- Name: Morteza Zakeri
- Login: m-zakeri
- Kind: user
- Location: Planet Earth
- Company: @Micropedia
- Website: m-zakeri.github.io
- Twitter: _zakeri_
- Repositories: 8
- Profile: https://github.com/m-zakeri
Ph.D. candidate, software engineer, machine intelligence
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Zakeri-Nasrabadi" given-names: "Morteza" orcid: "https://orcid.org/0000-0003-4289-0606" title: "CodART" version: 0.1.0 doi: https://doi.org/10.5281/zenodo.6510640 date-released: 2022-05-01 url: "https://m-zakeri.github.io/IUSTCompiler"