FotoScript: The Language Reference Manual

Similar documents
The SPL Programming Language Reference Manual

The PCAT Programming Language Reference Manual

GOLD Language Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

JME Language Reference Manual

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

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

ARG! Language Reference Manual

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

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

Language Reference Manual simplicity

GraphQuil Language Reference Manual COMS W4115

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

Sprite an animation manipulation language Language Reference Manual

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

Typescript on LLVM Language Reference Manual

Lecture 3 Tao Wang 1

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

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

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

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

DINO. Language Reference Manual. Author: Manu Jain

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

C Language, Token, Keywords, Constant, variable

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

egrapher Language Reference Manual

EZ- ASCII: Language Reference Manual

d-file Language Reference Manual

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

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

The Logical Design of the Tokeniser

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

The Warhol Language Reference Manual

DaMPL. Language Reference Manual. Henrique Grando

Fundamental of Programming (C)

4. Inputting data or messages to a function is called passing data to the function.

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

Basics of Java Programming

Programming for Engineers Introduction to C

Full file at

UNIT- 3 Introduction to C++

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

SFPL Reference Manual

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING

TED Language Reference Manual

C Reference Manual. Dennis M. Ritchie Bell Telephone Laboratories Murray Hill, New Jersey 07974

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Full file at

Chapter 2. Lexical Elements & Operators

PYTHON- AN INNOVATION

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

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

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

XQ: An XML Query Language Language Reference Manual

Number System. Introduction. Decimal Numbers

do fifty two: Language Reference Manual

Chapter 17. Fundamental Concepts Expressed in JavaScript

GAWK Language Reference Manual

Objectives. In this chapter, you will:

RTL Reference 1. JVM. 2. Lexical Conventions

Chapter 12 Variables and Operators

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Binghamton University. CS-120 Summer Introduction to C. Text: Introduction to Computer Systems : Chapters 11, 12, 14, 13

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

Program Fundamentals

Language Reference Manual

Pace University. Fundamental Concepts of CS121 1

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

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR. VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Java Notes. 10th ICSE. Saravanan Ganesh

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

corgi Language Reference Manual COMS W4115

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

Programming in C++ 6. Floating point data types

Decaf Language Reference

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

CGS 3066: Spring 2015 JavaScript Reference

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

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

SMURF Language Reference Manual Serial MUsic Represented as Functions

CSC 467 Lecture 3: Regular Expressions

Introduction to C# Applications

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

Output: For each size provided as input, a figure of that size is to appear, followed by a blank line.

Chapter 2, Part I Introduction to C Programming

Course Outline Introduction to C-Programming

YOLOP Language Reference Manual

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

HAWK Language Reference Manual

The C++ Language. Arizona State University 1

BASIC ELEMENTS OF A COMPUTER PROGRAM

Petros: A Multi-purpose Text File Manipulation Language

Creating a C++ Program

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

Transcription:

FotoScript: The Language Reference Manual Matthew Raibert mjr2101@columbia.edu Norman Yung ny2009@columbia.edu James Kenneth Mooney jkm2017@columbia.edu Randall Q Li rql1@columbia.edu October 23, 2004 Here is a description of the various features of FotoScript and how to use them. This manual is based in part on The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie: 1 Tokens There are five classes of tokens in FotoScript: identifiers, keywords, literals, separators and numerical operators. Blanks, tabs, and comments are ignored except as they separate tokens. 1.1 Comments As an experiment, we have chosen to implement comments in an unorthodox way. All capital letters will be ignored by FotoScript with the exception of those within string literals. A user will be able to write comments in all caps anywhere in the code. Because this is unusual, and possibly really annoying, it is subject to change. 1.2 Identifiers Identifiers are made up letters and digits. The first character must be a letter; upper-case characters are ignored by fotoscript and cannot, therefore, be used in identifiers. 1

1.3 Keywords Fotoscript reserves several keywords: break data depth format else foreach foto fotos height if modified new open set while name width 1.4 Literals There are two kinds of literals: string literals and number literals. 1.4.1 string literals A string literal is a string of characters surrounded by double quotes. 1.4.2 number literals A number literal is a string of digits which represent a non-negative decimal integer. A user may use operators to create negative numbers as well as fractional numbers. 1.5 Separators Separators include curly braces and newline characters. The curly braces, { and }, designate blocks of code. The newline character separates expressions. 2 Types In Fotoscript there are three classes of objects: images, numbers and strings. Variables are implicitly typed when they are created. For this reason, when it is created, each variable must either be assigned the value of a literal or that of an already typed variable; it takes it s type from whence it s initial value is taken. 2.1 The Image Class Fotoscript has a native class of objects for storing all the data related to an image. This object has the following fields: Field Name Brief Description data the raw image data name the file name width the image width in pixels height the image height in pixels depth the image color depth in bits per pixel format the file format for the image to be saved to disk modified set to one if the image has been modified, zero otherwise 2

2.1.1 foto For convenience, FotoScript has a special pointer to an image object; it signifies the current image. It can be assigned to point to a certain image by the user and is assigned automatically by some funtions. It is used by foreach to allow the user to iterate through all the images. 2.1.2 fotos Because it may be useful to load and edit several images at once, there is a built-in array of image objects called fotos. When a new image object is loaded or created, it is appended to fotos. The images in fotos can then be accessed by foreach as described below. 2.2 The Number Class FotoScript does not distinguish between different classes of number. A number variable can contain a reasonable range of positive and negative floating point numbers. Only non-negative integer values can be represented by string literals, but there are some operators that cause number literals to behave as one might expect. Here is a table of number operators; those with highest precedence are higher; each precedence level groups left to right: Operators unary and binary. unary - and + * and / binary - and + ==,!=, <, <=, >, >= 2.2.1 The Unary - Operator The unary - operator negates the number that follows it. Because their functions are similar, it does not need to be strongly distinguished from the binary - operator; if there is only one sensible operand, the unary version is used; if there are two, the binary version is used; no sensible operands is an error. For example: the string -25 returns a negative number with magnitude twenty-five. 2.2.2 The Binary - Operator The binary - operator has the same function as the unary version except that after the number following the operator is negated, it is added to to the number preceeding the operator. For example: the string 10-25 returns a negative number with the magnitude fifteen. 3

2.2.3 The Unary. Operator The unary. operator divides the number that follows it by 2 l where l is the length of the shortest string representing the number in decimal form. Because their functions are similar, it does not need to be strongly distinguished from the binary. operator; if there is only one sensible operand, the unary version is used; if there are two, the binary version is used; no sensible operands is an error. For example: the string.25 returns a number with the value twenty-five hundreths. 2.2.4 The Binary. Operator The binary. operator has the same function as the unary version except that after the number following the operator is divided as described above, it is added to to the number preceeding the operator. For example: the string 10.25 returns a number with the value ten and twenty-five hundreths. 2.2.5 The Binary + Operator The binary + operator adds its two operands together. If there is only one sensible operand it will have no function; no sensible operands is an error. For example: the string 10+25 returns a number with the value thirty-five. 2.2.6 The Binary * Operator The binary * operator multiplies its two operands together. Fewer than two sensible operands is an error. For example: the string 10*25 returns a number with the value two-hundred-and-fifty. 2.2.7 The Binary / Operator The binary / operator divides the operand preceeding it by the operand that follows it. Fewer than two sensible operands is an error. For example: the string 10/25 returns a number with the value ten twenty-fifths. 2.2.8 The == Operator The == operator compares its two operands and returns zero if they are equal and one otherwise. Fewer than two sensible operands is an error. For example: the string 10==25 returns one. 2.2.9 the!= Operator The!= operator compares its two operands and returns one if they are equal and zero otherwise. Fewer than two sensible operands is an error. For example: the string 10!=25 returns zero. 4

2.2.10 The <Operator The <operator compares its two operands and returns zero if the latter is greater than the former and one otherwise. Fewer than two sensible operands is an error. For example: the string 10<25 returns zero. 2.2.11 The <= Operator The <= operator compares its two operands and returns zero if the latter is greater than or equal to the former and one otherwise. Fewer than two sensible operands is an error. For example: the string 10<=25 returns zero. 2.2.12 The >Operator The >operator compares its two operands and returns zero if the latter is less than the former and one otherwise. Fewer than two sensible operands is an error. For example: the string 10>25 returns one. 2.2.13 The >= Operator The >= operator compares its two operands and returns zero if the latter is less than or equal to the former and one otherwise. Fewer than two sensible operands is an error. For example: the string 10>=25 returns one. 3 Syntax Fotoscript syntax is very simple. Each line of code can be of one of two types: flow control and functions. 3.1 Function Syntax Function syntax is simple. The function name is written followed by some number of identifiers and it is terminated by a newline character. Some examples of functions are the following keywords: 3.1.1 set variable value sets variable to value; variables have three types: number, string and image; the literals for each type are non-ambiguous so the variable types are implicitly defined; value can either be a literal or a variable that has already been implicitly typed by setting it with a literal. 3.1.2 break break break out of the current control loop. 5

3.1.3 open open name opens a file or directory called name; if name is not a readable file or directory it is an error. 3.1.4 new new name creates a new image for editing called name; note that it does not write the image to disk unless save is called. 3.1.5 save save image writes image out to disk. 3.2 Flow Control Special keywords control the flow of the program. Here are descriptions of each of these keywords and their syntax. test can be omitted and will, by default, evaluate to true. 3.2.1 foreach foreach test {statements 1 } else {statements 2 } For each member of fotos, set foto to that member and perform statements 1 if test is true, statements 2 otherwise. 3.2.2 if if test {statements 1 } else {statements 2 } Perform statements 1 if test is true, statements 2 otherwise 3.2.3 while while test {statements} Repeat statements as long as test is true. 6