DINO. Language Reference Manual. Author: Manu Jain

Similar documents
MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Typescript on LLVM Language Reference Manual

The PCAT Programming Language Reference Manual

The SPL Programming Language Reference Manual

GAWK Language Reference Manual

CHIL CSS HTML Integrated Language

XQ: An XML Query Language Language Reference Manual

Programming Languages & Translators. XML Document Manipulation Language (XDML) Language Reference Manual

1 Lexical Considerations

Template Language and Syntax Reference

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

Lexical Considerations

DaMPL. Language Reference Manual. Henrique Grando

MELODY. Language Reference Manual. Music Programming Language

Language Reference Manual simplicity

d-file Language Reference Manual

RTL Reference 1. JVM. 2. Lexical Conventions

Sprite an animation manipulation language Language Reference Manual

GraphQuil Language Reference Manual COMS W4115

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

Lexical Considerations

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

SFPL Reference Manual

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

ASML Language Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

Windshield. Language Reference Manual. Columbia University COMS W4115 Programming Languages and Translators Spring Prof. Stephen A.

JME Language Reference Manual

MR Language Reference Manual. Siyang Dai (sd2694) Jinxiong Tan (jt2649) Zhi Zhang (zz2219) Zeyang Yu (zy2156) Shuai Yuan (sy2420)

The Warhol Language Reference Manual

Java+- Language Reference Manual

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

CLIP - A Crytographic Language with Irritating Parentheses

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

Language Reference Manual

COLOGO A Graph Language Reference Manual

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

Language Reference Manual

Program Fundamentals

Sketchpad Graphics Language Reference Manual. Zhongyu Wang, zw2259 Yichen Liu, yl2904 Yan Peng, yp2321

egrapher Language Reference Manual

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

COMS W4115 Programming Languages & Translators FALL2008. Reference Manual. VideO Processing Language (VOPL) Oct.19 th, 2008

PieNum Language Reference Manual

SIPL: Simple Image Processing Language

C Language, Token, Keywords, Constant, variable

GBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Language Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science

do fifty two: Language Reference Manual

Full file at

EZ- ASCII: Language Reference Manual

YAGL: Yet Another Graphing Language Language Reference Manual

COAL (COmplex Arithmetic Language) Reference Manual

IT 374 C# and Applications/ IT695 C# Data Structures

DES CARTES. COMS W4115 Fall 2011 Prof. Stephen Edwards Language Reference Manual

VLC : Language Reference Manual

corgi Language Reference Manual COMS W4115

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

SMURF Language Reference Manual Serial MUsic Represented as Functions

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation

Programming in C++ 4. The lexical basis of C++

SEAL Language Reference Manual

Petros: A Multi-purpose Text File Manipulation Language

Introduction to Programming Using Java (98-388)

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

The pixelman Language Reference Manual. Anthony Chan, Teresa Choe, Gabriel Kramer-Garcia, Brian Tsau

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.

Programming for Engineers Introduction to C

CS 541 Spring Programming Assignment 2 CSX Scanner

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

FotoScript: The Language Reference Manual

Lesson 06 Arrays. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Cellular Automata Language (CAL) Language Reference Manual

Full file at

Creating a C++ Program

M/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567)

String Computation Program

FRAC: Language Reference Manual

PlOtter. Language Reference Manual

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

EasyQL Language Reference Manual

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

Decaf Language Reference Manual

Introduction to Bioinformatics

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

2.2 Syntax Definition

L-System Fractal Generator: Language Reference Manual

IC Language Specification

Transcription:

DINO Language Reference Manual Author: Manu Jain

Table of Contents TABLE OF CONTENTS...2 1. INTRODUCTION...3 2. LEXICAL CONVENTIONS...3 2.1. TOKENS...3 2.2. COMMENTS...3 2.3. IDENTIFIERS...3 2.4. KEYWORDS...3 2.5. CONSTANTS...3 2.6. OPERATORS...3 3. MEANING OF IDENTIFIERS...4 3.1. BASIC TYPES...4 3.2. DERIVED TYPES...4 4. CONVERSIONS...4 5. EXPRESSIONS...4 5.1. PRIMARY EXPRESSIONS...4 5.2. DINOSAUR AND THING PROPERTIES...4 5.3. FUNCTIONS...5 5.4. MULTIPLICATIVE OPERATORS...5 5.5. ADDITIVE OPERATORS...5 5.6. RELATIONAL OPERATORS...5 5.7. EQUALITY OPERATORS...5 5.8. ASSIGNMENT EXPRESSION...5 6. DEFINITIONS...5 6.1. FUNCTION DEFINITION...5 6.2. PROPERTY DEFINITION...6 7. CREATION...6 7.1. CREATING DINOSAURS...6 7.2. CREATING THINGS...7 7.3. CREATING LISTS...7 8. STATEMENTS...7 8.1. SELECTION STATEMENT...7 8.2. ITERATION STATEMENT...7 9. EXTERNAL DECLARATIONS...7

1. Introduction This manual describes the DINO language, developed by the author as a project for the PLT class of spring 2010 at Columbia University taught by Prof. Stephen Edwards. This manual is modeled after the C language reference manual, which forms Appendix A of the The C Programming Language book by Kernighan and Ritchie. 2. Lexical Conventions Converting a program written in DINO to executable code is a multi-step process. The first step involves running the scanner over the program, which outputs a sequence of tokens. This is known as lexical transformation. 2.1. Tokens There are six types of tokens identifiers, keywords, constants and operators. Tokens are separated by white spaces (blanks, tabs, new-lines). Comments are ignored. 2.2. Comments A comment starts with the characters ** and ends with the characters **. Comments do not nest. 2.3. Identifiers An identifier is a sequence of letters and digits, starting with a letter. Case distinctions are ignored. 2.4. Keywords The following identifiers are reserved as keywords, and may not be used otherwise: dinosaur named do return eat hide thing listof times function sleep attack define int if property wakeup position create string then tostring drink height zap while else toint run length empty 2.5. Constants Integer and string constants (string literals) are supported. 2.6. Operators Supported operators are additive operators, multiplicative operators, relational operators, equality operators and assignment operator.

