Essentials of Programming Languages Language

Similar documents
Essentials of Programming Languages Language

6.034 Artificial Intelligence February 9, 2007 Recitation # 1. (b) Draw the tree structure corresponding to the following list.

How to Design Programs Languages

How to Design Programs Languages

Scheme Quick Reference

Scheme Quick Reference

Artificial Intelligence Programming

Introduction to Scheme

Scheme->C Index to the Report on the Algorithmic Language Scheme 15 March 1993

Programming Languages: Application and Interpretation

CSC 533: Programming Languages. Spring 2015

Programming Languages: Application and Interpretation

INTRODUCTION TO SCHEME

Programming Languages

SRFIs: Libraries. Version August 10, 2015

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7

A Brief Introduction to Scheme (II)

R6RS: Scheme. Version February 2, 2012

Scheme as implemented by Racket

Syntactic Sugar: Using the Metacircular Evaluator to Implement the Language You Want

CSE 341 Section Handout #6 Cheat Sheet

Documentation for LISP in BASIC

An Explicit-Continuation Metacircular Evaluator

Lecture 09: Data Abstraction ++ Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree.

CSc 520 Principles of Programming Languages

Project 2: Scheme Interpreter

Text File Databases. Contents. Appendices 7 Source code... 7 Test code Input file readers

Functional Programming. Pure Functional Languages

Typed Racket: Racket with Static Types

Pattern Matching for Scheme

Functional Programming. Pure Functional Languages

The Typed Racket Guide

;;; Determines if e is a primitive by looking it up in the primitive environment. ;;; Define indentation and output routines for the output for

CSc 520. Principles of Programming Languages 7: Scheme List Processing

Functional Programming Languages (FPL)

LECTURE 16. Functional Programming

The Typed Racket Reference

Organization of Programming Languages CS3200/5200N. Lecture 11

Racket: Modules, Contracts, Languages

Data Abstraction. An Abstraction for Inductive Data Types. Philip W. L. Fong.

Functional Programming. Pure Functional Programming

Parser Tools: lex and yacc-style Parsing

Syntax: Meta-Programming Helpers

Kent Dybvig, Will Clinger, Matthew Flatt, Mike Sperber, and Anton van Straaten

Things Your Mother Never Told You About AutoLISP Phil Kreiker - Looking Glass Microproducts

ALISP interpreter in Awk

Streams, Delayed Evaluation and a Normal Order Interpreter. CS 550 Programming Languages Jeremy Johnson

Vectors in Scheme. Data Structures in Scheme

An Introduction to Scheme

CSc 520 Principles of Programming Languages. Examining Lists. Constructing Lists... 7: Scheme List Processing

CS 342 Lecture 8 Data Abstraction By: Hridesh Rajan

University of Massachusetts Lowell

Project 2: Scheme Lexer and Parser

Notes on Higher Order Programming in Scheme. by Alexander Stepanov

Using Symbols in Expressions (1) evaluate sub-expressions... Number. ( ) machine code to add

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter

CS 314 Principles of Programming Languages

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax

Functional Programming

CS61A Midterm 2 Review (v1.1)

Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003

6.945 Adventures in Advanced Symbolic Programming

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson

6.001: Structure and Interpretation of Computer Programs

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples

Teach Yourself Scheme in Fixnum Days. c Dorai Sitaram, All Rights Reserved ds26 at gte.com

Scheme: Strings Scheme: I/O

Lecture 3: Expressions

Typed Scheme: Scheme with Static Types

CSSE 304 Assignment #13 (interpreter milestone #1) Updated for Fall, 2018

