Ingen bildrubrik - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Ingen bildrubrik

Description:

Declarative OO Language Implementation. using JastAdd. Torbj rn Ekman, University of Oxford ... Generate IDEs. name completion, refactoring support, ... Principle 1 ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 16
Provided by: tobbe
Category:
Tags: bildrubrik | ides | ingen

less

Transcript and Presenter's Notes

Title: Ingen bildrubrik


1
Declarative OO Language Implementation using
JastAdd
Torbjörn Ekman, University of OxfordGörel
Hedin, Lund University
2
Agenda
  • Introduction principles, mechanisms,
  • Demo implement a small language from scratch
  • Demo extend Java with the foreach loop
  • Getting started skeletons, reusable components,

3
Things you can do with JastAdd
  • Implement a compiler
  • Java, Modelica, RAPID
  • Extend with new language constructs
  • Java 1.4 ??Java 5 ??AspectJ
  • Extend with new source code analyses
  • non-null analysis, dataflow analysis, CK metrics,
  • Build tools for domain-specific languages
  • consistency analysis, source code generation,
  • Source-to-source translation
  • normalization, prettyprinting, update code to use
    new library,
  • Generate IDEs
  • name completion, refactoring support,

4
Principle 1
Dont do semantics in the parser.Just build the
tree.
5
Example output
JastAdd
bytecode
source code
scanner parser
AST
another AST
Do the complex things here!
Build the tree
analysis results
6
Principle 2
The AST is the only datastructure you need
7
The usual way
AST
x
symbol table
x
flow graph
8
Principle 3
Think declaratively!
9
Attribute grammars
What attributes would I like this node to have?
Define by equations a f(b, c, d) b c d

a
10
Synthesized and inherited attributes
Inherited attribute A parent defines the
attribute
child.i
s
i
s
Synthesized attribute The node defines the
attribute
11
Think declaratively! Example
Are assignments type correct?
Assign
Ida
Add
Attributes
syn String Exp.type() eq Add.type()
integer eq Id.type() decl().type() syn
Id.decl() eq Id.decl() lookup(name) inh
Id.lookup(String s) eq Method.getBody().lookup(s)

Idb
Idc
a bc
12
JastAdd solves the equations
Think declaratively!
The AST is automatically correctly attributed!
13
Main program
Program
Program p parse(inputfile) p.printErrors()
Assign


14
Summary of principles
  • The parser just builds the AST
  • The AST is the only datastructure you need
  • Think declaratively!

15
Mechanisms
  • Basics
  • Synthesized and inherited attributes
  • Reference attributes
  • Parameterized attributes
  • Broadcasting inherited values to subtree
  • Intertype declarations for modularizing across
    AST
  • Integration with imperative code (can use the
    attributes)
  • Advanced
  • Circular attributes (fixed-point evaluation)
  • Collection attributes (e.g., for
    cross-references)
  • Nonterminal attributes (for growing the AST)
  • Rewrites (for adjusting the AST)
Write a Comment
User Comments (0)
About PowerShow.com