COMS W4115 Programming Languages and Translators Google Earth Script Language Language Reference Manual 10 18 2006 Carlos Icaza cai2101 columbia edu Darrell Tang tt2191 columbia edu Wei Chung Hsu wh2138 columbia edu 1 Language Conventions 1 1 Comments This is same as C C Java comment format We support 2 kinds of comments First one is multi lines comments that starts from and end at Second one is single line comment that start from until the end of this line 1 2 Identifiers Variable Function and Object names We use the identifiers to name variables functions and objects The identifier is a terminal in our grammar The following is our identifier rule letter A B Z a z digit 0 1 9 identifier letter letter digit 1 3 Numbers A number could be an integer or floating point It consists of digits and optional decimal point as well as digits In order to make our language simple we don t support exponent number now number digit digit 1 4 Strings A string is a sequence of characters enclosed by double quotes Basically the character here means the 256 types of character in ASCII code String character 1 5 NULL GECL has NULL value which is same as C C 1 6 Operators 1 7 Keywords IS Km struct If continue circle semicircle folder string m Coord Break NULL Hexagon perspective LOOKS AT While Nm Dist Return Boolean pentagon coord Print false mil dir float for rectangle overlay line int polygon square else true octagon lookat feet 1 8 Tokens to terminate or separate blocks 2 Types Objects In GECL we use type followed by object name to allocate an object and we process this object by this object name There are several type keywords GECL support which is list in chapter 1 7 These objects can be allocated like a standard type i e object myObject but require either the IS keyword or assignment operator to be defined 2 1 dist Defines a length that can be given in miles meters kilometers feet and nautical miles Instantiated and manipulated like an int 2 2 dir Defines a bearing in degrees Used to create a new coord object by moving from another 2 3 coord The basic geographic object from which all others are built Defines latitude longitude an elevation of a specific geographical point 2 6 point Creates a basic pop up point at a certain coord with title comments and URL for links or for loading photos 2 5 Struct This is the most important type in GECL used to construct a 3D object which could be a building a car or a polygon 2 6 Place This is the type to allocate a placemark object The placemark consists of several struct objects overlays and so on grouped so as to be related to perspective and folder objects 2 7 Overlay This is the type to allocate an overlay object so that we could specify the area we are going to look at with coordinates photo URL and rotation 2 8 Perspective This type specifies where and how the viewer will look at a struct coord overlay line and place object 2 9 Folder This type collects place struct point line and overlay objects under a single GoogleEarth folder for easy navigation between them The object names will become the titles for these objects inside the folder except for point which specifies its own title 2 10 Line This is the type to allocate a line object The reason to have this object is because we want to have some line mark in the Google Earth instead of using pure 3D objects 2 11 Array GECL has array data type which is pretty similar to C C Java array data type However in order to make our language easier to implement and use we only provide bounded array allocation such as int a 10 which will allocated in the compiling time 3 Expression Our GECL is a language that consists of several expressions The expression could be a list of integers a boolean number an identifier or a function call The following is our expression grammar expr int lit bool lit identifier identifier expr var post op expr bin op expr if expr then expr else expr end expr bool lit T F int lit digit bin op arith op rel op bool op arith op rel op bool op post op 4 Statements Semicolon is a statement terminator in GECL Basically statements are executed in sequence except specified control flow statements Statements can separate into several categories listed below statement expression statement compound statement interation statement conditional statement 4 1 Expression statement expression statement expressionopt An expression becomes a statement when it is followed by a semicolon 4 1 1 Assign statement assign statement primary expression assignment operator expression Asssign statements are the majority of expression statements Basically these statements assign the right side expression s final value to left side For example foo bar 10 4 2 Compound statement compound statement declaration listopt statement listopt declaration list declaration declaration list declaration statement list statement statement list A compound statement is composed of declarations and statements by put them into a pair of brackets The body of a function definition is a compound statement 4 3 Iteration statement iteration statement for expressionopt expressionopt expressionopt statement Iteration statements use to loop a statement or a block of statements several times In this for loop statement three expressions seperated by semicolon are all optional The first expression which must have arithmetic type is evaluated once and thus gives the initial state for the loop The second expression is evaluated before each iteration and if it becomes eqaul to zero false the iteration is terminate The third expression is evalated after each iteration and thus gives a new state for the loop 4 3 1 Break statement break statement break Break statement only happens inside an iteration statement It terminates inner most iteration statement and gives the control to the next statement that following the interation statement 4 3 2 Continue statement continue statement continue Continue statement only happens inside an iteration statement It causes control to pass through current loop the smallest enclosing and directly go to next loop s evaluation 4 4 Conditional statement conditional statement if expression statement if expression statement else statement The expression part of the conditional statement must have arithmetic type If its value compares unequal to zero then the first statement is excuted In the second form of conditional statement the second statement is executed if the expression s value is zero 5 Function Definition function
View Full Document
Unlocking...