• No results found

Today. Generic Language g Technology (2IS15)

N/A
N/A
Protected

Academic year: 2021

Share "Today. Generic Language g Technology (2IS15)"

Copied!
8
0
0

Loading.... (view fulltext now)

Full text

(1)

Generic Language Technology (2IS15)g g gy ( ) Domain Specific Language Design

Prof.dr. Mark van den Brand

Today

Toolsfor software analysis and manipulationy

Programming language independent(parametric)

The story is from the IDE/PEperspective

First a general overview, then introduction to specific technologies

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 1

What …

... is a language?g g

... is a Programming Environment (PE)?

... is Generic Language Technology (GLT)?

... is a Program Generator?

... is a Programming Environment Generator?

What …

... is a language?g g

... is a Programming Environment (PE)?

... is Generic Language Technology (GLT)?

... is a Program Generator?

(2)

What is a language?

A programming languageg g g g

Assembler, Cobol, PL/I, C, C++, Java, C#, ...

A D i S ifi L (DSL)

A Domain-Specific Language (DSL)

SQL for queries

BibTex for entries in a bibliographyBibTex for entries in a bibliography

Euris for railroad emplacement safety

Risla for financial products

WebDSL for web pages

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 4

Aspects of a Language

Syntaxy

Textual/graphical form of declarations, statements, etc.

Static Semantics

Scope and type of variables, conversions, formal/actual parameters, etc.

Queries: who calls who, who uses variable X, ..., ,

Dynamic Semantics

Program execution

Tooling

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 5

What …

... is a language?g g

... is a Programming Environment (PE)?

... is Generic Language Technology (GLT)?

... is a Program Generator?

... is a Programming Environment Generator?

What is a Programming Environment

A system that supports the development of

i d t

programs in order to:

Increase productivity:

Uniform user-interface (UI); integrated tools

Increased interaction; early error detection

Increase quality:

Integrated version managementIntegrated version management

Integrated testing

(3)

Classical PE

Command line oriented:

Text editor onlyxemacs or vim

j

gcc or javac

Programs stored in files

Complete recompilation after each changeComplete recompilation after each changeLate error detection

Debugging requires recompilation with different options

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 8

Integrated PE (IPE)

Integrated Development Environment (IDE)g ( )

Specialized, syntax-directed, editor for each languageCommon intermediate representation for all toolsIncremental processing (reusing results of previous

calculations)One GUIOne GUI

Early error detectionSyntax errors

Undeclared variables

Type errors in expressions

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 9

Functionality of an IDE

Syntax-directed editing/highlighting, pretty printingy g g g g y g

Typechecking

Restructuring

Versioning

Executing, debugging, profiling T ti

Testing

Documenting

Examples of IDEs

Eclipse: www.eclipse.orgg

Integrated Development Environment (IDE) for Java

Plug-in mechanism for extensions

MS Vi l St di d i ft / t di

MS Visual Studio: msdn.microsoft.com/vstudio

(4)

What …

... is a language?g g

... is a Programming Environment (PE)?

... is Generic Language Technology (GLT)?

... is a Program Generator?

... is a Programming Environment Generator?

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 12

What is Generic Language Technology?

Goal: Enable the easy creation of language-specific y g g tools and programming environments

Separate language-specificaspects from generic

aspects aspects

Approach:

Find good, reusable, solutions for generic aspectsd good, eusab e, so ut o s o ge e c aspects

Find ways to define language-specific aspects

Find ways to generate tools from language-specific d fi iti

definitions

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 13

Generic Aspects

User-interface

Text editor

Program storage

Documentation

Defining Language Aspects

Syntaxy

Lexical and context-free grammar

Static semantics

Ad hoc?

Dynamic semantics

Ad hoc?

(5)

From Definition to Tool

Syntaxy

Scanner and parser generation

Static semantics

???

Dynamic semantics

???

???

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 16

Examples of Generic IDEs

Eclipse IMP: http://eclipse-imp.sourceforge.net/imp.html

A framework for Generic Integrated Development Environments (IDE)

The goal of the Eclipse IMP is to provide an extensibleThe goal of the Eclipse IMP is to provide an extensible platform for the development of high-quality, fully-featured, language-specific IDE's in Eclipse

Spoofax/IMP:Spoofax/IMP: http://strategoxt.org/Spoofaxhttp://strategoxt org/Spoofax

Rascal: http://www.rascal-mpl.org/

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 17

What …

... is a language?g g

... is a Programming Environment (PE)?

... is Generic Language Technology (GLT)?

... is a Program Generator?

... is a Programming Environment Generator?

What is Program Generator?

Definition of problem P

Generator

(6)

Examples of Program Generators (1)

Regular expression matching:g g

Problem: recognize regular expressions R1, ..., Rnin a text

Generates: finite automaton

Generates: finite automaton

Web sites

Problem: create uniform web site for set of HTML pagesp g

Generate: HTML code with standard layout and site map

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 20

Examples of Program Generators (2)

Generate bibliographic entries; inputg

@article{BJKO00, author = {Brand, {M.G.J. van den} and Jong, {H.A. de} and P. Klint and P. Olivier}, title = {{E}fficient {A}nnotated {T}erms},

journal = {Software, Practice \& Experience}, year = {2000},

pages = {259--291},

p g { },

volume = {30}} generates:

M G J van den Brand H A de Jong P Klint and P A Olivier Efficient M.G.J. van den Brand, H.A. de Jong, P. Klint and P.A. Olivier, Efficient Annotated Terms, Software, Practice & Experience, 30(3):259―291, 2000

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 21

Examples of Program Genators (3)

Compiler:

Input: Java program

Generates: JVM code C

C preprocessor:

Input C program with #include, #definedirectives

Generates C program with directives replacedGenerates C program with directives replaced

Program Generators (summary)

Problem description is specific and is usually written y in a Domain-Specific Language (DSL)

Generator contains generic algorithms and information about application domain information about application domain.

A PG isolates a problem description from its implementation peasier to switch to other implementation methods.

Improvements/optimizations in the generator are good for all generated programs

(7)

What …

... is a language?g g

... is a Programming Environment (PE)?

... is Generic Language Technology (GLT)?

... is a Program Generator?

... is a Programming Environment Generator?

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 24

What is Programming Environment

Generator (PEG)?

Generator (PEG)?

A PEG is a program generator applied in the p g g pp domain of programming environments

Input: description of a desired language L

Output: (parts of) a dedicated Lenvironment

Advantages:

U if i t f diff t l

Uniform interface across different languages

Generator contains generic, re-usable, implementation knowledge

Disadvantage: some UI optimizations are hard

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 25

Programming Environment Generator

Formal definition of language L

Generator Generator

PEG = collection of program generators

Definition of L static semantics Definition of L syntax Definition of L dynamic semantics

Parser Typechecker Evaluator Generator

yp

(8)

Programming Environment Generator

PEG allows definition of (small) (domain specific) ( ) ( ) languages

• PEG = language workbench

/ Faculteit Wiskunde en Informatica 7-9-2011 PAGE 28

Summary

Evolution from traditional PE via IDE to language g g workbenches

How to describe the syntax and semantics of a (small) (domain specific) language

(small) (domain specific) language

Questions so far?Questions so far?

References

Related documents

The proposed Peyton Slough Hydraulic Relief Project consists of removing an existing hydraulic restriction in Peyton Slough to improve water exchange between McNabney Marsh and Suisun

The threshold into the stadium is through a series of layers which delaminate from the geometry of the field to the geometry of the city and creates zones of separation,

The whole system, with external I/O IGBT fiber optic gate signals, executes in real- time at 80 µ s time step under the RT-Lab real-time distributed simulation software on

The Rater will discuss with the Ratee the proposed objective, target completion date, the evaluation or measurement criteria by which successful results can be identified, costs,

I further understand that La Trobe University, as an education provider, is required to provide information about my enrolment and my contact details in Australia to the Department

Questions regarding scholarship application may be directed to: [email protected].. Davis- Monthan

31 Dette er rimelig siden vi prøver ˚ a forklare hvorfor sekter kunne etablere seg 32 Det engelske ordet coping har jeg her oversatt til h˚ andtering... 3) søke etter en