QGE - an Attribute Grammar Based System to Assess Grammars Quality

Total Page:16

File Type:pdf, Size:1020Kb

QGE - an Attribute Grammar Based System to Assess Grammars Quality Universidade do Minho Escola de Engenharia Departamento de Informatica´ Master Course in Computing Engineering Joao˜ Carlos Alves Cruz QGE - An Attribute Grammar based System to assess Grammars Quality Master dissertation Supervised by: Pedro Rangel Henriques Co-supervised by: Daniela da Cruz Braga, October 27, 2015 Universidade do Minho Escola de Engenharia Departamento de Informatica´ Master Course in Computing Engineering Joao˜ Carlos Alves Cruz QGE - An Attribute Grammar based System to assess Grammars Quality Master dissertation Supervised by: Pedro Rangel Henriques Co-supervised by: Daniela da Cruz Braga, October 27, 2015 PARECER Serve o presente parecer para declarar que o aluno Joao˜ Carlos Alves Cruz concluiu, conforme esper- ado, a escrita do seu relatorio´ de dissertac¸ao.˜ O documento foi revisto pelos orientadores, os quais atestam a sua validade cient´ıfica, assim como o cumprimento dos objetivos propostos para esta etapa. Mais se informa que as atividades de mestrado do aluno Joao˜ Carlos Alves Cruz decorrem dentro dos planos e prazos inicialmente previstos. ORIENTADOR Pedro Rangel Henriques CO - ORIENTADOR Daniela da Cruz ACKNOWLEDGEMENTS a ABSTRACT The development and support of a software system is a complex task, therefore software engineering is responsible to supply a collection of techniques and scientific methods, to deal and cope with such complexity. Analysis, modeling/specification, design, maintenance, among others, are activities included in this field of engineering. This master work aims at proposing an approach for the application of these techniques and meth- ods within languages, more precisiley, grammars. Emphasis is put on the grammars development process, implementation and maintenance, aiming for better results, in terms of efficiency and quality, concerning both the generated language and its processor. Assuming a grammar, gaps were identified related to the study of its quality, more specific, in terms of ease of learning (reading and understand- ing), ease of derivation and maintenance, as well as in terms of efficiency, like the language sentences recognition and the generation of the language processor. A set of metrics is proposed to overcome those gaps and improve the quality of grammars. This process is based on: i) selecting a set of well-defined software metrics, for the quantitative measurement of the quality of grammars; ii) deciding how each metric relates to the characteristics which affect the quality of a grammar. The solution that will be presented here aims at developing a tool, based on Attribute Grammars to assess, in an automatic way, the quality of grammars. The implementation of the grammars quan- tification process enables the achievement and discussion of results for a given attribute grammar as well, as it allows us to take elations concerning the language that is defined by this grammar, due to a symbiotic relationship between the two concepts . Another important aspect, after reading the results obtained by this process is the direct manipulation of grammars, turning them into a higher quality software product, validated by well-defined software engineering techniques. Keywords: grammar engineering, attribute grammars, software metrics, software quality and main- tenance b RESUMO A construc¸ao˜ e o suporte de um sistema de software e´ um processo complexo, pelo que a engen- haria de software e´ responsavel´ por proporcionar uma colec¸ao˜ de tecnicas´ e metodos´ cient´ıficos, de acordo com essa complexidade. Inclui atividades como a analise,´ modelac¸ao/especificac¸˜ ao,˜ design, implementac¸ao,˜ manutenc¸ao,˜ entre outros. Neste documento de tese de mestrado propoe-se˜ uma abordagem de aplicac¸ao˜ destas tecnicas´ e metodos´ no ambitoˆ das linguagens, mais precisamente, das gramaticas,´ num ramo da engenharia de software conhecido por Engenharia Gramatical. A proposta foca-se no processo de desenvolvimento, implementac¸ao˜ e manutenc¸ao˜ de gramaticas´ com o intuito de melhorar os resultados em termos de eficienciaˆ e qualidade, quer da linguagem definida pela gramatica,´ quer do respetivo processador. Pesquisando no universo da engenharia gramatical, identificaram-se lacunas referentes a estudos sobre a sua qualidade, mais propriamente, em termos de facilidade de aprendizagem (leitura e compreensao),˜ facilidade de derivac¸ao˜ e manutenc¸ao,˜ bem como em termos de eficiencia,ˆ tanto no reconhecimento de frases da linguagem como na gerac¸ao˜ de um processador para essa linguagem, e propoe-se˜ uma soluc¸ao˜ para superar tais lacunas, atraves´ de um processo de avaliac¸ao˜ baseado em medidas rigorosas de certos parametros.ˆ Este processo baseia-se: i) na selec¸ao˜ de um conjunto de metricas´ de software bem definidas, para a aferic¸ao˜ quantitativa da qualidade das gramaticas;´ ii) na escolha da forma como cada metrica´ se relaciona com as caracter´ısticas que influenciam a qualidade de uma gramatica.´ A soluc¸ao˜ que sera´ aqui apresentada visa o desenvolvimento de uma ferramenta, baseada em Gramaticas´ de Atributos para aferir, de uma forma automatica,´ a qualidade das gramaticas.´ A implementac¸ao˜ do processo de avaliac¸ao˜ quantitativa de gramaticas´ possibilita a obtenc¸ao˜ e discussao˜ de resultados referentes a uma dada gramatica´ de atributos, bem como, permite tirar elac¸oes˜ referentes a` linguagem que e´ definida por essa gramatica,´ devido a uma relac¸ao˜ simbiotica´ que existe entre os dois con- ceitos. Outro aspecto importante, depois de uma leitura aos resultados obtidos por este processo e´ a manipulac¸ao˜ direta das gramaticas,´ transformando-as num produto de software de maior qualidade, validado por tecnicas´ de engenharia de software bem definidas. Palavras-Chave: engenharia gramatical, gramaticas´ de atributos, metricas´ de software, qualidade de software c CONTENTS Contents........................................... iii 1 INTRODUCTION ................................... 3 1.1 Grammar Engineering .............................. 3 1.2 Motivation..................................... 4 1.3 Aims/Objectives.................................. 6 1.4 Document Structure................................ 7 2 STATE OF THE ART .................................. 8 2.1 The art of Measurement.............................. 8 2.1.1 Measurement in Software Engineering.................. 9 2.1.2 The Scope of Metrics........................... 12 2.1.3 The Theory behind measurement..................... 15 2.1.4 A framework for software measurement................. 16 2.2 Quality of Languages............................... 18 2.3 Quality of Grammars............................... 22 2.3.1 Formal Grammar Definitions....................... 22 2.3.2 Assessing Grammar Quality....................... 27 2.3.3 Metrics for Grammars .......................... 33 3 THEPROBLEMANDITSCHALLENGES ...................... 41 3.1 Tool Description ................................. 42 4 GQE - GRAMMAR QUALITY EVALUATOR .................... 44 4.1 A Tool for Metric Evaluation........................... 44 4.2 GQE Architecture................................. 45 4.3 Grammar Objects................................. 47 4.3.1 Context-Free Grammar.......................... 48 4.3.2 Attribute Grammar............................ 55 4.4 ANTLR Linking Component........................... 58 4.5 Splitter Expander................................. 59 4.6 GQE Interface................................... 61 4.7 Execution Flow.................................. 62 5 GQEMAINRESULTS ................................. 64 5.1 CFG analysis: Lisp Language .......................... 64 5.2 AG analysis: Lisp Language ........................... 70 6 CONCLUSIONS .................................... 75 iii Contents 6.1 Conclusions.................................... 75 6.2 Future work.................................... 77 AGRAMMAROFANTLRMETA - LANGUAGE .................... 81 BTHEANTLRTOOL ..................................101 B.1 Generated Code..................................103 B.2 ANTLR Grammar Format ............................105 B.2.1 Lexicon..................................105 B.2.2 Structure .................................106 B.2.3 Parser Rules ...............................107 B.2.4 Actions and Attributes..........................107 B.2.5 Lexer Rules................................108 C NATURAL LANGUAGES TOOLS . 110 C.1 Perl Module Lingua::IdSplitter..........................110 C.2 WordNet......................................111 C.2.1 Relations .................................111 C.2.2 Options..................................113 C.3 Perl Module WordNet::QueryData........................115 iv LISTOFFIGURES Figure 1 Measurement for promotion ...................... 11 Figure 2 Example aspects of a productivity model................ 12 Figure 3 The ISO 9126-1 software quality model ................ 14 Figure 4 Empirical relations for the attribute ”height”.............. 15 Figure 5 Derivation Tree of a production..................... 25 Figure 6 Dependency Graph between Symbols of a grammar that specifies List lan- guage................................... 26 Figure 7 Activity Diagram ............................ 43 Figure 8 Grammar Quality Evaluator Logo.................... 45 Figure 9 Structural diagram with the four main components of GQE. 46 Figure 10 Structural diagram of the Grammar Objects component. 47 Figure 11 Data structure for productions of the grammar from Example1. 50 Figure 12 Structural diagram of the ANTLR linking component.......... 58 Figure 13 Structural diagram of the SplitterExpander component.
Recommended publications
  • A Course Material on OBJECT ORIENTED PROGRAMMING by Mr
    CS 8392 OBJECT ORIENTED PROGRAMMING A Course Material on OBJECT ORIENTED PROGRAMMING By Mr.C.KAMATCHI ASSISTANT PROFESSOR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING PRATHYUSHA ENGINEERING COLLEGE 1 CS 8392 OBJECT ORIENTED PROGRAMMING CS 8392 OBJECT ORIENTED PROGRAMMING S.NO CONTENTS PAGE NO Unit I – OVERVIEW 1.1 Why Object-Oriented Programming in C++ 9 1.1.1 History of C++ 9 1.1.2 Why C++? 9 1.2 Native Types 10 1.2.1 Implicit conversions (coercion) 10 1.2.2 Enumeration Types 10 1.3 Native C++ Statements 11 1.4 Functions and pointers 11 1.4.1 functions 11 1.4.2 Declarations 12 1.4.3 Parameters and arguments 13 1.4.4 Parameters 14 1.4.5 by pointer 14 1.5 Pointers 17 1.5.1 Pointer Arithmetic 18 1.6. Implementing Adts In The Base Language. 19 1.6.1Simple ADTs 19 1.6.2 Complex ADTs 19 3 CS 8392 OBJECT ORIENTED PROGRAMMING UNIT II -BASIC CHARACTERISTICS OF OOP 2.1 Data Hiding 21 2.2 Member Functions 22 2.2.1 Defining member functions 22 2.3 Object Creation And Destruction 23 2.3.1 Object Creation 23 2.3.2 Accessing class members 24 2.3.3 Creation methods 26 2.3.4 Object destruction 27 2.4 Polymorphism And Data Abstraction 28 2.4.1 Polymorphism 28 2.5 Data Abstraction 30 2.5.1 Procedural Abstraction 30 2.5.2Modular Abstraction 31 2.5.3 Data Abstraction 31 2.6 Iterators 33 2.7 Containers 34 UNIT III -ADVANCED PROGRAMMING 3.1 Templates 36 3.1.1 Templates and Classes 38 3.1.2 Template Meta-programming overview 42 3.1.3 Compile-time programming 42 3.1.4 The nature of template meta-programming 42 4 CS 8392 OBJECT ORIENTED PROGRAMMING 3.1.5 Building blocks 44 3.2 Generic programming 47 3.2.1 Type parameter 47 3.2.2 A generic function 48 3.2.3 Subprogram parameters 48 3.3 Standard Template Library (Stl) 49 3.3.1 History 50 3.3.2 List of STL implementations.
    [Show full text]
  • C++ for You++, AP Edition, by Maria Litvin and Gary Litvin Is Licensed Under a Creative Commons Attribution-Noncommercial-Sharealike 3.0 Unported License
    An Introduction to Programming and Computer Science Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Software, Inc. Skylight Publishing Andover, Massachusetts Copyright © 1998 by Maria Litvin and Gary Litvin C++ for You++, AP Edition, by Maria Litvin and Gary Litvin is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. You are free: • to Share — to copy, distribute and transmit the work • to Remix — to adapt the work Under the following conditions: • Attribution — You must attribute the work to Maria Litvin and Gary Litvin (but not in any way that suggests that they endorse you or your use of the work). On the title page of your copy or adaptation place the following statement: Adapted from C++ for You++ by Maria Litvin and Gary Litvin, Skylight Publishing, 1998, available at http://www.skylit.com. • Noncommercial — You may not use this work for commercial purposes. • Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. See http://creativecommons.org/licenses/by-nc-sa/3.0/ for details. Skylight Publishing 9 Bartlet Street, Suite 70 Andover, MA 01810 (978) 475-1431 e-mail: [email protected] web: http://www.skylit.com Library of Congress Catalog Card Number: 97–091209 ISBN 0-9654853-9-0 To Marg and Aaron Brief Contents Part One. Programs: Syntax and Style Chapter 1. Introduction to Hardware and Software 3 Chapter 2. A First Look at a C++ Program 23 Chapter 3. Variables and Constants 49 Chapter 4.
    [Show full text]
  • Rupiah: Towards an Expressive Static Type System for Java Pdfsubject
    Rupiah: Towards an Expressive Static Type System for Java by John N. Foster A Thesis Submitted in partial fulfillment of of the requirements for the Degree of Bachelor of Arts with Honors in Computer Science WILLIAMS COLLEGE Williamstown, Massachusetts May 20, 2001 Abstract Despite Java’s popularity, several practical limitations imposed by the language’s type sys- tem have become increasingly apparent in recent years. A particularly glaring omission is the lack of a generic mechanism. As a result of this shortcoming, many recent projects have extended Java to support polymorphism in the style of C++ templates or Ada gener- ics. One project, GJ [BOSW98], adds F-bounded parametric polymorphism [CCH+89] to Java via a homogeneous translation (such that only one class file results from each com- piled source file), and produces bytecode that is compatible with the standard Java Virtual Machine. However while GJ’s simple translation based on erasure allows for maximum interaction with existing Java code, the new parameterized types that it supports do not operate consistently with Java’s semantics for lightweight reflection (i.e., checked type-casts and instanceof operations). We present Rupiah, a language based on features adapted from LOOM [BFP97], a provably type-safe language, and implemented by a translation based on GJ. However its translation differs from GJ’s in that it harnesses Java’s built-in reflection to store infor- mation about parameterized types. The resulting bytecode correctly executes checked cast and instanceof expressions because it has access to the necessary type information at run-time. We also add a ThisType construct, which solves many of the problems that arise when binary methods are mixed with inheritance, and we replace subtyping with a different relation, matching.
    [Show full text]
  • The Java® Virtual Machine Specification Java SE 9 Edition
    The Java® Virtual Machine Specification Java SE 9 Edition Tim Lindholm Frank Yellin Gilad Bracha Alex Buckley 2017-08-07 Specification: JSR-379 Java® SE 9 Release Contents ("Specification") Version: 9 Status: Final Release Release: September 2017 Copyright © 1997, 2017, Oracle America, Inc. and/or its affiliates. 500 Oracle Parkway, Redwood City, California 94065, U.S.A. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. The Specification provided herein is provided to you only under the Limited License Grant included herein as Appendix A. Please see Appendix A, Limited License Grant. Table of Contents 1 Introduction 1 1.1 A Bit of History 1 1.2 The Java Virtual Machine 2 1.3 Organization of the Specification 3 1.4 Notation 4 1.5 Feedback 4 2 The Structure of the Java Virtual Machine 5 2.1 The class File Format 5 2.2 Data Types 6 2.3 Primitive Types and Values 6 2.3.1 Integral Types and Values 7 2.3.2 Floating-Point Types, Value Sets, and Values 8 2.3.3 The returnAddress Type and Values 10 2.3.4 The boolean Type 10 2.4 Reference Types and Values 11 2.5 Run-Time Data Areas 11 2.5.1 The pc Register 12 2.5.2 Java Virtual Machine Stacks 12 2.5.3 Heap 13 2.5.4 Method Area 13 2.5.5 Run-Time Constant Pool 14 2.5.6 Native Method Stacks 14 2.6 Frames 15 2.6.1 Local Variables 16 2.6.2 Operand Stacks 17 2.6.3 Dynamic Linking 18 2.6.4 Normal Method Invocation Completion 18 2.6.5 Abrupt Method Invocation Completion 18 2.7 Representation of Objects
    [Show full text]
  • An Abstract, Reusable, and Extensible Programming Language Design Architecture⋆
    An Abstract, Reusable, and Extensible Programming Language Design Architecture⋆ Hassan A¨ıt-Kaci Universit´eClaude Bernard Lyon 1 Villeurbanne, France [email protected] Abstract. There are a few basic computational concepts that are at the core of all programming languages. The exact elements making out such a set of concepts determine (1) the specific nature of the computational services such a language is designed for, (2) for what users it is intended, and (3) on what devices and in what environment it is to be used. It is therefore possible to propose a set of basic build- ing blocks and operations thereon as combination procedures to enable program- ming software by specifying desired tasks using a tool-box of generic constructs and meta-operations. Syntax specified through LALR(k) grammar technology can be enhanced with greater recognizing power thanks to a simple augmentation of yacc technology. Upon this basis, a set of implementable formal operational semantics constructs may be simply designed and generated (syntax and seman- tics) `ala carte, by simple combination of its desired features. The work presented here, and the tools derived from it, may be viewed as a tool box for generating lan- guage implementations with a desired set of features. It eases the automatic prac- tical generation of programming language pioneered by Peter Landin’s SECD Machine. What is overviewed constitutes a practical computational algebra ex- tending the polymorphically typed λ-Calculus with object/classes and monoid comprehensions. This paper describes a few of the most salient parts of such a system, stressing most specifically any innovative features—formal syntax and semantics.
    [Show full text]
  • Improving Support for Generic Programming in C# With
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Texas A&M Repository IMPROVING SUPPORT FOR GENERIC PROGRAMMING IN C# WITH ASSOCIATED TYPES AND CONSTRAINT PROPAGATION A Thesis by ARAVIND SRINIVASA RAGHAVAN Submitted to the Office of Graduate Studies of Texas A&M University in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE May 2007 Major Subject: Computer Science IMPROVING SUPPORT FOR GENERIC PROGRAMMING IN C# WITH ASSOCIATED TYPES AND CONSTRAINT PROPAGATION A Thesis by ARAVIND SRINIVASA RAGHAVAN Submitted to the Office of Graduate Studies of Texas A&M University in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE Approved by: Chair of Committee, Jaakko J¨arvi Committee Members, Bjarne Stroustrup Marian Eriksson Head of Department, Valerie Taylor May 2007 Major Subject: Computer Science iii ABSTRACT Improving Support for Generic Programming in C# with Associated Types and Constraint Propagation. (May 2007) Aravind Srinivasa Raghavan, B.E, University of Madras Chair of Advisory Committee: Dr. Jaakko J¨arvi Generics has recently been adopted to many mainstream object oriented lan- guages, such as C# and Java. As a particular design choice, generics in C# and Java use a sub-typing relation to constraint type parameters. Failing to encapsulate type parameters within generic interfaces and inability to encapsulate type constraints as part of an interface definition have been identified as deficiencies in the way this de- sign choice has been implemented in these languages. These deficiencies can lead to verbose and redundant code. In particular, they have been reported to affect the development of highly generic libraries.
    [Show full text]
  • The Java® Virtual Machine Specification Java SE 14 Edition
    The Java® Virtual Machine Specification Java SE 14 Edition Tim Lindholm Frank Yellin Gilad Bracha Alex Buckley Daniel Smith 2020-02-20 Specification: JSR-389 Java SE 14 Version: 14 Status: Final Release Release: March 2020 Copyright © 1997, 2020, Oracle America, Inc. All rights reserved. The Specification provided herein is provided to you only under the Limited License Grant included herein as Appendix A. Please see Appendix A, Limited License Grant. Table of Contents 1 Introduction 1 1.1 A Bit of History 1 1.2 The Java Virtual Machine 2 1.3 Organization of the Specification 3 1.4 Notation 4 1.5 Feedback 4 2 The Structure of the Java Virtual Machine 5 2.1 The class File Format 5 2.2 Data Types 6 2.3 Primitive Types and Values 6 2.3.1 Integral Types and Values 7 2.3.2 Floating-Point Types, Value Sets, and Values 8 2.3.3 The returnAddress Type and Values 10 2.3.4 The boolean Type 10 2.4 Reference Types and Values 11 2.5 Run-Time Data Areas 11 2.5.1 The pc Register 12 2.5.2 Java Virtual Machine Stacks 12 2.5.3 Heap 13 2.5.4 Method Area 13 2.5.5 Run-Time Constant Pool 14 2.5.6 Native Method Stacks 14 2.6 Frames 15 2.6.1 Local Variables 16 2.6.2 Operand Stacks 17 2.6.3 Dynamic Linking 18 2.6.4 Normal Method Invocation Completion 18 2.6.5 Abrupt Method Invocation Completion 18 2.7 Representation of Objects 19 2.8 Floating-Point Arithmetic 19 2.8.1 Java Virtual Machine Floating-Point Arithmetic and IEEE 754 19 2.8.2 Floating-Point Modes 20 2.8.3 Value Set Conversion 20 2.9 Special Methods 22 2.9.1 Instance Initialization Methods 22 2.9.2 Class
    [Show full text]
  • A Course Material on OBJECT ORIENTED PROGRAMMING by Mr. K.TAMILVANAN ASSISTANT PROFESSOR DEPARTMENT of COMPUTER SCIENCE and ENGI
    CS 6456 OBJECT ORIENTED PROGRAMMING A Course Material on OBJECT ORIENTED PROGRAMMING By Mr. K.TAMILVANAN ASSISTANT PROFESSOR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SASURIE COLLEGE OF ENGINEERING VIJAYAMANGALAM – 638 056 1 CS 6456 OBJECT ORIENTED PROGRAMMING QUALITY CERTIFICATE This is to certify that the e-course material Subject Code : CS 6456 Subject : Object Oriented Programming Class : II Year EEE Being prepared by me and it meets the knowledge requirement of the university curriculum. Signature of the Author Name: Designation: This is to certify that the course material being prepared by Mr. K. Tamilvanan is of adequate quality. He has referred more than five books among them minimum one is from aboard author. Signature of HD Name: Mr. S. Sriram SEAL 2 CS 6456 OBJECT ORIENTED PROGRAMMING S.NO CONTENTS PAGE NO Unit I – OVERVIEW 1.1 Why Object-Oriented Programming in C++ 9 1.1.1 History of C++ 9 1.1.2 Why C++? 9 1.2 Native Types 10 1.2.1 Implicit conversions (coercion) 10 1.2.2 Enumeration Types 10 1.3 Native C++ Statements 11 1.4 Functions and pointers 11 1.4.1 functions 11 1.4.2 Declarations 12 1.4.3 Parameters and arguments 13 1.4.4 Parameters 14 1.4.5 by pointer 14 1.5 Pointers 17 1.5.1 Pointer Arithmetic 18 1.6. Implementing Adts In The Base Language. 19 1.6.1Simple ADTs 19 1.6.2 Complex ADTs 19 3 CS 6456 OBJECT ORIENTED PROGRAMMING UNIT II -BASIC CHARACTERISTICS OF OOP 2.1 Data Hiding 21 2.2 Member Functions 22 2.2.1 Defining member functions 22 2.3 Object Creation And Destruction 23 2.3.1 Object Creation 23 2.3.2 Accessing
    [Show full text]
  • A First-Class Approach to Genericity
    RICE UNIVERSITY A First-Class Approach to Genericity by Eric Ethan Allen A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree Doctor of Philosophy Approved, Thesis Committee: Robert Cartwright, Chair Professor of Computer Science Keith Cooper Professor of Computer Science Michael Fagan Faculty Fellow, Computational and Applied Mathematics Houston, Texas April, 2003 A First-Class Approach to Genericity Eric Ethan Allen Abstract This thesis describes how to add first-class generic types|including mixins|to strongly-typed object-oriented languages with nominal subtyping such as Java and C#. A generic type system is “first-class” if generic types can appear in any context where conventional types can appear. In this context, a mixin is simply a generic class that extends one of its type parameters, e.g., a class C<T> that extends T. Although mixins of this form are widely used in C++ (via templates), they are clumsy and error-prone because C++ treats mixins as syntactic abbreviations (macros), forcing each mixin instantiation to be separately compiled and type-checked. The abstraction embodied in a mixin is never separately analyzed. Our formulation of mixins using first-class genericity accommodates sound local (class-by-class) type checking. A mixin can be fully type-checked given symbol ta- bles for each of the classes that it directly references|the same context in which Java performs incremental class compilation. To our knowledge, no previous formal analysis of first-class genericity in languages with nominal type systems has been con- ducted, which is surprising because nominal type systems have become predominant in mainstream object-oriented programming languages.
    [Show full text]
  • Understanding and Maintaining C++ Generic Libraries
    UNDERSTANDING AND MAINTAINING C++ GENERIC LIBRARIES A dissertation submitted to Kent State University in partial fulfillment of the requirements for the degree of Doctor of Philosophy by Andrew Sutton August, 2010 Dissertation written by Andrew Sutton B.S., Ohio University, USA, 1999 M.S., Kent State University, USA, 2005 Ph.D., Kent State University, USA, 2010 Approved by Dr. Jonathan Maletic Chair, Doctoral Dissertation Committee Dr. Gwenn Volkert Members, Doctoral Dissertation Committee Dr. Mikhail Nesterenko Dr. Michael Collard Dr. Donna Witter Accepted by Dr. Robert A. Walker Chair, Department of Computer Science Dr. Timothy Moerland Dean, College of Arts and Sciences ii TABLE OF CONTENTS TABLE OF CONTENTS ...............................................................................................III LIST OF FIGURES .....................................................................................................VIII LIST OF TABLES ..................................................................................................... XVII ACKNOWLEDGEMENTS ........................................................................................XIX CHAPTER 1 INTRODUCTION................................................................................... 21 1.1 Research Overview ................................................................................................. 23 1.2 Contributions........................................................................................................... 23 1.3 Broader Impacts .....................................................................................................
    [Show full text]
  • Introduction to Templates In
    An introduction to C++ template programming Hayo Thielecke University of Birmingham www.cs.bham.ac.uk/~hxt January 1, 2016 Abstract These notes present an introduction to template programming in C++. They are aimed particularly at readers who are reasonably familiar with functional languages, such as OCAML. We will concentrate on features and idioms that are well understood from functional languages: paramet- ric polymorphism and pattern-matching on function arguments. Contents 1 Introduction 2 2 Templates in the design of modern C++ 2 3 Templates and type parameters 3 4 Parametric polymorphism 5 5 Writing templates by abstracting over types 6 6 Classes and pointers as template arguments 7 7 Function pointers as template arguments 8 8 Member functions of template classes 10 9 Function objects and templates 10 10 Template std::function 12 11 Void pointers and polymorphism 12 12 Template template parameters 14 13 Type-safety and templates 14 14 Template typing versus derived class typing 16 15 Specialization as pattern-matching on template arguments 18 1 16 Dependent types via templates 20 17 Templates and inheritance 21 18 Higher-order templates (for λ-calculus fans) 22 1 Introduction These notes are intended for readers who are familiar with basic procedural programming in a C-like syntax (such as Java) as well as functional programming (e.g., in OCAML). They were written with the students on my second-year C/C++ course in mind, who have been taught both Java and OCAML in their first year. See http://www.cs.bham.ac.uk/~hxt/2014/c-plus-plus/index.shtml However, readers may safely skip everything about OCAML when they do not find the comparison helpful.
    [Show full text]