A Two-Dimensional Separation of Concerns for Compiler Construction Carl (Xiaoqing) Wu, Suman Roychoudhury, Barrett R. Bryant and Jeffrey G. Gray The University.

Slides:



Advertisements
Similar presentations
Introduction To Compilers And Phase 1 Inside a compiler. Inside a C-- compiler. The compilation process. Example C-- code. Extended Backus-Naur.
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Each design pattern is designed to facilitate one kind of change, i.e. changes in one dimension. However, software evolution can happen in multiple dimensions.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
INTERPRETER Main Topics What is an Interpreter. Why should we learn about them.
Object-Oriented Databases v OO systems associated with – graphical user interface (GUI) – powerful modeling techniques – advanced data management capabilities.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
Visitor Pattern Jeff Schott CS590L Spring What is the Purpose of the Visitor Pattern ? n Represent an operation to be performed on the elements.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Visitor Matt G. Ellis. Intent Metsker: Let developers define a new operation for a hierarchy without changing the hierarchy classes. GoF: Represent an.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Chapter 2 A Simple Compiler
Arrays (Part II). Two- and Multidimensional Arrays Two-dimensional array: collection of a fixed number of components (of the same type) arranged in two.
Interpreter By: Mahmoodreza Jahanseir Amirkabir University of Technology Computer Engineering Department Fall 2010.
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
1 Computer Science 340 Software Design & Testing © Ken Rodham 2003 The “Visitor” Design Pattern Source: "Design Patterns: Elements of Reusable Software"
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
The Interpreter Pattern. Defining the Interpreter Intent Given a language, define a representation for its grammar along with an interpreter that uses.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
1 N Degrees of Separation: Multi-Dimensional Separation of Concern (MDSOC) HyperJ: language and concepts of general concern combination.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
©Ian Sommerville 2000 Software Engineering, 6th edition. Slide 1 Component-based development l Building software from reusable components l Objectives.
{ Graphite Grigory Arashkovich, Anuj Khanna, Anirban Gangopadhyay, Michael D’Egidio, Laura Willson.
Design Pattern Interpreter By Swathi Polusani. What is an Interpreter? The Interpreter pattern describes how to define a grammar for simple languages,
Grammar Variation in Compiler Design Carl Wu. Three topics Syntax Grammar vs. AST Component(?)-based grammar Aspect-oriented grammar.
On the Modularity Assessment of Aspect- Oriented Multi-Agent Systems Product Lines: a Quantitative Study Camila Nunes
Generative Programming. Automated Assembly Lines.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
1 Xiaoqing Wu, Barrett R. Bryant, Jeff Gray and Suman Roychoudhury University of Alabama at Birmingham Separation of Concerns in Compiler Development Using.
A Technique for Constructing Aspect Weavers using a Program Transformation Engine Jeff Gray Suman Roychoudhury Department of Computer and Information Sciences.
Towards Multi-Paradigm Software Development Valentino Vranić Department of Computer Science and Engineering Faculty of Electrical Engineering.
Introducing Allors Applications, Tools & Platform.
Aspect-Oriented Action Semantics Descriptions Luis Menezes University of Pernambuco
11/25/2015© Hal Perkins & UW CSEH-1 CSE P 501 – Compilers Implementing ASTs (in Java) Hal Perkins Winter 2008.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
1 Model-based Aspect Weaver Construction Suman Roychoudhury Frédéric Jouault Jeff Gray {roychous, jouault, cis.uab.edu This project is supported.
The Visitor Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
Applying Aspect-Orientation in Designing Security Systems Shu Gao Florida International University Center for Advanced Distributed Systems Engineering.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Interpreter By: Mahmoodreza Jahanseir Amirkabir University of Technology Computer Engineering Department Fall 2010.
Chap. 7, Syntax-Directed Compilation J. H. Wang Nov. 24, 2015.
Syntax-Directed Definitions CS375 Compilers. UT-CS. 1.
AUTOMATIC GENERATION OF MODEL TRAVERSALS FROM METAMODEL DEFINITIONS Authors: Tomaž Lukman, Marjan Mernik, Zekai Demirezen, Barrett Bryant, Jeff Gray ACM.
CSCE 240 – Intro to Software Engineering Lecture 3.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
CSE784 – Software Studio Jim Fawcett Fall 2002.
OOP - Object Oriented Programming
Introduction to Design Patterns
Presentation by Julie Betlach 7/02/2009
Implementing Language Extensions with Model Transformations
Design Pattern: Visitor
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Interpreter Pattern.
Tiger Compiler Project
Ivan Kurtev, Klaas van den Berg Software Engineering Group
Course Overview PART I: overview material PART II: inside a compiler
Implementing Language Extensions with Model Transformations
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Aspect Oriented Software Design
Presentation transcript:

A Two-Dimensional Separation of Concerns for Compiler Construction Carl (Xiaoqing) Wu, Suman Roychoudhury, Barrett R. Bryant and Jeffrey G. Gray The University of Alabama at Birmingham, USA Marjan Mernik University of Maribor, Slovenia

Language Evolution During language evolution, compiler construction is usually performed along two dimensions: The Inheritance pattern and the Visitor pattern are used to improve modularity in each case defining new abstract syntax tree (AST) nodes (Inheritance) adding new semantic operations (Visitor)

Inheritance Pattern (I) A pure object-oriented approach based on AST nodes –Declare an abstract super class for all AST nodes with virtual methods for node operations inside the class. –Define a class for each AST node and implement the methods that inherit from the super node class.

Inheritance Pattern (II) Pros –Easy to extend the grammar. Any new symbols can be added to the base grammar as a separated class Cons –The semantic operations crosscut the various other class boundaries –Adding a new operation requires an invasive change throughout the existing class hierarchy. √ ×

Visitor Pattern (I) Semantics operation oriented –All the methods pertaining to one operation of the nodes are encapsulated into a single visitor unit –Visitor is separated with node classes and can be freely added or deleted Object-Oriented Implementation Aspect-Oriented Implementation

Visitor Pattern (II) Object-Oriented VisitorAspect-Oriented Visitor

Visitor Pattern (III) Pros –Adding new semantics operations is easy Cons –Operations belong to one AST node crosscut several visitor classes. Adding a new node to the existing class hierarchy will cause an invasive change to all of the visitors √ ×

Inheritance or Visitor

Compiler Matrix Vertical modularization → each column = an class → Inheritance Pattern Horizontal modularization → each row = an aspect → Visitor Pattern

Pattern Transformation

A Simple Expression Language Syntax Grammar expression ::= term | binary_expression binary_expression ::= sum | difference sum ::= expression ‘+’ expression difference ::= expression ‘-’ expression term ::= integer_literal | real_literal Semantics operations Value evaluation Type checking Pretty print

Phase I: Build AST Nodes class Sum implements Binary_expression, ASTNode{ public Expression expression1; public Expression expression2; public Sum (Expression expression1, Expression expression2){ this.expression1 = expression1; this.expression2 = expression2; }; }

Phase II: Adding Semantics Operations aspect ValueEval { public abstract Double ASTNode.valueEval(); public Double Real_literal.valueEval(){ return Double.valueOf(lexeme); }; public Double Integer_literal.valueEval(){ return Double.valueOf(lexeme); }; public Double Difference.valueEval(){ Double value1 = expression1.valueEval(); Double value2 = expression2.valueEval(); return new Double (value1.doubleValue()- value2.doubleValue()); }; public Double Sum.valueEval(){ Double value1 = expression1.valueEval(); Double value2 = expression2.valueEval(); return new Double (value1.doubleValue()+value2.doubleValue()); }; }

Phase III: Extending Syntax Grammar expression ::= term | binary_expression | unary_expression binary-expression ::= sum | difference | quotient | product sum ::= expression ‘+’ expression difference ::= expression ‘-’ expression quotient ::= expression ‘/’ expression product ::= expression ‘*’ expression unary_expression ::= ‘-’ term term ::= integer_literal | real_literal | parenthesized_expression parenthesized_expression ::= ‘(’expression ‘)’

Phase III: Extending Syntax Grammar class Sum implements Binary_expression, ASTNode{ public Expression expression1; public Expression expression2; public Sum (Expression expression1, Expression expression2){ this.expression1 = expression1; this.expression2 = expression2; }; public Double valueEval() { Double value1 = expression1.valueEval(); Double value2 = expression2.valueEval(); return new Double(value1.doubleValue()+value2.doubleValue()); } //pretty print method //type checking method }

Aspect Weaving and Unweaving Demo

A General Example Payroll System

Future Work More complex programming language designs Aspect weaving and unweaving –Multiple visitor functions for one semantics operation of one class –Attributes of aspects The pattern transformation approach for other patterns –Observer –Mediator –Abstract Factory

Conclusion By exploring the essence of the compiler matrix, we developed an approach for compiler construction in two dimensions –Based on pattern transformation –Using object-orientation and aspect-orientation The pattern transformation approach can be also utilized in other software system development and extended to other patterns –Multi-dimensional evolution needs exist in software development, no single design principle or pattern offers a panacea toward addressing problems of change evolution. –Transformation techniques applied to design patterns offer an alternative to alleviating this problem.

Questions?