Unformatted text preview:

L System Fractal Generator Language Reference Manual Michael Eng Jervis Muindi Timothy Sun Contents 1 Program Definition 3 2 Lexical Conventions 3 2 1 Comments 3 2 2 Identifiers 3 2 3 Keywords 3 2 4 Constants and Literals 4 2 5 Operators 5 2 6 Punctuators 5 3 Meaning of Identifiers 6 3 1 Scoping 6 3 2 Object Types 6 4 Type Conversions 7 5 Expressions and Operators 7 5 1 Precedence and Associativity Rules 7 5 2 Primary Expressions 8 5 3 Function Calls 8 5 4 Arithmetic Operators 9 5 5 Relational Operators 10 5 6 Equality Operators 10 5 7 Boolean Operators 10 5 8 Assignment Operator 11 5 9 Constant Expressions 11 1 6 Declarations 11 6 1 Function Declarations 11 6 2 Variable Declarations 12 7 Statements 13 7 1 Expression Statement 13 7 2 If Statement 13 7 3 While Loops 13 7 4 Return Statements 13 8 System Functions 14 8 1 Turtle Functions 14 8 2 The print Function 15 2 1 Program Definition A program in our language is made up of statements which consist of function declarations function implementations and expression statements A program in our language is to be written in a single source file and combining different source files is currently not supported The structure of the program in the source file is as follows function declarations and implementations at top of source file main program code The main program code section should contain code that will be executed when the program is first run It is the the entry point of the program Unlike the function declaration the main program code does not have a function signature attached to it Instead any code that immediately follows the last defined function is assumed to be part of the main program code An example of the program structure def compute sqrt double x computes square root of x def draw hilbert int n code to draw the Hilbert curve hilbert 10 paint and draw a Hilbert curve on screen A program written in any other order causes a syntax error and will be reported as such by the compiler 2 2 1 Lexical Conventions Comments Comments are single line and prefaced by the symbol This is a comment hilbert 5 This is also a comment 2 2 Identifiers An identifier is a sequence of letters digits and underscores in which the first character is not a digit An identifier can consist of both upper and lower case letters The language is case sensitive and will differentiate identifiers with identical letters in different cases 2 3 Keywords The following terms are a list of reserved keywords in the language and cannot be used for any other purpose 3 alphabet boolean compute def double draw else false if int lambda return rules string true while 2 4 Constants and Literals Our language provides functionality for literals also known as constants of type int double string and boolean If any of these literals are assigned to a variable that variable s declared type must match up with the literal s type no automatic conversion will occur Integer constants An integer constant consists of a sequence of numbers without a decimal point An example int x 45 where 45 is the integer constant We do not provide support for octal or hexadecimal representation of integers String constants A string constant is enclosed in double quotation marks such as apples We provide support for the following escape sequences within string constants Character Name newline horizontal tab double quotation marks backslash Escape Sequence n t Examples of statements involving string constants include string s string n print column 1 t column 2 t column 3 t n String concatenation is supported in our language and is accomplished by using the operator Double precision floating point constants A double constant consists of a sequence of numbers and a decimal point At least one number must appear before the decimal point Examples of valid double constants include 4 0 345 0 0 1 0793211 3 141592654 But do not include sequences like 314 010 0 0 0 0 02 2 2 9 Boolean constants Boolean constants consist of the keywords true and false A valid example of their use is boolean b true if b true code 2 5 Operators An operator is a symbol that denotes a specific operation that is to be performed Below is a list of operators Symbol Explanation These must occur in pairs and can be separated by an expression in between Performs addition Performs subtraction or the unary minus operator Performs multiplication Performs division Performs the modulo operation Performs assignment Operators are discussed in greater detail later on in the manual 2 6 Punctuators A punctuator is a symbol that does not specify a specific operation to be performed It is primarily used in formatting code and it does have meaning A punctuator can be only one of the symbols below Symbol Explanation Statement terminator Used for grouping code e g in functions 5 3 Meaning of Identifiers 3 1 Scoping The region of a program in which a certain identifier is visible and thus accessible is called its scope The scoping in our language is global That is all identifiers declared are visible throughout the entire program Also identifiers become visible only after being declared and thus it is illegal to refer to identifiers that have not yet been declared For example int int int int int foo bar x sum y 5 10 25 foo bar x y 15 This is illegal You cannot access y Function Scope Similar to the scoping of identifiers functions also have global scope Additionally you cannot refer to a function that has not been seen yet For example def compute sqrt x def compute twice square root x double root sqrt x return add root root This is illegal Add must be declared before it s used def compute add x y 3 2 Object Types Our language supports the four fundamental types of objects integer floating point string boolean Character Types The only supported character type is the string type This can store a string of potentially unlimited length and does not have an upper bound limit The length is only limited by the amount of computing resources e g memory available Integer and Floating Point types 6 The only supported integer type is int which can store 32 bits worth of data and the only supported floating point type is double which can store 64 bits of data Both of these data types are signed Boolean Type This type is a truth value and can only store a bit of information Specifically it may only take a value of either true or false 4 Type Conversions Integer type variables also known as ints can be converted into double type variables with casting The reverse


View Full Document

Columbia COMS W4115 - L-System Fractal Generator: 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
Loading Unlocking...
Login

Join to view L-System Fractal Generator: 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 L-System Fractal Generator: Language Reference Manual 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?