A%20Two-Dimensional%20Separation%20of%20Concerns%20for%20Compiler%20Construction - PowerPoint PPT Presentation

About This Presentation
Title:

A%20Two-Dimensional%20Separation%20of%20Concerns%20for%20Compiler%20Construction

Description:

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

Number of Views:103
Avg rating:3.0/5.0
Slides: 21
Provided by: uae63
Learn more at: https://gray.cs.ua.edu
Category:

less

Transcript and Presenter's Notes

Title: A%20Two-Dimensional%20Separation%20of%20Concerns%20for%20Compiler%20Construction


1
A Two-Dimensional Separation of Concernsfor
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

2
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

adding new semantic operations (Visitor)
defining new abstract syntax tree (AST) nodes
(Inheritance)
3
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.

4
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.

v
5
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

6
Visitor Pattern (II)
  • Object-Oriented Visitor
  • Aspect-Oriented Visitor

7
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

v

8
Inheritance or Visitor
?
9
Compiler Matrix
Vertical modularization ? each column an class
? Inheritance Pattern Horizontal modularization
? each row an aspect ? Visitor Pattern
10
Pattern Transformation
11
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

12
Phase I Build AST Nodes
13
Phase II Adding Semantics Operations
14
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 )

15
Phase III Extending Syntax Grammar
16
Aspect Weaving and Unweaving
17
A General Example
  • Payroll System

18
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

19
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.

20
Questions?
Write a Comment
User Comments (0)
About PowerShow.com