exp ::= (match exp clause :::) j clause :::) j * clause :::) j (match-let ([pat exp] :::) body) j (match-let* ([pat exp] :::) body) j (match-letrec ([

User-defined Functions. Conditional Expressions in Scheme

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

Fundamentals of Artificial Intelligence COMP221: Functional Programming in Scheme (and LISP)

Principles of Programming Languages COMP251: Functional Programming in Scheme (and LISP)

Parser Tools: lex and yacc-style Parsing

(Func&onal (Programming (in (Scheme)))) Jianguo Lu

Revised 5 Report on the Algorithmic Language Scheme

(scheme-1) has lambda but NOT define

Redex: Practical Semantics Engineering

More Scheme CS 331. Quiz. 4. What is the length of the list (()()()())? Which element does (car (cdr (x y z))) extract from the list?

MIT Scheme Reference Manual

11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT

Functional Programming Lecture 1: Introduction

Chapter 15 Functional Programming Languages

Announcements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters.

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 3. LISP: ZÁKLADNÍ FUNKCE, POUŽÍVÁNÍ REKURZE,

Administrivia. Simple data types

Syntax Color: Utilities

Data abstraction, revisited

From Syntactic Sugar to the Syntactic Meth Lab:

C311 Lab #3 Representation Independence: Representation Independent Interpreters

Readline: Terminal Interaction

Overview. CS301 Session 3. Problem set 1. Thinking recursively

Building a system for symbolic differentiation

CS 360 Programming Languages Interpreters

Lecture Notes on Lisp A Brief Introduction

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives

Readline: Terminal Interaction

Transcription:

Essentials of Programming Languages Language Version 6.90.0.26 April 20, 2018 The Essentials of Programming Languages language in DrRacket provides a subset of functions and syntactic forms of racket mostly the ones that correspond to r5rs forms. See below for a complete list. The language is intended for use with the textbook [EoPL]. #lang eopl package: eopl The following bindings are re-provided from racket: make-parameter * inexact? parameterize / zero? print-struct abs positive? unquote gcd negative? unquote-splicing lcm odd? quote exp even? quasiquote log quotient if sin remainder lambda cos modulo letrec tan floor define-syntax not ceiling delay eq? truncate let make-string round let* symbol->string numerator let-syntax string->symbol denominator letrec-syntax make-rectangular asin and exact->inexact acos or inexact->exact atan cond number->string sqrt case string->number expt do rationalize make-polar begin output-port? real-part set! current-input-port imag-part 1

#%module-begin current-output-port angle #%app current-error-port magnitude #%datum open-input-file input-port? #%top open-output-file read #%top-interaction close-input-port read-char #%require close-output-port peek-char #%provide with-output-to-file eof-object? #%expression flush-output char-ready? syntax-rules string-length write... string-ci<=? display cons string-ci>=? newline car string-append write-char cdr string-fill! load pair? string->list string? map list->string string for-each vector-length string-ref caar vector-fill! string-set! cadr vector->list string=? cdar list->vector substring cddr char-alphabetic? string-copy caaar char-numeric? string-ci=? caadr char-whitespace? string<? cadar char-upper-case? string>? caddr char-lower-case? string<=? cdaar char->integer string>=? cdadr integer->char string-ci<? cddar char-downcase string-ci>? cdddr call-with-output-file vector? caaaar call-with-input-file make-vector caaadr with-input-from-file vector caadar apply vector-ref caaddr symbol? vector-set! cadaar null? char? cadadr list? char=? caddar list char<? cadddr length char>? cdaaar append char<=? cdaadr reverse char>=? cdadar list-tail char-ci=? cdaddr list-ref char-ci<? cddaar memq char-ci>? cddadr memv char-ci<=? cdddar member char-ci>=? cddddr assq char-upcase = assv boolean? < assoc eqv? 2

> procedure? equal? <= number? force >= complex? call-with-values max real? values min rational? dynamic-wind + integer? eval - exact? (define-datatype id predicate-id (variant-id (field-id predicate-expr)...)...) Defines the datatype id and a function predicate-id that returns #t for instances of the datatype, and #f for any other value. Each variant-id is defined as a constructor function that creates an instance of the datatype; the constructor takes as many arguments as the variant s field-id s, and each argument is checked by applying the function produced by the variant s predicate-expr. In DrScheme v209 and older, when constructor-based printing was used, variant instances were printed with a make- prefix before the variant name. Thus, for compatibility, in addition to variant-id, make-variant-id is also defined for each variant-id (to the same constructor as variant-id). (cases datatype-id expr (variant-id (field-id...) result-expr...)...) (cases datatype-id expr (variant-id (field-id...) result-expr...)... (else result-expr...)) Branches on the datatype instance produced by expr, which must be an instance of the specified datatype-id that is defined with define-datatype. sllgen:make-string-scanner sllgen:make-string-parser sllgen:make-stream-parser sllgen:make-define-datatypes sllgen:show-define-datatypes sllgen:list-define-datatypes Defined in the textbook s Appendix B [EoPL]. However, the DrRacket versions are syntactic forms, instead of procedures, and the arguments must be either quoted literal tables or identifiers that are defined (at the top level) to quoted literal tables. 3

sllgen:make-rep-loop : procedure? Defined in the EoPL textbook s Appendix B [EoPL] (and still a function). eopl:error : procedure? As in the book. (eopl:printf form v...) Ñ void? form : string? v : any/c (eopl:pretty-print v [port]) Ñ void? v : any/c port : output-port? = (current-output-port) Same as scheme/base s printf and pretty-print. ((list-of pred...+) x) Ñ boolean? pred : (any/c. ->. any) x : any/c (always? x) Ñ boolean? x : any/c (maybe pred) Ñ boolean? pred : (any/c. ->. boolean?) As in the book [EoPL]. empty : empty? The empty list. (time expr) Evaluates expr, and prints timing information before returning the result. (collect-garbage) Ñ void? Performs a garbage collection (useful for repeatable timings). (trace id...) (untrace id...) For debugging: trace redefines each id at the top level (bound to a procedure) so that it prints arguments on entry and results on exit. The untrace form reverses the action of trace for the given ids. Tracing a function causes tail-calls in the original function to become non-tail calls. 4

(provide provide-spec...) Useful only with a module that uses eopl as a language: exports identifiers from the module. See provide from racket for more information. eopl:error-stop : (-> any/c) Defined only in the top-level namespace (i.e., not in a module); mutate this variable to install an exception-handling thunk. Typically, the handler thunk escapes through a continuation. The eopl library sets this variable to #f in the current namespace when it executes. (install-eopl-exception-handler) Ñ void? Sets an exception handler to one that checks eopl:error-stop. The eopl library calls this function when it executes. 5

Bibliography [EoPL] Essentials of Programming Languages, Third Edition, MIT Press, 2008. http://www.eopl3.com/ 6