DINO A Friendly Dinosaur Language for Kids Final Project Report Author Manu Jain Table of Contents 1 Introduction 4 1 1 What is DINO 4 1 2 Purpose 4 1 3 Basic Idea 4 1 4 Evolution of Concepts 4 2 Language Tutorial 4 2 1 Basics 4 2 2 A Simple Program 4 2 3 A More Complex Program 5 3 Language Manual 6 3 1 Introduction 6 3 2 Syntax Notation 6 3 3 The Big Picture 6 3 4 Language Rules 6 3 5 Lexical Conventions 7 3 5 1 3 5 2 3 5 3 3 5 4 3 5 5 3 5 6 3 6 Tokens 7 Comments 7 Identifiers 7 Keywords 7 Constants 8 Operators 8 Meaning of Identifiers 8 3 6 1 3 6 2 Basic Types 8 Derived Types 8 3 7 Conversions 9 3 8 Expressions 9 3 8 1 3 8 2 3 8 3 3 8 4 3 8 5 3 8 6 3 8 7 3 8 8 3 8 9 3 8 10 3 9 3 9 1 3 9 2 3 9 3 3 10 Primary Expressions 9 Function Call 9 Dino Method Call 10 Dino Property Accessor 10 Multiplicative Operators 10 Additive Operators 10 Increment and Decrement Operators 10 Relational Operators 11 Equality Operators 11 Assignment Expression 11 Definitions 12 Function Definition 12 Dino Method Definition 12 Property Definition 13 Variable Creation 13 3 10 1 3 10 2 3 10 3 3 10 4 3 11 Statements 14 3 11 1 3 11 2 3 12 4 Creating Integers 13 Creating Strings 13 Creating Dinosaurs 13 Creating Lists 13 Selection Statement 14 Iteration Statement 14 External Declarations 15 Project Plan 15 4 1 Process 15 4 2 Programming Style 15 4 3 Show your project timeline 15 4 4 Roles and Responsibilities 16 4 5 Software Development Environment 16 5 Architectural Design 17 5 1 Major Components 17 5 2 Developers 17 6 Test Plan 17 6 1 Hello World Test with String Literal 17 6 2 Hello World Test with String Variable 17 6 3 Integer Operators Test 18 6 4 Simple Dino Test 19 6 5 Complex Dino Test 20 6 6 Do Times Test 21 7 Lessons Learned 21 7 1 Beneath the Covers 21 7 2 It s not Easy to Make it Simple 22 7 3 OCaml Really is Different 22 7 4 Be Less Ambitious 22 7 5 Develop All Parts Together Iteratively 22 7 6 Working Alone is Boring 23 8 Appendix Code Listing 23 8 1 Scanner mll 23 8 2 Parser mly 24 8 3 AST ml 27 8 4 Interpret ml 29 8 5 Dino ml 32 1 Introduction 1 1 What is DINO DINO is intended to be a fun easy to learn language for kids It is created by the author as a project for the PLT class of fall 2010 at Columbia University taught by Prof Stephen Edwards 1 2 Purpose The purpose behind creating DINO is to get kids interested in programming The language is aimed at getting young kids ages 8 interested in programming teaching them the basics of programming and making programming fun for them 1 3 Basic Idea The basic idea of the language is to give the young programmers simple types like integers and strings to play with along with just one other type called dino whose properties and behavior they can build as per their own liking and as they go along 1 4 Evolution of Concepts The concepts around how the language should be structured what its syntax should be and what features it should provide have undergone significant changes since when the project proposal was first given on to when the language reference manual was created and through the development phase The language started out looking more VB like and ended up looking more C like 2 Language Tutorial 2 1 Basics DINO programs look like simplified C programs albeit with a few differences DINO supports only four types bool integer string and dino It has support for built in expressions that operate on one or more of those types DINO provides the ability to create C like functions It also provides the ability to define methods which add behavior to the dino type and properties which add data to the dino type The main entry point of a DINO program is the main function 2 2 A Simple Program A simple DINO program can consist of just the main function An example is the hello world program below main print hello world Another way the hello world program may be written is by using a string variable main string hello hello hello world print hello 2 3 A More Complex Program A typical DINO program will have methods and properties for the dino type defined preceding the main function followed by a main method Properties defined on the dino type These add data members to each dino object with default values assigned at object creation time property int Height property string Name Methods defined on the dino type These add behavior to each dino object method bool IsSameHeight dino saurus if me Height dino Height return true else return false main dino trex trex Height 50 trex Name T Rex dino sauropod sauropod H eight 100 saurpod Name Sauropod print tostring trex IsSameHeight sauropod 3 Language Manual 3 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 3 2 Syntax Notation The syntax in this document is written in a variant of Extended Backus Norm Form EBNF using regular expression repetition operators 3 3 The Big Picture DINO programs are written in a single source file DINO source files have dino file extension The entry point of a DINO program is the main function Functions methods and properties are defined outside and preceding the main function Statements in DINO may appear inside any function or method definition and in main A DINO program has the following high level structure function definition method definition property definition main program main expression white space statement white space 3 4 Language Rules DINO uses static scoping It evaluates expressions and parameters from left to right i e it is left associative It follows applicative order argument evaluation and thus evaluates parameters before executing the body of the function It performs short circuit evaluation evaluating the body of statements and operands of operators if needed It follows normal operator precedence rules 3 5 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 3 5 1 Tokens There are five types of tokens comments identifiers keywords constants and operators Tokens are separated by white spaces blanks tabs new lines Comments are ignored token …
View Full Document
Unlocking...