DOC PREVIEW
Columbia COMS W4115 - Learning Language  Reference Manual

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1 Learning Language Reference Manual George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) 2 A. Introduction Learning Language is a programming language designed to be accessible to students prior to entering high school. Students at this age traditionally have no exposure to computer programming, despite the fact that many of them have the maturity and education to write procedural logic. For these students, existing programming languages can be overwhelming due to their abstract syntax and the difficulty of implementing I/O operations. To that end, the language is designed with the needs and abilities of 10‐14 year old children in mind. B. Lexical Conventions B1. Comments The character # introduces a comment, which termi nates at the next newline. Comments do not occur within string literals. B2. Identifiers An identifier is a sequence of letters and digits and underscores. The first character must be a letter. Upper and lower case letters are the same. Identifiers may have any length. B3. Keywords The following identifiers are reserved for use as keywords, and may not be used otherwise: string return called number function listof fraction until display repeat displayline end If ifnot times then end open read readline B4. Constants There are several kinds of constants. Constant: 3 Number‐constant String‐constant Fraction‐constant List‐constant Number‐Constant: A number constant consists of a sequence of digits which are taken to be an integer in decimal base. The sequence is optionally preceded by a ‘‐‘ for negative. String‐Constant: A string constant is a sequence of one or more characters enclosed in double quotes, as in “foobar”. In order to represent the “ character, newlines, and certain other characters, the following escape sequences may be used: Newline \n Backslash \\ Double quote \” Fraction‐Constant: A fraction constant is two numbers separated by ‘//’. List‐Constant: A list constant is a comma separated sequence of number, fraction or string constants surrounded by braces. Example: {1,2,7} C. Basic Types There are three basic types of variables in Learning Language. They are number, fraction and string. The number type is a 32bit integer. The fraction type is two 32 bit integers, a numerator and a denominator. The string type is a dynamically allocated array of characters. The programmer does not need to specify the size of the string. There is one derived type in Learning Language. It is the list. Lists can be of one of the three basic variable types or of another list. Memory is dynamically allocated to the list as needed. Users do not need to specify the size of their list. D. Conversions There is only one case where conversions occur in Learning Language. For binary arithmetic operators, if one operand is a number and the other a fraction, then the number is promoted to a fraction. 4 E. Expressions E.1 Primary Expressions Primary expressions are identifiers, constants, strings, or expressions in parenthesis. Primary‐expression: Identifier Constant String (expression) E.2 Postfix Operators The operators in postfix expressions group left to right. Postfix‐expression: Primary‐expression Postfix‐expression[expression] Postfix‐expression(argument‐expression‐list) Postfix‐expression() Argument‐expression‐list: Assignment‐expression Argument‐expression‐list, assignment‐expression List references: A postfix expression followed by an expression in square brackets is a postfix expression denoting a subscripted list reference. The first of the two expressions must have type “Listof T” where T is some type, and the other must have Number type. Function Calls: A function call is a postfix expression, called the function designator, followed by parentheses containing a possibly empty, comma‐separated list of assignment expressions which constitute the arguments to the functio n. In preparing for the call to a function, a copy is made of each argument; all argument‐passing is strictly by value. A function may change the values of its parameter objects, which are copies of the argument expressions, but these changes cannot affect the values of the arguments. Functions must be declared with explicit parameter types. E.3 Unary Operators Unary Minus Operator ‘’: 5 The operand of the unary minus operator must have type number or fraction. The result is the negative of the operand. Example: Number called b b <- -4 b <- -b Logical Negation Operator ‘not’: The operand must be of type number. The result is 1 if its operand is equal to 0, and 0 otherwise. The result is of type number. Example: Number called b b <- 1 a <- not b #a = 0 Logical Magnitude Operator ‘|operand|’: The operand must be of type string or list. The result is the length of the string or the number of elements in the list. The result is of type number. Example: Number called a string called b listof number called c b <- “the cat” a <- |b| #a = 7 c[5] <- 3 a <- |c| #a = 5 Absolute Value Operator ‘|operand|’: The operand must be of type number or fraction. The result is the length of the string. The result is of type number. Example: Number called a number called b a <- -8 b <- |a| #b = 86 E.4 Binary Arithmetic Operators Exponential Operator ‘^’: The exponential operator groups left to right. The exponent must be of type number and positive. The left operand may be a fraction or a number. Exponential‐expression: Exponential‐expression ^ unary‐expression Unary‐expression Example: Number called a number called b a <- 2 b <- 2 ^ a #b = 4 Multiplicative Operators ‘*’, ‘/’, ‘%’: The multiplicative operators group left to right. The operands for ‘*’ (multiplication) and ‘/’ (division) must be numbers or fractions. The operands for ‘%’ (remainder) must be numbers. If the second operand is zero for any of the above, the result is 0. If one operand is a fraction, the other is implicitly converted to a fraction Multiplicative‐expression: Multiplicative‐expression * Exponential‐expression Multiplicative‐expression / Exponential‐expression Multiplicative‐expression % Exponential‐expression Exponential‐expression Example: Number called a number called b a <- 2 * 4 / 3 #a = 2 b <- a % 2


View Full Document

Columbia COMS W4115 - Learning Language  Reference Manual

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download Learning Language  Reference Manual
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Learning Language  Reference Manual and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Learning Language  Reference Manual 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?