24 HOURS LATER Phillip Build Stuff, Lithuania, 2014.

Slides:



Advertisements
Similar presentations
Chapter 2 Syntax A language that is simple to parse for the compiler is also simple to parse for the human programmer. N. Wirth.
Advertisements

Short circuit code for boolean expressions: Boolean expressions are typically used in the flow of control statements, such as if, while and for statements,
PSUCS322 HM 1 Languages and Compiler Design II IR Code Generation I Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Parasol.tamu.edu/courses/minipolaris. What is Polaris? Polaris is a source to source transforming compiler, originally developed at UIUC, intended to.
Trees. 2 Definition of a tree A tree is like a binary tree, except that a node may have any number of children Depending on the needs of the program,
G Programming Languages G Walter Williams.
Lecture 3. Review (What is Class and Object ?) The world of JAVA contains objects The world of JAVA.
Compiler Design Lexical Analysis Syntactical Analysis Semantic Analysis Optimization Code Generation.
Trees. Definition of a tree A tree is like a binary tree, except that a node may have any number of children –Depending on the needs of the program, the.
Programming Languages Structure
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Context-Free Grammars and Parsing 1.
Abstract Syntax Trees Lecture 14 Wed, Mar 3, 2004.
CIS Computer Programming Logic
9/18/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
COP4020 Programming Languages
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
CS1022 Computer Programming & Principles Lecture 1.2 A brief introduction to Python.
LANGUAGE TRANSLATORS: WEEK 24 TRANSLATION TO ‘INTERMEDIATE’ CODE (overview) Labs this week: Tutorial Exercises on Code Generation.
Language Translators - Lee McCluskey LANGUAGE TRANSLATORS: WEEK 21 LECTURE: Using JavaCup to create simple interpreters
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
A Little Language for Surveys: Constructing an Internal DSL in Ruby H. Conrad Cunningham Computer and Information Science University of Mississippi.
1 Homework / Exam Turn in HW3 today Exam 1 next class –Open Book / Open Notes –Recommended Use of Book / Notes in Exam: Avoids reliance on “rote memorization”
1 ML fun x -> e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors let f x = e variables These.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
EIW - ASP Introduction1 Active Server Pages VBScript.
5-1 5 Compilation  Overview  Compilation phases –syntactic analysis –contextual analysis –code generation  Abstract syntax trees  Case study: Fun language.
Parse & Syntax Trees Syntax & Semantic Errors Mini-Lecture.
PLT Final Project---COLOGO Lixing Dong, Zhou Ma, Chao Song, Siyuan Lu, Dongyang Jiang.
Programming Languages
CS 153: Concepts of Compiler Design October 21 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CSE 413 Languages & Implementation Hal Perkins Autumn 2012 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
What am I? while b != 0 if a > b a := a − b else b := b − a return a AST == Abstract Syntax Tree.
Java Review if Online Time For loop Quiz on Thursday.
Controlling Program Flow with Decision Structures.
CS412/413 Introduction to Compilers Radu Rugina Lecture 11: Symbol Tables 13 Feb 02.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
Phillip Trelford Blog:
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
Open Source Compiler Construction (for the JVM)
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2017.
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
CS1022 Computer Programming & Principles
PROGRAMMING LANGUAGES
Parsing & Context-Free Grammars
Introduction to Parsing (adapted from CS 164 at Berkeley)
PROGRAMMING LANGUAGES
ITM 352 Flow-Control: if and switch
More Selections BIS1523 – Lecture 9.
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018.
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
COP4020 Programming Languages
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Zach Tatlock Winter 2018.
Control Structures Programs utilize 4 basic control structures
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2016.
Chapter 3: Environment-Passing Interpreters
Chapter 1 Preliminaries.
Understand the interaction between computer hardware and software
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2017.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Programming Control Structures with JavaScript
A Tour of Language Implementation
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2019.
Presentation transcript:

24 HOURS LATER Phillip Build Stuff, Lithuania, 2014

THIS TALK IS *NOT* About how to write a compiler the hard way All theory For the faint of heart

THIS TALK *IS* ABOUT Abstract Syntax Trees Parsing Domain Specific Languages Interpreters Code Generation

LANGUAGE FAMILIES Lisp C ML BASIC

LANGUAGE DESIGN (CONSIDERED OPTIONAL) Adhoc PHP JavaScript Scala Copy&Delete Java J Go Copy&Add C# F# Haskell

TO THE TURTLES CODE Phillip Build Stuff, Lithuania, 2014

TURTLE LANGUAGE repeat 10 [right 36 repeat 5 [forward 54 right 72]]

TURTLE AST module AST type arg = int type command = | Forward of arg | Turn of arg | Repeat of arg * command list

TWO GIRLS (5 & 7YRS) + TURTLE

SMALL BASIC SAMPLE Sub Init gw = 598 gh = 428 GraphicsWindow.BackgroundColor = "DodgerBlue" GraphicsWindow.Width = gw GraphicsWindow.Height = gh color = "1=Orange;2=Cyan;3=Lime;" size = "1=20;2=16;3=12;" passed = 0 cd = "False" ' collision detected EndSub

SMALL BASIC AST /// Small Basic expression type expr = | Literal of value | Identifier of identifier | GetAt of location | Func of invoke | Neg of expr | Arithmetic of expr * arithmetic * expr | Comparison of expr * comparison * expr | Logical of expr * logical * expr /// Small Basic instruction type instruction = | Assign of assign | SetAt of location * expr | PropertySet of string * string * expr | Action of invoke | For of assign * expr * expr | EndFor | If of expr | ElseIf of expr | Else | EndIf | While of expr | EndWhile | Sub of identifier * string list | EndSub | Label of label | Goto of label

C# COMPILER IN 24 DAYS Oh Yes!Neil Danson (aka The Do) Now, I didn’t do any compiler theory in uni, I’ve never written a compiler before and I’ve only ever looked at Reflection Emit in anger. But despite these limitations I have a fairlycapable C# 0.5 compiler (in that it is a subset of the C# 1 compiler). Which means you can do it too – it took me less than a month.compiler theoryReflection Emit

RESOURCES Phillip Build Stuff, Lithuania, 2014

F# KOANS [ ] let SquareEvenNumbersWithPipelineOperator() = (* In F#, you can use the pipeline operator to get the benefit of the parens style with the readability of the statement style. *) let result = [0..5] |> List.filter isEven |> List.map square AssertEquality result __

TRYFSHARP.ORG

F# BOOKS

QUESTIONS? Twitter: Blog: Turtle: