TRAVEL ASSIST SCRIPTING LANGUAGE TASL Language Reference Manual Yogi Saxena ys2332 columbia edu 1 Introduction There are several websites that offer a web based interface to get quotes for air fare accommodation and other services such as rental cars The user is required to enter several pieces information related to his her travel plans such as dates destination and quantity This information is not stored and the user is required to re enter when he starts a new search Most of the users are looking for the cheapest fare for their travel This may require multiple searches with a combination of different dates and or destinations The TASL language attempts to provide a simple scripting language that would make it easier for the travelers to do their search The user input will be stored and used for periodic searches carried out at a pre defined interval If the results of the search match the user defined criteria then the results could be stored in a file and or the user could be alerted via email 2 2 1 Lexemes Identifiers Identifiers refer to or identify function names data objects class names etc They consist of a string of characters such as one or more uppercase or lower case alphabets and numbers The first character of an identifier must start with an alphabet Upper case and lower case letters are treated differently Keywords are reserved identifiers and cannot be re defined 2 2 Keywords The following reserved identifiers are used as keywords boolean else return for reserve 2 3 int function search float void while repeat modify if break email delete Numbers A number is a string of digits and a decimal point The types of Numbers supported in the language are Integer and float An Integer consists of a sequence of digits A floating point number consists of an integer part a decimal point and a fraction part Example 10 100 00 250 00 2 4 String String is a sequence of zero or more characters String literals are character strings surrounded by double quotes EWR String literals can include any valid character including white space characters and character escape sequences 2 5 Operators An operator is a token that specifies an operation on at least one operand and yields some result a value designator side effect or some combination Operands are expressions or constants The following are the operators used in TASL 3 Data Types The language defines the following data types Numeric Integer represents date and quantity float represents price True or False These represent Boolean values 4 4 1 Declarations General declaration All objects must be declared before use The general syntax of a declaration is as follows type specifier init declarator list opt init declarator list declarator init declarator list declarator The type specifiers can be int float or boolean 4 2 Arrays Arrays can be declared with square brackets The following is the syntax for declaring an array type specifier declarator constant expression list opt the type specifier can be int or float 5 5 1 Functions Function Types A function has the derived type function returning type The type can be a data type except array or a function type A function that does not return any value is referred to as a void function Functions can be defined in the following ways 1 A function definition can create a function designator define its parameters and their types defined the type of its return value and construct the body of the function 2 A function declaration specifies the properties of a function defined elsewhere 5 2 Function Definitions A function definition includes the body of the function Function definitions can appear in any order and can be referenced in one or more source files Function definitions cannot be nested A function definition has the following syntax function definition declaration specifiers opt declarator declaration list opt compound statement declaration specifiers The declaration specifiers type qualifier and type specifier can be listed in any order Type specifiers are int float and boolean Example main search EWR SFO 10182007 10242007 2 if Results email xyz columbia edu boolean function Results if FARE 0 desiredValue return true return false 5 3 Function Declarations For all functions if the function definition is located after the calling function the function must be declared before calling it 5 4 Function Parameters and Arguments The functions exchange information by means of parameters and arguments The term parameter refers to any declaration within the parentheses following the function name in a function declaration or definition The term argument refers to any expression within the parenthesis of a function call The following rules apply to the parameters and arguments 1 The number of arguments in a function call must be the same as the number of parameters declared by the function definition 2 The maximum number of arguments and corresponding parameters is 50 for a single function 3 Arguments are separated by commas The comma is not an operator in this context and the arguments can be evaluated by the compiler in any order 4 Arguments are passed by value 5 Modifying a parameter does not modify the corresponding argument passed by the function call 5 5 Function invocation and return Function Call A function call can be a single statement followed by a Return Statement The return statement is used to return from the function at the point the return statement is specified Return statements can return a value The return statement is terminated by a 5 6 Built In Functions 5 6 1 print Sends the output to the screen 5 6 2 load File I O functions 5 6 3 email xxx yyy edu Emails the results to the supplied email id 6 6 1 Expressions and Operators Primary Expressions Simple expressions are called primary expressions they denote values Primary expressions include previously declared identifiers constants string literals and parenthesized expressions Primary expressions have the following syntax primary expression identifier constant strings expression 6 1 1 Identifier An identifier is a primary expression provided it is declared as designating an object or a function 6 1 2 Constant A constant is a primary expression Its type depends on its form ie either boolean or int or float 6 1 3 Expression A parenthesized expression is a primary expression whose type and value are identical to those of the unadorned expression The presence of parentheses does not affect whether the expression is an lvalue 6 2 Postfix
View Full Document
Unlocking...