Today Generic Lanuae Technoloy (2IS15) Domain Specific Lanuae Desin Prof.dr. Mark van den Brand Tools for software analysis and manipulation Prorammin lanuae independent (parametric) The story is from the IDE/PE perspective First a eneral overview, then introduction to specific technoloies / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 1 What What... is a lanuae?... is a Prorammin Environment (PE)?... is Generic Lanuae Technoloy (GLT)?... is a Proram?... is a Prorammin Environment?... is a lanuae?... is a Prorammin Environment (PE)?... is Generic Lanuae Technoloy (GLT)?... is a Proram?... is a Prorammin Environment? / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 2 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 3
What is a lanuae? Aspects of a Lanuae A prorammin lanuae Assembler, Cobol, PL/I, C, C++, Java, C#,... AD Domain-Specific ifi Lanuae (DSL) SQL for queries BibTex for entries in a biblioraphy Euris for railroad emplacement safety Risla for financial products WebDSL for web paes Syntax Textual/raphical 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 Proram execution Toolin / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 4 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 5 What What is a Prorammin Environment... is a lanuae?... is a Prorammin Environment (PE)?... is Generic Lanuae Technoloy (GLT)?... is a Proram?... is a Prorammin Environment? A system that supports the development of prorams in order to: Increase productivity: Uniform user-interface (UI); interated tools Increased interaction; early error detection Increase quality: Interated version manaement Interated testin Interated documentation / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 6 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 7
Classical PE Interated PE (IPE) Command line oriented: Text editor only xemacs or vim cc or javac Prorams stored in files Complete recompilation after each chane Late error detection Debuin requires recompilation with different options Interated Development Environment (IDE) Specialized, syntax-directed, editor for each lanuae Common intermediate representation for all tools Incremental processin (reusin results of previous calculations) One GUI Early error detection Syntax errors Undeclared variables Type errors in expressions / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 8 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 9 Functionality of an IDE Examples of IDEs Syntax-directed editin/hihlihtin, pretty printin Typecheckin Restructurin Versionin Executin, debuin, profilin Testin Documentin Eclipse: www.eclipse.or Interated Development Environment (IDE) for Java Plu-in mechanism for extensions MS Visual Studio: msdn.microsoft.com/vstudio t di IDE for various lanuaes VB, C, C++, C# / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 10 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 11
What What is Generic Lanuae Technoloy?... is a lanuae?... is a Prorammin Environment (PE)?... is Generic Lanuae Technoloy (GLT)?... is a Proram?... is a Prorammin Environment? Goal: Enable the easy creation of lanuae-specific tools and prorammin environments Separate lanuae-specific aspects from eneric aspects Approach: Find ood, reusable, e, solutions o s for eneric e aspects Find ways to define lanuae-specific aspects Find ways to enerate tools from lanuae-specific definitions iti / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 12 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 13 Generic Aspects Definin Lanuae Aspects User-interface Text editor Proram storae Documentation Syntax Lexical and context-free rammar Static semantics Ad hoc? Dynamic semantics Ad hoc? / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 14 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 15
From Definition to Tool Examples of Generic IDEs Syntax Scanner and parser eneration Static semantics??? Dynamic semantics??? Eclipse IMP: http://eclipse-imp.sourcefore.net/imp.html A framework for Generic Interated Development Environments (IDE) The oal of the Eclipse IMP is to provide an extensible platform for the development of hih-quality, fully-featured, lanuae-specific IDE's in Eclipse Spoofax/IMP: http://strateoxt.or/spoofaxor/spoofax Rascal: http://www.rascal-mpl.or/ / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 16 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 17 What What is Proram?... is a lanuae?... is a Prorammin Environment (PE)?... is Generic Lanuae Technoloy (GLT)?... is a Proram?... is a Prorammin Environment? Definition of problem P Generated proram that solves P / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 18 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 19
Examples of Proram s (1) Examples of Proram s (2) Reular expression matchin: Problem: reconize reular expressions R 1,..., R n in a text Generates: finite automaton Web sites Problem: create uniform web site for set of HTML paes Generate: HTML code with standard layout and site map Generate biblioraphic entries; input @article{bjko00, author = {Brand, {M.G.J. van den} and Jon, {H.A. de} and P. Klint and P. Olivier}, title = {{E}fficient {A}nnotated {T}erms}, journal = {Software, Practice \& Experience}, year = {2000}, paes = {259--291}, volume = {30}} enerates: M.G.J. van den Brand, H.A. de Jon, 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 20 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 21 Examples of Proram Genators (3) Proram s (summary) Compiler: Input: Java proram Generates: JVM code C preprocessor: Input C proram with #include, #define directives Generates C proram with directives replaced Problem description is specific and is usually written in a Domain-Specific Lanuae (DSL) contains eneric alorithms and information about application domain. A PG isolates a problem description from its implementation easier to switch to other implementation methods. Improvements/optimizations in the enerator are ood for all enerated prorams. / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 22 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 23
What... is a lanuae?... is a Prorammin Environment (PE)?... is Generic Lanuae Technoloy (GLT)?... is a Proram?... is a Prorammin Environment? What is Prorammin Environment (PEG)? A PEG is a proram enerator applied in the domain of prorammin environments Input: description of a desired lanuae L Output: (parts of) a dedicated L environment Advantaes: Uniform interface across different lanuaes contains eneric, re-usable, implementation knowlede Disadvantae: some UI optimizations are hard / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 24 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 25 Prorammin Environment PEG = collection of proram enerators Formal definition of lanuae L Definition of L syntax Definition of L static semantics Definition of L dynamic semantics Parser Typechecker Evaluator Dedicated environment for editin, manipulatin and executin L prorams L-parser L-typechecker L-evaluator Interated L-prorammin p environment / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 26 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 27
Prorammin Environment Summary PEG allows definition of (small) (domain specific) lanuaes PEG = lanuae workbench Evolution from traditional PE via IDE to lanuae workbenches How to describe the syntax and semantics of a (small) (domain specific) lanuae Questions so far? / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 28 / Faculteit Wiskunde en Informatica 7-9-2011 PAGE 29