3. Meaning of Identifiers Identifiers can refer to many different things tags of types (basic types or derived types), properties of types, functions, and objects or variables of types. 3.1. Basic Types The fundamental types supported are empty, int, string, dinosaur and thing. The type empty represents an empty value. It is the type returned by functions that don t return any value. The type int represents signed integer values. The type string represents a sequence of characters. Strings are surrounded by double quotes. The type dinosaur represents a dinosaur. The dinosaur type supports properties that can be of any basic type or list of basic type. The type thing is used to represent anything that is not a dinosaur. The thing type supports properties that can be of any basic type or list of basic type. 3.2. Derived Types There may be an infinite class of derived types created from the basic types, by creating lists of basic types, and by creating functions that operate on basic types or list of basic types and return either a basic type or a list of basic type. 4. Conversions Conversion from one type to another is generally not supported, except for conversions between int and string. Conversion from type int to type string is supported through the tostring keyword. Conversion from type string to type int is supported through the toint keyword. When the value of the string doesn t evaluate to an integer, toint return value is indeterminate. 5. Expressions 5.1. Primary Expressions Primary expressions are identifiers and constants. 5.2. Dinosaur and Thing Properties A dinosaur or thing property is an expression that contains an object of dinosaur or thing type, followed by a dot, followed by a property member of that type. The dinosaur or thing property expression evaluates to one of the basic types (3.1) excluding the empty type, or a list of a basic type.

5.3. Functions A function is an expression that contains an identifier (that represents an object of dinosaur type), followed by an identifier that represents a function name, followed by zero or more arguments. The function expression evaluates to one of the basic types (3.1), or a list of one of the basic type. In other words, a function returns a basic type or a list of a basic type. Each argument of a function may be of any basic type, or a list of a basic type, except the empty type. A function automatically gets the dinosaur object whose identifier precedes the function-name as the first argument. 5.4. Multiplicative Operators Supported multiplicative operators are multiplication (*) and division (/). The operands of these operators must be of type int, and the result is also an int type. For division, the result is rounded off to the nearest integer. 5.5. Additive Operators Supported additive operators are plus (+) and minus (-). The operands of these operators must be of type int, and the result is also an int type. 5.6. Relational Operators Supported relational operators are < (less), > (greater), <= (less than or equal) and >= (greater than or equal). The operands of these operators must be of type int, and the result is either 0 if condition is false or 1 if condition is true. Relational operators are only allowed within the if conditional statement. 5.7. Equality Operators The = (equal to) and!= (not equal) operators are similar to relational operators, except that they also support comparison of string types in addition to int types. Equality operators are only allowed within the if conditional statement. 5.8. Assignment Expression The assignment operator (=) requires a variable or object of a basic type (except the empty type) as the left operand, with the right-hand side operand being an expression that evaluates to the same type. As a result of the assignment, the left hand side variable or object takes the value of the evaluated expression on the right-hand side. 6. Definitions 6.1. Function Definition Function definitions are used to define new functions.

An function definition consists of the keyword define, followed by the keyword function, followed by the function return-type, followed by an identifier (function name), followed by a list of arguments enclosed in brackets, followed by the function-body. The function return-type may be any basic type or a list of a basic type. The identifier in the function definition becomes the function-name of the newly defined function. Function-names must be unique. Each item in the list of arguments contains a type, which can be any basic type or a list of a basic type, followed by the name of that argument. The function automatically receives an argument named dino that is of type dinosaur. The function body contains zero or more expressions. If the function has a return-type which is not empty, the last statement in the function body is a return keyword followed by an expression that evaluates to the same type as the function return-type. 6.2. Property Definition Property definitions are used to define new properties on dinosaur or thing types. A property definition consists of the keyword define, followed by the keyword property, followed by the property type, followed by the keyword dinosaur or thing, followed by a dot, followed by an identifier (property name), followed by an expression that evaluates to the same type as the property type. The expression in the end is used to provide a default value to the property. The property type may be any basic type or a list of a basic type. 7. Creation New objects are instantiated by using the create keyword. 7.1. Creating Dinosaurs New dinosaur objects are created by using the create keyword, followed by the dinosaur keyword, followed by the named keyword, followed by an identifier. The identifier in the end denotes the object name and has to be unique.

7.2. Creating Things New thing objects are created by using the create keyword, followed by the thing keyword, followed by the named keyword, followed by an identifier. The identifier in the end denotes the object name and has to be unique. 7.3. Creating Lists Lists are created by using the create keyword, followed by the listof keyword, followed by one of the basic types. 8. Statements Statements are executed in sequence. They are of several types. 8.1. Selection Statement Selection statements may be of two different forms if (expression) statement if (expression) statement else statement In both forms of the if statement, if the expression evaluates to non-zero, the first substatement is executed. In the second form, the second sub-statement is executed if the expression evaluates to 0. Nesting ifs are not permitted. 8.2. Iteration Statement Iteration statements may be of two different forms do expression times statement while (expression) statement In the do statement, the sub-statement is executed as many times as the expression specifies. The expression evaluates to an integer. In the while statement, the sub-statement is executed repeatedly until the value of the expression evaluates to 0. Nesting do or while statements are not permitted. 9. External Declarations External declarations are not supported. All the source code for a DINO program must reside in a single unit of input.