TabPro A Table Generation language Anureet Dhillon Lakshmi Nadig 19 December 2008 Rajat Dixit Contents 1 2 3 An Introduction to TabPro 6 1 1 Background 6 1 2 Goals of TabPro 6 Language Tutorial 6 2 1 Preparing Tabpro 6 2 2 Declaring Variables 7 2 3 Declaring and Calling Functions 7 2 4 Working with Columns and indexes 8 2 5 Generating Table 8 2 6 Simple function 8 2 7 More Examples 9 2 8 Exceptions and Errors 11 Reference Manual 14 3 1 Lexical Conventions 14 3 1 1 whitespace 15 3 1 2 Comments 15 3 1 3 Identifiers 15 3 1 4 Keywords 15 3 1 5 Constants 15 3 1 6 Declarations 15 3 1 7 Operators 15 3 1 8 Separators 16 3 1 9 Scope and Name Space 16 3 1 10 3 2 Types 16 3 3 Expressions 17 3 3 1 Primary Expressions 17 3 3 2 Indexed expression 17 3 3 3 Index range expression 18 3 3 4 Column Size expression 18 3 3 5 Function Calls 18 3 3 6 Expressions with Arithmetic Operators 18 3 3 7 Expressions with Relational Operators 18 3 3 8 Expressions with Assignment operators 19 3 3 9 Expression with Comma Operator 19 3 4 Statements 19 3 4 1 Declaration Statement 19 3 4 2 Block Statement 20 3 4 3 Conditional statements 20 3 4 4 return statement 20 3 4 5 Iteration Statements 20 3 4 6 Function Declaration 21 3 5 4 Built in functions and reserved keywords 16 Pre Processor Library Support 21 Project Plan 23 4 1 Team Responsibilities 23 4 2 Project Timeline 23 4 3 Software Development Environment 23 4 4 Project Log 26 5 Architectural Design 26 5 1 Architecture 26 Statement list 28 5 2 6 The Runtime Environment 28 Testing Plan 28 6 1 Goals 28 6 2 Phase 1 Scanner test 28 6 3 Phase 2 Parser Tests 29 6 4 Phase 3 Interpreter Tests 30 6 5 Phase 4 Regression Tests 32 7 Lessons Learned 33 8 Potential Enhancements 34 4 8 1 Short Term 34 8 2 Long Term 34 Appendix 34 4 1 Code Listing for the main interpreter 34 4 1 1 Scanner TablePro mll 34 4 1 2 Parser TablePro mly 36 4 1 3 AST TablePro mll 39 4 1 4 Interpreter ml 40 4 1 5 Printer ml 52 4 1 6 TableUtil ml 54 4 1 7 Tabpro ml 55 4 2 4 2 1 Code Listing for the Preprocessor 55 Scanner TableProPreProcess mly 55 4 2 2 Scanner TableProPreProcess mly 56 4 2 3 PreProcessor ml 56 4 2 4 TabProPreProcess ml 56 4 3 Other Test Code 57 4 4 Regression test script 57 4 5 Test Cases 58 4 6 Negative Test Cases 64 1 An Introduction to TabPro 1 1 Background We live on sharing information and we try to do it in as simple way as it can be One of the simplest ways of organizing the information is table Tables are used around the world in various places for example we need a table to organize a schedule to display scores in various sports like basketball bowling baseball etc A table helps anyone to interpret the information very easily since it becomes easier for us to visualize the information Tables can also be used to show the balance available in the bank account of a person etc As we know there is several numbers of programming languages we still feel a need of a language that enables user to create a tabular form of the data information Thus looking at the importance of the table we developed a programming language TabPro which allows us to create and manipulate data in a tabular form 1 2 Goals of TabPro The objective of this language is to give the user both a flexible and simple way of manipulating and generating data in the form of a table This language should aid the user in visualizing the data information The user should be able to define the organization of the data in a simple way and at the same time give them the power to manipulate the data before generating the final data in a table layout To begin with this language aims are generating tables in the form of comma separated files The comma separated file can be opened using a spread sheet editor A screen shot of the sample output is shown below Further extension would include generation of tables in html files TeamNames NewYorkKnicks TeamMiamiHeat ChicagoBulls DetroitPistons HoustonRockets Score1 20 30 25 33 42 Score2 40 34 22 44 28 Sum 60 64 47 77 70 Ranks None Third None First Second Bonus 60 69 47 97 80 Avg 30 32 23 5 38 5 35 2 Language Tutorial This tutorial is for those people who want to learn to work in TabPro Of course any knowledge of other programming languages or any general computer skill can be useful to better understand this tutorial although it is not essential 2 1 Preparing Tabpro OCaml has to be installed on the user s computer To make TabPro run the user has to download the TabPro executable To run a file test tab following command should be used being in the current directory ocamlrun TabPro test tab 2 2 Declaring Variables Declaring any variable in TabPro is simple There can be four basic types of variables as explained in LRM and that can be declared as follow To simply declare a variable of type numbernum i To initialize a variable of type number you have to give the decimal value in the form of 0 9 0 9 For examplei 1 0 To declare and initialize a variable of type string you have to give the value in double inverted commas For examplestr name name Rajat If you want to declare any column then you must also mention its data type along with its heading col c0 num MyHeading And if you want to give values for the declared column you can use assign operator along with the declaration and a pair of curly braces For examplecol c0 str MyHeading Sno 2 3 Declaring and Calling Functions To declare a function we use a keyword function followed by function name and an argument list with their data type and return type at the end Here is a small examplefunction multiply num i num j num num k k i j return k To call this function you need to declare a variable which is of the type similar to the return type of the function For example here in our example it is done as num t t multiply 3 3 The return type of the function in its definition should be the same as the type of the variable holding its value after calling it 2 4 Working with Columns and indexes Indexing on a column will return the element at that position For example if you would like to access retrieve the 3 rd element of a column mycol you use mycol 3 With …
View Full Document
Unlocking...