Compile Time Abstraction Techniques for the D Programming Language Benjamin Shropshire.

Slides:



Advertisements
Similar presentations
The Problem Decomposition of programs in terms of classes and in terms of crosscutting concerns are both useful, but languages based on source files allow.
Advertisements

Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Case Study: A Recursive Descent Interpreter Implementation in C++ (Source Code Courtesy of Dr. Adam Drozdek) Payap University ICS220 - Data Structures.
1 Symbol Tables. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
IPS: Implementation of Protocol Stacks for Embedded Systems Yan Wang Halmstad University, Sweden The Second Internal EPC Workshop IPS, Halmstad University,
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Main Index Contents 11 Main Index Contents Week 10 – Recursive Algorithms.
SableCC SableCC is developed by professors and graduate students at McGill University and is open source (licensed under the Apache License, Version 2.0)‏
Transforming XML The XSLT Language Michael H. Kay.
Façade Pattern Jeff Schott CS590L Spring What is a façade? 1) The principal face or front of a building 2) A false, superficial, or artificial appearance.
Introducing Monads Lecture 3, Designing and Using Combinators John Hughes.
OOP in C. Cfront Original C++ compiler was just a pre- processor –generated C code which could be compiled with an existing C Compiler.
CS 310 – Fall 2006 Pacific University CS310 Parsing with Context Free Grammars Today’s reference: Compilers: Principles, Techniques, and Tools by: Aho,
Compiler Summary Mooly Sagiv html://
Professor Yihjia Tsai Tamkang University
CPSC Compiler Tutorial 3 Parser. Parsing The syntax of most programming languages can be specified by a Context-free Grammar (CGF) Parsing: Given.
CS 330 Programming Languages 12 / 09 / 2008 Instructor: Michael Eckmann.
Invitation to Computer Science 5th Edition
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
Getting Started with ANTLR Chapter 1. Domain Specific Languages DSLs are high-level languages designed for specific tasks DSLs include data formats, configuration.
INTRODUCTION TO COMPUTING CHAPTER NO. 06. Compilers and Language Translation Introduction The Compilation Process Phase 1 – Lexical Analysis Phase 2 –
1 Week 4 Questions / Concerns Comments about Lab1 What’s due: Lab1 check off this week (see schedule) Homework #3 due Wednesday (Define grammar for your.
1 Week 3 Questions / Concerns What’s due: Lab1b due Friday at midnight Lab1b check-off next week (schedule will be announced on Monday) Homework #2 due.
Computer Programming I An Introduction to the art and science of programming with C++
CSC 338: Compiler design and implementation
Perl 6 Update - PGE and Pugs Dr. Patrick R. Michaud April 26, 2005.
Parsing Expression Grammars Aaron Hoffer CSS 548 Autumn 2012.
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.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Review Joey Paquet,
Introduction to Parsing Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
CS 461 – Oct. 7 Applications of CFLs: Compiling Scanning vs. parsing Expression grammars –Associativity –Precedence Programming language (handout)
CS 280 Data Structures Professor John Peterson. How Does Parsing Work? You need to know where to start (“statement”) This grammar is constructed so that.
-Mandakinee Singh (11CS10026).  What is parsing? ◦ Discovering the derivation of a string: If one exists. ◦ Harder than generating strings.  Two major.
BizTalk Flat File Parsing Annotations. Flat File Parsing = LL(k) Parser The flat file parser is entirely grammar driven and is implemented as an LL(k)
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 6, 10/02/2003 Prof. Roy Levow.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Towards the better software metrics tool motivation and the first experiences Gordana Rakić Zoran Budimac.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow.
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
XML Access Control Koukis Dimitris Padeleris Pashalis.
INTRODUCTION TO COMPILERS(cond….) Prepared By: Mayank Varshney(04CS3019)
Top-down Parsing. 2 Parsing Techniques Top-down parsers (LL(1), recursive descent) Start at the root of the parse tree and grow toward leaves Pick a production.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
1 Week 5 Questions / Concerns What’s due: Lab2 part a due on Sunday Lab1 check-off by appointment Test#1 HW#5 next Thursday Coming up: Lab3 Posted. Discuss.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
LECTURE 7 Lex and Intro to Parsing. LEX Last lecture, we learned a little bit about how we can take our regular expressions (which specify our valid tokens)
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Normal forms.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Costas Busch - LSU1 Parsing. Costas Busch - LSU2 Compiler Program File v = 5; if (v>5) x = 12 + v; while (x !=3) { x = x - 3; v = 10; } Add v,v,5.
CSC 4181 Compiler Construction
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Introduction to C++ Course Version 1.0. Topics Course Outline Course Materials Syllabus Blackboard Forum Why C++
CS 44 – Jan. 28 Pumping lemma #2 Applications to compiling.
OOP - Object Oriented Programming
Introduction to Compiler Construction
G. Pullaiah College of Engineering and Technology
CMSC201 Computer Science I for Majors Lecture 18 – Recursion
Parsing with Context Free Grammars
4 (c) parsing.
Lecture 7: Introduction to Parsing (Syntax Analysis)
Parsing Costas Busch - LSU.
Implementation of a Functional Programming Language
CSCE 314: Programming Languages Dr. Dylan Shell
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Implementation of a Functional Programming Language
Presentation transcript:

Compile Time Abstraction Techniques for the D Programming Language Benjamin Shropshire

Abstraction What Why When How

Benjamin Shropshire3 What & Why What:Isolation of lower level complexity –Distillation of Intent –Removal of redundancy Why:Saving Time –Programming time –Maintenance time –User time

Benjamin Shropshire4 When to use Abstractions? Let the computer do what it is good at. Abstract where abstraction is a good fit

Benjamin Shropshire5 When to Not use Abstractions? If the abstraction doesn't fit, don't force it. Beware of premature optimizations. –Code speed –Coding speed –Test optimizations.

Compile time processing Nesting Templates Chained Recursion Nested Tuples

Benjamin Shropshire7 Nesting Templates Define two lists using two templates

Benjamin Shropshire8 Nesting Templates Multiple Tuples Useful naming

Benjamin Shropshire9 Chained Recursion Starting point Introduce alias to nested templates Nested templates that do something and then also use mixin

Benjamin Shropshire10 Chained Recursion Object Oriented style design Domain Specific Languages Closer to what is wanted

Benjamin Shropshire11 Nested Tuples Alias tuples inside of strut

Benjamin Shropshire12 Nested Tuples Use structs – Alias in templates don’t work – foreach works well on types

All Together Now Compile Time Parsing Compile Time Parser Generation

Benjamin Shropshire14 Compile Time Parsing Reading Data Building tree

Benjamin Shropshire15 Compile Time Parsing Attempt to parse D Attempt to parse B Build tuple of D’s Record unused input

Benjamin Shropshire16 Compile Time Parsing Found BCA Found BC failed on A, so parsing only B Found B failed on C, so parsing only B Failed on B, so failing

Benjamin Shropshire17 Compile Time Parsing

Benjamin Shropshire18 Compile Time Parser Generation Parse grammar Select production to instance Try each disjunction –Try each part Recurs to other productions Record checkpoints Backtrack through checkpoints on failure

Benjamin Shropshire19 Compile Time Parser Generation

Benjamin Shropshire20 Compile Time Abstraction Techniques for the D Programming Language Benjamin Shropshire Dr. Robert Hiromoto Michael Hewitt Dr. David Buehler Dr. Geoffrey Shropshire Eric Hewitt Special Thanks to: