Introduction to Today Generic Language Technology � Tools for software analysis and manipulation Mark van den Brand � Programming language independent (parametric) Paul Klint � The story is from the IDE/PE perspective � The story is from the IDE/PE perspective Jurgen Vinju Jurgen Vinju � First a general overview, then introduction to specific technologies 1 2 Introduction to Generic Language Technology Introduction to Generic Language Technology What ... What ... � ... is a language? � ... is a language? � ... is a Programming Environment (PE)? � ... is a Programming Environment (PE)? � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? � ... is a Program Generator? � ... is a Program Generator? � ... is a Programming Environment Generator? � ... is a Programming Environment Generator? 3 4 Introduction to Generic Language Technology Introduction to Generic Language Technology
What is a Language? Aspects of a Language � A programming language � Syntax − Assembler, Cobol, PL/I, C, C++, Java, C#, ... − Textual form of declarations, statements, etc. � A Domain-Specific Language (DSL) � Static Semantics − SQL for queries − Scope and type of variables, conversions, formal/actual parameters, etc. − BibTex for entries in a bibliography − Queries: who calls who, who uses variable X, ... − Euris for railroad emplacement safety � Dynamic Semantics − Risla for financial products − Program execution 5 6 Introduction to Generic Language Technology Introduction to Generic Language Technology What is a Programming What ... Environment? A system that supports the development of � ... is a language? programs in order to: � ... is a Programming Environment (PE)? � Increase productivity: � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? − Uniform user-interface (UI); integrated tools Uniform user-interface (UI); integrated tools � ... is a Program Generator? − Increased interaction; early error detection � ... is a Programming Environment Generator? � Increase quality: − Integrated version management − Integrated testing − Integrated documentation 7 8 Introduction to Generic Language Technology Introduction to Generic Language Technology
Integrated PE (IPE) Classical PE also: Integrated Development Environment (IDE) � Text editor only � Specialized, syntax-directed, editor for each language � Programs stored in files � Common intermediate representation for all tools � Complete recompilation after each change � Incremental processing (reusing results of previous calculations) calculations) � Late error detection � One GUI � Debugging requires recompilation with different options � Early error detection � Example: − Syntax errors − xemacs or vim − Undeclared variables − gcc or javac − Type errors in expressions 9 10 Introduction to Generic Language Technology Introduction to Generic Language Technology Functionality of an IPE Simple, External, View of IPE � Syntax-directed editing/highlighting, pretty printing Text � Typechecking Edit � Restructuring Commands Integrated Integrated � Versioning Text Programming Environment Error � Executing, debugging, profiling Messages � Testing Values � Documenting 11 12 Introduction to Generic Language Technology Introduction to Generic Language Technology
Simple, Internal, View of IPE Examples of IPEs � Eclipse: www.eclipse.org − Integrated Development Environment (IDE) for Java Text parser − Plug-in mechanism for extensions Edit Edit Edit Edit editor editor Commands Commands � MS Visual Studio: msdn.microsoft.com/vstudio Syntax Text pretty printer Tree − IDE for various languages VB, C, C++, C# Manager Error type checker Messages Values evaluator 13 14 Introduction to Generic Language Technology Introduction to Generic Language Technology What is Generic Language What ... Technology? � ... is a language? � Goal: Enable the easy creation of language- specific tools and programming environments � ... is a Programming Environment (PE)? � Separate language-specific aspects from generic � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? aspects aspects � ... is a Program Generator? � Approach: � ... is a Programming Environment Generator? − Find good, reusable, solutions for generic aspects − Find ways to define language-specific aspects − Find ways to generate tools from language-specific definitions 15 16 Introduction to Generic Language Technology Introduction to Generic Language Technology
Generic aspects Defining Language Aspects � User-interface � Syntax − Lexical and context-free grammar � Text editor � Static semantics � Program storage � Program storage − Algebraic specification/rewrite rules � Documentation � Dynamic semantics − Algebraic specification/rewrite rules 17 18 Introduction to Generic Language Technology Introduction to Generic Language Technology From Definition to Tool Examples of Generic IPEs � Syntax � Eclipse IMP: http://eclipse-imp.sourceforge.net/imp.html − Scanner and parser generation − A framework for Generic Integrated Development Environments (IDE) � Static semantics − The goal of the Eclipse IMP is to provide an The goal of the Eclipse IMP is to provide an − Term rewriting extensible platform for the development of high- � Dynamic semantics quality, fully-featured, language-specific IDE's in Eclipse. − Term rewriting 19 20 Introduction to Generic Language Technology Introduction to Generic Language Technology
What ... What is a Program Generator? � ... is a language? Definition of � ... is a Programming Environment (PE)? problem P � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? � ... is a Program Generator? Generator � ... is a Programming Environment Generator? Generated program that solves P 21 22 Introduction to Generic Language Technology Introduction to Generic Language Technology Examples of Program Generators (1) Examples of Program Generators (2) � Generate bibliographic entries; input � Regular expression matching: ����������������������� ����������������������������������������������� − Problem: recognize regular expressions R 1 , ..., R n in a ��������������������������������������� text ����� ���� �!!��������������������"���#$�� − Generates: finite automaton Generates: finite automaton %������ ���&�!�'��������������()� *+��������� � Web sites ,��� ���-����� +���$ ���-./00-/1�� − Problem: create uniform web site for set of HTML ����#� ���2��� pages generates: − Generate: HTML code with standard layout and site map 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 23 24 Introduction to Generic Language Technology Introduction to Generic Language Technology
Examples of Program Generators (3) Program Generators (summary) � Compiler: � Problem description is specific and is usually written in a Domain-Specific Language (DSL) − Input: Java program � Generator contains generic algorithms and − Generates: JVM code information about application domain. information about application domain. � C preprocessor: − Input C program with �������� , ������� directives � A PG isolates a problem description from its implementation ⇒ easier to switch to other − Generates C program with directives replaced. implementation methods. � Improvements/optimizations in the generator are good for all generated programs. 25 26 Introduction to Generic Language Technology Introduction to Generic Language Technology What is a Programming Environment What ... Generator (PEG)? � ... is a language? � A PEG is a program generator applied in the domain of programming environments � ... is a Programming Environment (PE)? � Input: description of a desired language L � ... is Generic Language Technology (GLT)? � ... is Generic Language Technology (GLT)? � Output: (parts of) a dedicated L environment Output: (parts of) a dedicated L environment � ... is a Program Generator? � Advantages: � ... is a Programming Environment Generator? − Uniform interface across different languages − Generator contains generic, re-usable, implementation knowledge � Disadvantage: some UI optimizations are hard 27 28 Introduction to Generic Language Technology Introduction to Generic Language Technology
Recommend
More recommend