Table Generation Language TabPro Project LRM Rajat Dixit UNI rd2392 Anureet Dhillon UNI ad2660 LakshmiNadig UNI ln2206 Contents Table Generation Language TabPro 1 1 Lexical Conventions 3 1 1 whitespace 3 1 2 Comments 3 1 3 Identifiers 3 1 4 Keywords 3 1 5 Constants 4 1 6 Declarations 4 1 7 Operators 4 1 8 Separators 4 1 9 Scope and Name Space 4 1 10 Built in functions and reserved keywords 5 c row limit 5 d col limit 5 e col sort index 5 f row filter condition 5 2 Types 5 3 Expressions 6 3 1 Primary Expressions 6 3 2 Postfix Expressions 6 3 2 1 Indexed Interpretation 6 3 2 2 Function Calls 7 3 3 Expressions with Arithmetic Operators 7 3 4 Expressions with Relational Operators 7 3 5 Expressions with Logical And Operator 8 3 6 Expressions with Logical Or Operator 8 3 7 Expressions with Assignment operators 8 4 Statements 8 4 1 Normal Statement 9 4 2 Block Statement 9 4 3 Conditional statements 9 4 4 return statement 9 4 5 Iteration Statements 10 4 6 Function Declaration 10 5 Library Support 11 6 Grammar rules 11 7 Lexer Tokens 13 1 Lexical Conventions A TabPro program consists of a single translation unit stored in a file which is written using the ASCII character set The file is scanned in a forward manner starting from the logical start of the file to the end of file Various tokens present in the file could be Keywords Identifiers or variables Operators Constants Tokens are separated from each other by using a white space or a semicolon 1 1 whitespace TabPro ignores whitespace Whitespace characters consist of newlines carriage returns tabs and spaces It could be also combination of the above mentioned characters 1 2 Comments Single line comments are supported The character introduces a comment which terminates at the end of that line Comments do not nest and they do not occur within a string or character literals 1 3 Identifiers An identifier represents a variable name or a function name Identifier is a combination of alphabets and digits where the first character has to be an alphabet Special characters are not permitted The maximum length of an identifier could be ten Two identifiers are considered equal if the characters of their names match 1 4 Keywords Below is the list of identifiers that has been reserved by TabPro for the use of keywords num return col col heading col limit size string function if row heading col sort index currIndex loop row else row limit row filter condition generate table 1 5 Constants The kinds of constants used in TabPro are listed below a Number Constants These are declared using the keyword num datatype in Tabpro These include decimal integers which are a string of decimal digits from 0 9 and real numbers of the form 0 9 0 9 b String Constants A string constant is enclosed in double quotes The quotes are not considered as a part of the constant 1 6 Declarations TabPro declares an identifier when it is first encountered in a file A declaration is made by placing the datatype identifierName combination on the left side of the assignment operator For instance string tabstring greetings declares a string type identifier Here the data type could be num string row or col 1 7 Operators a All basic arithmetic operators are supported by TabPro These operators work on row and column level as well For instance num abc def 5 b Operators like are used to indicate the arithmetic operation followed by the assignment of the result of right side to the identifier of left side These assignment arithmetic operators can also be applied to range of rows and columns as in myrow 3 5 5 c operator is supported to access row or column s elements Therefore in order to access the 5th element of a row one might use myrow 5 d Relational operators like are supported for evaluating a relational expressions to a 1 or a 0 1 corresponds to its true counterpart and 0 corresponds to false e logical operators like are used to join relational expressions operator is the logical AND and operator represents the logical OR The precedence of these operators is same as their counterparts in C language 1 8 Separators While declaring a row or a column in order to separate two elements is used For instance row myrow 3 88 45 33 12 77 59 48 declares a row Also TabPro recognizes a semicolon as the line separator which is the end of an executable statement 1 9 Scope and Name Space Curly braces are required to mark the scope of a function or a looping construct TabPro supports a single name space i e only one identifier can have a particular name be it a function or an identifier 1 10 Built in functions and reserved keywords a col heading This is a reserved word a special list that holds the label values and types for the elements of the respective column This is a required field that the programmer has to set b row heading This is a reserved word a special list that holds the label values for the rows This is optional and need not be specified by the programmer c row limit This is a reserved word that defines the limit for the row i e the maximum number of rows that can be present in the table d col limit This is a reserved word that defines the limit for the column i e the maximum number of columns that can be present in the table e col sort index This is a reserved word a setting that can be used by the developer to set the column by which the rows need to be sorted f row filter condition This is a reserved word a setting that can be used by the developer to set the filtering condition by which the rows will be filtered before final display g generate table arg This built in function is used to print the table on the console or the file depending upon the argument arg can be 0 1 or 2 for standard console file and both respectively If arg is 1 or 2 the generated table would be stored in a file having the name as that of the table itself h size This keyword indicates the size of the row column in context For instance myrow size would refer to the size of myrow row i e the number of columns in myrow 2 Types TabPro supports the following data types a num Decimal integers are allowed which are a string of decimal digits from 0 9 or real numbers of the form 0 9 0 9 These can be preceded by a to indicate negative numbers The range of these numbers will be the same as a float type b string Strings are allowed which are a collection of ASCII characters c row This data type is used to declare a row of elements For Instance row myrow …
View Full Document
Unlocking...