DOC PREVIEW
Columbia COMS W4115 - La Mesa

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

La Mesa Language Reference Manual COMS 4115: Programming Languages and Translators Professor Stephen Edwards Michael Vitrano Matt Jesuele Charles Williamson Jared Pochtar1. Introduction La Mesa is a language intended to make working with tables in a programmatic setting easier. It is designed so that a programmer can use the full functionality of tables for retrieving, storing, and manipulating data without the additional hassle of working with SQL. Relational databases form the core of many information technology systems that need to store large amounts of data in an efficient and organized manner. While interacting with these databases with SQL is useful for efficiently accessing a particular subset of data, there are many tasks that are either cumbersome or impossible. For example, applying a function to each record in a relational table is a multistep process, requiring the programmer to write a query to retrieve the relevant data, parse it, apply the function and return the new data to the table. Further, there is no way to use SQL constructs to check input validity using regular expressions. La Mesa attempts to simplify the interaction with relational databases by making tables first-class objects. Users are able to load information from a database, manipulate it using the familiar imperative programming paradigm and optionally commit the data back to the database. 2. Basic syntax La Mesa is intended to be a counterpart to Java; i.e. it uses syntax derived heavily from Java and compiles into Java. However, it is distinct from Java, so that a La Mesa program and a Java program are not confused. To this end, La Mesa borrows conventions from other imperative languages, while keeping the flavor of imperative programming intact. A La Mesa program is a series of tokens; the type and nature of those tokens are described as follows. There are five types of tokens: comments, keywords, operators, identifiers, and literals. Spaces, newlines, tabs, and any other exotic nonprinting characters constitute whitespace; they are necessary to separate tokens but are not recognized in any other way by the compiler. 2.1 Comments The characters // introduce a comment; a newline terminates a comment. There are no multi-line comments. 2.2 Keywords The following are keywords in La Mesa and are not to be used otherwise. int null string float for if else while where table load func type import many one 2.3 Identifiers An identifier is anything beginning with a letter and continuing with any combination of letters, numbers, and underscores ‘_’. It can be used to describe variables, tables or functions.2.4 Literals Any sequence of digits is an integer literal. Any set of two sequences of digits separated by a decimal point ‘.’ is a floating-point literal. Any sequence of characters enclosed by double quotes is a string literal. A list delimited by parentheses is a row literal, eg (“Matt”,”654 W 123 St”,”New York”). 3. Primitive Datatypes Internally, values in La Mesa are treated as tables. In other words, while a user might type in the expression “x = 5 + 4,” the La Mesa program treats the expression as “the variable x describing a table is assigned to hold the table containing the singleton value 5 added to the table containing the singleton value 4. This is done to ensure that data will not be left in an indeterminate form during program execution, it is also done to satisfy type constraint consistency. All of this will be invisible to the programmer; nevertheless certain operators acquire different powers and/or necessitate different restrictions under this policy. This is similar to the way that a database query engine such as MySQL would treat data. Boolean Operators == (boolean equality test), >= (boolean greater than or equal to), <= (boolean less than or equal to), != (boolean not equals), && (boolean AND), || (boolean OR), ! (boolean NOT). La Mesa uses standard boolean operators that work on strings, integers, and floats, and evaluates to either 0 (false) or something other than 0 (true). There is no special boolean data type. Integer/Floating Point Operations + (addition), - (subtraction), * (multiplication), / (division), ** (exponentiation). The La Mesa compiler defines all of the usual operators that work on both integer and floating point numbers. One of the operands is restricted to be a singleton; otherwise the compiler will throw an error. String Operators ^ (string concatenation), ${expression} (string interpolation). The La Mesa compiler defines two operators on strings, concatenation and interpolation. For concatenation, “string1” ^ “string2” = “string1string2”. La Mesa defines interpolation as in the code fragment: string suffix = “4115” string dept_code = “COMS${suffix}” In the above fragment, the variable named ‘dept_code’ is assigned the string “COMS4115”. The value inside the curly braces must be a valid identifier, or else it will cause an error. Table Operators | (pipe operator) -- The pipe operator is used to iterate over table rows. La Mesa expects a valid table name to the left, and an existing or new identifier for the row to the right of the operator.For example, the following statment iterates over the table “Classes” to find the row with id “COMS4115”: classes | class { if class.class_id = “COMS4115” { //matched class_id } } << (push operator) -- The push operator adds a new row to a table. The new row must have the same width and column types as the table it is being added to; otherwise a compiler error results. >> (return operator) – takes now left hand side, adds the pushes the right hand side onto the table that will be returned. Eg: func many:user explicitReturn(many:user in) { u|in { n = copy(u) n.name = n.name ^ “is cool” ret << n } return ret } becomes func many:user implicitReturn(many:user in) { u|in { n = copy(u) n.name = n.name ^ “is cool” >> n } } :: (append operator) -- The append operator adds a new column to a table. The new column must have the same height as the table it is being added to; otherwise a compiler error results. : (table attribute datatype resolution operator) -- Because La Mesa is strongly typed, this operator is used to specify what type of data the program is to expect. If the type resolved by the operator is not the


View Full Document

Columbia COMS W4115 - La Mesa

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

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
Download La Mesa
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view La Mesa 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 La Mesa 2 2 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?