Turtle Tango (TT) Language Reference Manual

Similar documents
COLOGO A Graph Language Reference Manual

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

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

Flow Control. CSC215 Lecture

ARG! Language Reference Manual

Typescript on LLVM Language Reference Manual

YOLOP Language Reference Manual

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

Lexical Considerations

1 Lexical Considerations

The Warhol Language Reference Manual

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

L-System Fractal Generator: Language Reference Manual

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

Operators. Java operators are classified into three categories:

CA4003 Compiler Construction Assignment Language Definition

Language Reference Manual simplicity

Lexical Considerations

egrapher Language Reference Manual

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

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

GBL Language Reference Manual

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

d-file Language Reference Manual

RTL Reference 1. JVM. 2. Lexical Conventions

ASML Language Reference Manual

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

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Control Structures. CIS 118 Intro to LINUX

Introduction to C Programming

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

PieNum Language Reference Manual

GraphQuil Language Reference Manual COMS W4115

SMURF Language Reference Manual Serial MUsic Represented as Functions

Review of the C Programming Language for Principles of Operating Systems

Sprite an animation manipulation language Language Reference Manual

Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition

TED Language Reference Manual

EZ- ASCII: Language Reference Manual

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

Java+- Language Reference Manual

SFPL Reference Manual

XQ: An XML Query Language Language Reference Manual

c.def (pronounced SEE-def) Language Reference Manual

Senet. Language Reference Manual. 26 th October Lilia Nikolova Maxim Sigalov Dhruvkumar Motwani Srihari Sridhar Richard Muñoz

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

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

JME Language Reference Manual

DINO. Language Reference Manual. Author: Manu Jain

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

DaMPL. Language Reference Manual. Henrique Grando

8. Control statements

COMS W4115 Programming Languages & Translators GIRAPHE. Language Reference Manual

The SPL Programming Language Reference Manual

CHIL CSS HTML Integrated Language

Key Differences Between Python and Java

YAGL: Yet Another Graphing Language Language Reference Manual

SSOL Language Reference Manual

Decaf Language Reference Manual

Language Reference Manual

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

Functions. Lecture 6 COP 3014 Spring February 11, 2018

The PCAT Programming Language Reference Manual

Loops and Files. Chapter 04 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators

ECE 2400 Computer Systems Programming Fall 2018 Topic 1: Introduction to C

Review of the C Programming Language

Language Reference Manual

Full file at C How to Program, 6/e Multiple Choice Test Bank

Petros: A Multi-purpose Text File Manipulation Language

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

UNIT- 3 Introduction to C++

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

corgi Language Reference Manual COMS W4115

Lecture 3 Tao Wang 1

CHAD Language Reference Manual

GAWK Language Reference Manual

Chapter 2. Lexical Elements & Operators

easel LANGUAGE REFERENCE MANUAL

Hava Language Technical Reference

Java Loop Control. Programming languages provide various control structures that allow for more complicated execution paths.

WarmFusion Reference Manual

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

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

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Flow Language Reference Manual

5. Control Statements

Arrays. Comp Sci 1570 Introduction to C++ Array basics. arrays. Arrays as parameters to functions. Sorting arrays. Random stuff

Chapter 4. Flow of Control

String Computation Program

CMAT Language - Language Reference Manual COMS 4115

CS313D: ADVANCED PROGRAMMING LANGUAGE

MATLIP: MATLAB-Like Language for Image Processing

Expr Language Reference

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Photogram. Programmable Photoshop Language Language Reference Manual. ( ), Group Leader. (

Programming for Engineers Iteration

Transcription:

Turtle Tango (TT) Language Reference Manual Jeff Bender UNI: jrb2211 COMS W4115 6/29/2012

Contents 1. Introduction... 3 2. Lexical Conventions... 3 3. Scope... 3 4. Statements... 4 5. Expressions... 5 6. Variable Declarations... 6 7. Routine Declarations... 7 8. Built-in Routines... 7 9. Sample Program... 8 2

1. Introduction Tango (TT) is a line-drawing language that uses audio input to modulate graphical output. Turtle, the relative cursor, follows programming instructions and the modulations of a program's associated Tune to generate a PostScript representation of the specified dance in his world, the Disco. A TT program consists of variable and routine declarations composed in a text file with a.tt extention. Control initiates in the main~ filepath routine, which accepts as an argument the FilePath to.wav audio input. The output of compilation is a PostScript file with extension.ps depicting Turtle's dance in graphical form when viewed in a PostScript viewer. 2. Lexical Conventions 2.1. Tokens The five classes of tokens are identifiers, keywords, constants, operators, and separators. Whitespace is ignored; TT is free-format. 2.2. Comments The sequence '/*' begins a comment, which ends with the sequence '*/'. 2.3. Identifiers An identifier is a sequence of letters 'a'-'z' and 'A'-'Z' and digits '0'-'9'. Identifiers are case-sensitive, e.g. 'a' is not the same as 'A'. 2.4. Keywords The following keywords are reserved: int, routine, return, if, else, for, while, break, continue setdiscosize, setdiscocolor fd, bk, lt, rt, setposition, setorientation, setrate pu, pd, setcolor, setlinestyle, setlinewidth cue, pause, play, stop, setvolume 2.5. Constants Constants are integers consisting of a sequence of digits '0'-'9'. 3. Scope Variable and routines are statically scoped. 3

Variable declarations are allowed only within routines; all variables are considered local. Variables can only be accessed within the routine in which they were declared, and cannot be accessed before declared. Variable names must be unique within any single scope. Routines must have globally unique names and cannot be declared within other routines. A routine can be called before it is declared. 4. Statements Statements are executed in sequence unless otherwise noted. 4.1. Expression Expressions are described in detail in section 5. An expression statement consists of an expression followed by ';'. 4.2. Compound A compound statement allows several statements to be used in places in which one statement is expected, but more are needed. It consists of a '{' followed by zero or more statements and a closing '}'. 4.3. Conditional Conditional expressions take one of two forms: if (expression) statement if (expression) statement else statement The expression is first evaluated. Any resulting value other than zero is considered true, and the following statement is executed. If the expression evaluates to zero, in the first conditional form, the statement is skipped; in the second conditional form, the statement following the else is executed. else binds to the most recent if not associated with another else. 4.4. Loop 4.4.1. For The for statement has one form: for (expression1; expression2; expression3) statement expression1 specifies loop initialization. expression2 specifies a test, executed before each iteration, that evaluates to 0 to signal that the loop should exit. expression3 usually mutates a variable declared in expression1, so that expression2 eventually evaluates to 0. However, none of the three expressions is required. If expression2 is empty, the loop 4

iterates until the break statement is executed. 4.4.2. While The while statement has one form: while (expression) statement The expression is evaluated once before each of zero or more iterations. If the expression evaluates to zero the loop terminates; otherwise, the statement is executed, followed again by the expression. 4.5. Break The statement break; terminates the nearest enclosing for or while statement and passes control past the scope of that terminated statement. 4.6. Continue The statement continue; passes control to the end of the nearest enclosing for or while statement, skipping any in-between statements. The loop statement then continues normal iteration behavior. 4.7. Return A routine can terminate execution and return to its caller with the return statement, which has two forms: return; return expression; When the expression is omitted, zero is returned. 5. Expressions Expressions are left-associative unless otherwise specified. 5.1. Constants Integer constants are valid expressions. 5.2. Variables A variable is accessed by specifying its identifier, which is a valid expression. 5.3. Unary Operators 5

The unary operator '-' negates its right-associated expression. 5.4. Binary Operators The following binary operators are listed from highest to lowest precedence. 5.4.1. Multiplicative '*' indicates: multiplication. '/' indicates: division. 5.4.2. Additive '+' indicates: addition. '-' indicates: subtraction. 5.4.3. Relational and Equality The relational and equality operators return 1 when true and 0 when false. '<' indicates: less than. '>' indicates: greater than. '<=' indicates: less than or equal. '>=' indicates: greater than or equal. '==' indicates: equal. '!=' indicates: not equal. 5.5. Assignment '=' indicates: assignment. It is used to assign an integer variable or constant to a variable, and is right-associative. 5.6. Routine Calls A routine is called by specifying its identifier, followed by a '~' and a comma-separated list of arguments. The number of the arguments in the comma-separated list must match the routine declaration. 6. Variable Declarations A variable declaration has one form: int identifer; The keyword int prefixes a variable declaration, and a semi-colon follows the identifier. Variables contain the value zero when first declared. 6

7. Routine Declarations A routine declaration has the form: routine identifer ~ arg1, arg2,..., argn { variable declarations and statements } The keyword routine is followed by an identifier, a '~', and an optional comma-separated list of arguments. A mandatory opening brace then begins a series of zero or more variable declarations and statements, followed by a closing brace. All variables specified in the argument list are accessible as local variables; these variable names remain unique within the scope of the routine. The main routine requires one argument, filepath, which specifies the FilePath used to initiate this program's Tune. routine main ~ filepath { } 8. Built-in Routines 8.1. Disco setdiscosize~ x,y Adjusts the rectangular size of Turtle's dance floor to width x and height y. setdiscocolor~ c Sets the background color to c. 8.2. Turtle fd~ p, bk~ p Turtle moves forward or back positive p pixels while drawing if Pen is down. setposition~ x,y Turtle jumps to the position x,y without drawing. getorientation~ Retrieves Turtle's orientation in degrees. setorientation~ d Turtle turns d degrees relative to value returned by getorientation~. setrate~ r Sets Turtle's rate of movement to r. 8.3. Pen pu~, pd~ Sets the Pen Up, Down. 7

setcolor~ c Sets the Pen's Color to c. setlinestyle~ s Sets the Pen's LineStyle to s. setlinewidth~ w Sets the Pen's Width to w. 8.4. Tune cue~ filepath Prepares the.wav file at filepath for playback. pause~ Pauses the Tune in the Disco. play~ Resumes play of the Tune in the Disco. stop~ Closes and releases the Tune's.wav file. setvolume~ Sets the volume of the Tune to v. 9. Sample Program Example TT Program: /* SquareDance.tt */ routine square ~ x,y { int entryorientation = getorientation~; setorientation~ 0; setposition~ x,y; for(int i = 0; i < 4; i = i + 1;) { fd~ 50; rt~ 90; } setorientation~ entryorientation; } routine main ~ filepath { setdiscosize~ 400,400 setrate~ 10; cue~ filepath; play~; pd~; 8

int i = 1; while (i <= 5) { square~ i*80,i*80; i = i + 1; } } stop~; This example draws five squares positioned along the diagonal from top left to bottom right. Each square is modulated by the amplitude of the.wav file input specified by filepath. The image below represents a loose depiction of a possible output, driven by a specific audio input: 9