D Language Compiler as a Library

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

Control Flow Analysis (Chapter 7) Mooly Sagiv (with Contributions by Hanne Riis Nielson)
CPSC Compiler Tutorial 9 Review of Compiler.
WPSM Programming Language A simple language that transform simple data structure into complex xML format Wai Y. Wong Peter Chen Seema Gupta Miqdad Mohammed.
ModelicaXML A Modelica XML representation with Applications Adrian Pop, Peter Fritzson Programming Environments Laboratory Linköping University.
ANTLR.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Speech Recognition ECE5526 Wilson Burgos. Outline Introduction Objective Existing Solutions Implementation Test and Result Conclusion.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Metadata Crosswalking/ Transforming and Federated Searching in Ex Libris Products Anthony Dellureficio Library Systems Manager The New School University.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Syntax: 10/18/2015IT 3271 Semantics: Describe the structures of programs Describe the meaning of programs Programming Languages (formal languages) -- How.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 8: Semantic Analysis and Symbol Tables.
© 2006 by «Author»; made available under the EPL v1.0 | Date | Other Information, if necessary Doug Schaefer My plans/dreams for C# in CDT.
P.R. James © P.Chalin et al.1 An Integrated Verification Environment for JML: Architecture and Early Results Patrice Chalin, Perry R. James, and George.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
Money What is it? Why do we have it? What do we do with it? How does it help our economy? Does it grow on trees? How does it differ from country to country?
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow.
Abstract Syntax Trees Compiler Baojian Hua
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
. n COMPILERS n n AND n n INTERPRETERS. -Compilers nA compiler is a program thatt reads a program written in one language - the source language- and translates.
A New Operating Tool for Coding in Lossless Image Compression Radu Rădescu University POLITEHNICA of Bucharest, Faculty of Electronics, Telecommunications.
Implementation of a Relational Database as an Aid to Automatic Target Recognition Christopher C. Frost Computer Science Mentor: Steven Vanstone.
القليل اللثغة مترجم ( リトル LISP コンパイラ ) دانيال تو مايو كين ( ダニエル · 火月の親 族 ) يوهان حزقيل (a 洋平ハスケル )
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
DGrid: A Library of Large-Scale Distributed Spatial Data Structures Pieter Hooimeijer,
Drupal Basics May 30, 2012 By Sean Fitzpatrick. Sean Fitzpatrick | Welcome We're going to talk about Drupal We're going to keep it pretty.
A Method for Improving Code Reuse System Prasanthi.S.
Introduction The concept of a web framework originates from the basic idea that every web application obtains its foundations from a similar set of guidelines.
Open Source Compiler Construction (for the JVM)
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Dictionary generation for the Experiments
Parsing & Context-Free Grammars
POW MND section.
Alexandru Razvan Caciulescu University POLITEHNICA of Bucharest
Java Anonymous inner class
Best Angular 2 interview questions and Answer that have been designed for Angular 2 programmers who are preparing online interviews on Angular 2 interviews question. Visit Website:
Microsoft Connect /17/ :55 PM
CMPE 152: Compiler Design ANTLR 4 and C++
MAKE SDTM EASIER START WITH CDASH !
SharePoint-Hosted Apps and JavaScript
Module 1: Getting Started
Divide and Conquer Methodology
Parsing & Context-Free Grammars Hal Perkins Autumn 2011
Introduction to Problem Solving
Generic Lightweight Druntime
A New Collections Framework for the Standard Library
Introduction:- Instructional technology has become an important part of teaching and learning within the classroom as well as working with fully online.
Near Real Time ETLs with Azure Serverless Architecture
Lesson 1: Fundamentals of Programming
Exploring the Power of EPDM Tasks - Working with and Developing Tasks in EPDM By: Marc Young XLM Solutions
BEST NODE JS & ANGULARJS ECOMMERCE WEBSITE
Computer Programming.
Tool Palettes/Catalogs on the Network
Implementation of a Functional Programming Language
Adapted from slides by Nicholas Shahan and Dan Grossman
The Organizational Impacts on Software Quality and Defect Estimation
Compiler Structures 0. Preliminaries
Knowledge is Power A Marketing Information System (MIS) determines what information managers need and then gathers, sorts, analyzes, stores, and distributes.
Nicholas Shahan Spring 2016
Chapter 8 - Design Strategies
Introduction to ANTLR Jin Tianxing
Graduate Thesis GRAD 699 (90)
Rethinking the Default Class Hierarchy: an Object’s Tale
Implementation of a Functional Programming Language
A Quest for a Statically Typed Embeddable Programming Language
Workshop 1++: A bit of C++
Object Oriented Design
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Chuck Bailey, VP of Software Implementation and Support
Presentation transcript:

D Language Compiler as a Library Razvan Nitu University POLITEHNICA of Bucharest razvan.nitu1305@gmail.com DConf 2017 Berlin, May 4-7, 2017

Introduction Language adoption depends on time-to-market metric Development tools greatly decrease ttm D lacks such tools Compiler library encourages tool development 2

“The compiler is open source. Hack and slash the code you need” ~ Anonymous Compiler Developer Chuck Norris 3

The Old Fashioned Way : Example Create tool to print all imports Options: → mess with the compiler code → implement a visitor 4

Solution 1: Compiler Surgery Search for the code Add a print there Inelegant Time consuming 5

6

Solution 2: Implement a Visitor

Solution 2: Implement a Visitor More elegant A lot of overriding Requires D AST organization knowledge 8

Bottom Line Time consuming In-depth knowledge No Flexibility 9

Compiler as a Library 10

Divide: Lexer Conquer: get all lexer files and build them as a library Scarce dependencies 11

Divide: Parser

Divide: Parser The Parser class depends on ~95% of the compiler front end code Tightly coupled How to break dependency? 13

Templated Parser 14

ASTDefault

Pros Parser Independence Non-disruptive change Library and compiler share the same code Flexibility 16

Cons 17

AST Families ASTNull → ASTFamily that does nothing → serves as guidance for defining new AST families ASTBase → AST family that stores parsing information 18

ASTNull Struct that defines a null AST No information is stored 19

ASTBase Struct that takes ASTNull further Defines all functions and variables present in ASTNull and stores parsing information 20

Visitor Interface Basic Visitor Strict Visitor Permissive Visitor Transitive Visitor 21

Strict Visitor 22

Permissive Visitor 23

Permissive Visitor: Import Example 24

Transitive Visitor 25

Parser Competing Library Libdparse Visitor interface Built from scratch Uses phobos 26

Divide: Semantics TODO 27

Current Status Lexer Library Parser Library → Transitive visitor – work in progress Semantics – next step 28

Conclusions Compiler library makes life easier for tool developers The parsing library offers flexible visitor interface We’re halfway there! Creating a semantic library is going to be awesome 29