COMS W4115: Programming Languages and Translators Language Project Proposal LOON: Language of Object Notation

Similar documents
LOON. Language Reference Manual THE LANGUAGE OF OBJECT NOTATION. Kyle Hughes, Jack Ricci, Chelci Houston-Borroughs, Niles Christensen, Habin Lee

Introduction to Programming Using Java (98-388)

Language Reference Manual simplicity

Full file at

Computer Components. Software{ User Programs. Operating System. Hardware

Programming. Syntax and Semantics

About Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python

LOON. Final Report THE LANGUAGE OF OBJECT NOTATION. Kyle Hughes, Jack Ricci, Chelci Houston-Borroughs, Niles Christensen, Habin Lee

2 rd class Department of Programming. OOP with Java Programming

Zheng-Liang Lu Java Programming 45 / 79

Kyle Rainville Littleton Coin Company

Script language: Python Data structures

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

The Lorax Programming Language

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018

Project Proposal. Programming Languages and Translators - Fall Team

COMS W4115. Programming Languages and Translators. ASML: White Paper

Full file at

ReJSON = { "activity": "new trick" } Itamar

JME Language Reference Manual

Assignment #3 CSCI 201 Spring % of course grade Title Weathermeister Back-End API Integration

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

String Computation Program

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

CSCE 314 Programming Languages. Type System

JSON as an XML Alternative. JSON is a light-weight alternative to XML for datainterchange

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Chapter 3: Operators, Expressions and Type Conversion

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

Data Collections. Welcome to the Fourth Dimension (and beyond) Martin Phillips Ladybridge Systems Ltd. International Spectrum Conference, 2014

Packaging Data for the Web

Lecture 03 Bits, Bytes and Data Types

Sprite an animation manipulation language Language Reference Manual

Variables, Constants, and Data Types

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Advanced Algorithms and Computational Models (module A)

Basics of Java: Expressions & Statements. Nathaniel Osgood CMPT 858 February 15, 2011

JavaScript Lecture 1

Scheme: Strings Scheme: I/O

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Princeton University Computer Science 217: Introduction to Programming Systems The C Programming Language Part 1

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

Simple Java Input/Output

CSI33 Data Structures

Python Input, output and variables

CSC Web Technologies, Spring Web Data Exchange Formats

Expressions and Variables

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

Exercise: Using Numbers

CIS 194: Homework 3. Due Wednesday, February 11, Interpreters. Meet SImPL

Control Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping

CS112 Lecture: Primitive Types, Operators, Strings

Python Input, output and variables. Lecture 22 COMPSCI111/111G SS 2016

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

CSC 1214: Object-Oriented Programming

Part III Appendices 165

Variables. Store information needed by the program

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

pybdg Documentation Release 1.0.dev2 Outernet Inc

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Functional Programming and Haskell

Pace University. Fundamental Concepts of CS121 1

Variables, Functions and String Formatting

printf( Please enter another number: ); scanf( %d, &num2);

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

CS Programming I: ArrayList

System Models & Simulation

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

String Objects: The string class library

YAGL: Yet Another Graph Language Proposal

COMS 469: Interactive Media II

Chapter 2: Basic Elements of C++

For the course, we will be using JCreator as the IDE (Integrated Development Environment).

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Java Overview An introduction to the Java Programming Language

LECTURE 16. Functional Programming

Introduction to Programming, Aug-Dec 2006

fedithead RichardJ.Mathar Generated by Doxygen Tue May :39:52

Assigns a number to 110,000 letters/glyphs U+0041 is an A U+0062 is an a. U+00A9 is a copyright symbol U+0F03 is an

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Programming Fundamentals and Python

Topic 2: Introduction to Programming

Language Reference Manual

DaMPL. Language Reference Manual. Henrique Grando

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CMSC 330: Organization of Programming Languages. OCaml Expressions and Functions

Open XML Requirements Specifications, a Xylia based application

1/29/2018. Starting a Program Executes its main Function. ECE 220: Computer Systems & Programming. The Function main Divides into Two Parts

Data Types, Literals, Operators

Introduction to Java

CSC Java Programming, Fall Java Data Types and Control Constructs

CSE 115. Introduction to Computer Science I

Higher Computing Science Software Design and Development - Programming Summary Notes

2/12/17. Goals of this Lecture. Historical context Princeton University Computer Science 217: Introduction to Programming Systems

I Wish I Knew How To. Begin Programming JSON with Xojo. By Eugene Dakin. November 2015 Edition (1.1)

Transcription:

COMS W4115: Programming Languages and Translators Language Project Proposal LOON: Language of Object Notation Kyle Hughes (keh2184), Niles Christensen (nnc2117), Chelci Houston-Burroughs (ceh2193), Jack Ricci (jr3663), Habin Lee (hl3020) September 26, 2017 1 Language Overview Over the past decade, JavaScript Object Notation (JSON) has arguably become the format of choice for transferring data between web applications and services. JSON has achieved its immense popularity in large part due to its flexibility and lightweight nature, but also due to its independence from any particular language. An application programmed in Java can send JSON data to a client running on a JavaScript engine, who can pass it along to a different application coded in C#, and so on and so forth. However, programs written in these languages generally utilize libraries to convert JSON data to native objects in order to manipulate the data. When the program outputs the modified JSON data, it must convert it back to JSON format from the created native objects. Our proposed language, LOON (Language of Object Notation), provides a simple and efficient way to construct and manipulate JSON data for such transfers. Developers will be able to import large data sets and craft them into JSON without needing to import standard libraries or perform tedious string conversions. In addition to generating JSON format from other data formats, programmers will be able to employ LOON to operate on JSON data while maintaining valid JSON format during all iterations of the programming cycle. In other words, LOON eliminates the JSON-to-Native Object-to-JSON conversion process. This feature provides valuable debugging capabilities to developers, who will be able to log their output at any given point of their code and see if the JSON is being formatted properly. LOON is simple by nature. It resembles C-based languages in its support for standard data types such as int, float, char, boolean, and string. Arrays in LOON are dynamic and can hold any type. The language introduces two new types: Pair and JSON. These two types will be at the heart of most every piece of LOON source code. Where LOON truly separates itself is in its provision of operators, such as the += operator for concatenation, for usage on values of the JSON and Pair types. This allows for more intuitive code to be written when working with JSON data. 1

2 Potential Applications LOON has the capacity to serve a variety of use cases, especially as JSON s popularity grows in comparison to rival data transportation formats. LOON s potential applications and programs are listed below, with a brief explanation of the problem s background and where LOON comes into play. 1. Format Control 2. Parsing Converting some form of dictionary/array/hash, etc. to JSON text. Converting JSON text to some form of dictionary/array/hash, etc. 3. Streamlined JSON data processing Easy and intuitive manipulation of data; no longer need JSON-to-Native Object-to- JSON conversion(s) that you would need in a Java, C etc. program. 4. Data Generation Generation of useful test data through LOON-based algorithms. 5. Ease of conversion between alternate data formats LOON algorithms to efficiently convert JSON objects to XML, etc. (and vice versa). 6. Ease of Data Comparison With LOON, developers can operate on valid JSON at all points in their programming cycle; keys & values between different JSON objects can be easily manipulated, operated on, and compared. 7. Ease of JSON data exchange (send, receive) to/from large data sets LOON enables developers to easily integrate external JSON data to existing data sets and, in the other direction, pull interesting JSON data from external data sets. 2

3 Technical Details 3.1 JSON This is the most important type in the language. The main advantage that this language has over other languages that have JSON libraries will be a very optimized representation of a JSON object. This will be stored in memory as an array containing a series of references to Pairs (per the description in the next subsection). This will allow efficient iteration over the Pairs in the JSON object, in addition to the ability to fetch, for example, the value corresponding to any key through a hash-map setup. Values can be accessed through the formal jsonn ame.keyn ame, as demonstrated below. Any variable of type JSON has a value that is always in valid JSON format. This is of great value to developers when debugging at different stages of their program. // I n i t i a l i z e an empty JSON o b j e c t JSON t e s t J s o n S t r i n g = { // I n i t i a l i z e a JSON o b j e c t with v a l u e s JSON i n i t i a l i z e d J s o n = { myintegervalue : 5 // Changes myintegervalue t o 6 i n i t i a l i z e d J s o n. myintegervalue ++ 3.2 Pair Pair represents a key-value pair. The key will always be a String (as described below). The value can be any type described in this language, except for a Pair. It might be possible to include syntactic sugar such that if an attempt is made to make the value of a Pair be another Pair, the second Pair could be wrapped in its own JSON object. This would cause reasonable behavior in most cases, as it will then be its own dictionary with only one value. Similarly, if two Pairs are concatenated, the resulting object should be a JSON object, as it is the most reasonable way to store two Pairs together. Since this language is strongly typed, carat notation can be used to indicate the type of the value in the Pair. // Creates a new Pair with an Int as the value Pair<Int> i n t P a i r = < Test value : 5> // Creates a new Pair Pair<String > s t r i n g P a i r = < S t r i n g value : Hello! > // Should throw an e r r o r Pair<Int> e r r o r P a i r = < Other s t r i n g value : Goodbye! > // Pair with value o f type JSON Pair<JSON> j s o n P a i r = < jsonvalue, {name : Jack, age : 20> / jsonpair s value i s now : { jsonvalue : { name : Jack, age : 20 3

/ // Combining P a i r s JSON combination = i n t P a i r + s t r i n g P a i r //The value o f combination i s now { Test value : 5, S t r i n g value : Hello! // Adding P a i r s to JSON o b j e c t s combination = combination + < New Value! : 7> 3.3 Int A 32-bit two s complement integer. Standard mathematical operations will be implemented. 3.4 Float A 32-bit float. Standard mathematical operations will be implemented. 3.5 Char An 8 bit integer. Can be used as an integer, but should typically be understood to represent an ASCII character. 3.6 Array An array of any of the other types of values, including Array itself. JSON format allows for type flexibility within a single array, so LOON offers developers the ability to craft both statically and dynamically typed arrays. Creating an array containing arbitrary types will be done with a special notation. // Create a new array Array<Int> myintarray = [ 5, 4, 3, 2, 1 ] // Append the i n t e g e r 4 to the end o f the array myintarray += 4 // Create a two dimensional array with c h a r a c t e r s Array<Array<Char>> twodimensionalchararray = [ [ a, b ], [ c, d ] ] Array<?> miscarray = [ 5, FOO, 3. 1 4 ] 3.7 String An array of Chars. 4

3.8 Functions LOON will support functions to allow developers to modularize the tasks that they perform on similar types data sets. Functions will be employed using the familiar C-style function syntax, though the flexible nature of JSON data may lead to a looser enforcement of that style. 4 Source Code Example Consider the following scenario: a developer has a set of structured data available in a CSV file called intro.csv. intro.csv contains information about a set of dog lovers, their ages, what kind of dog they own, and whether or not it is friendly. The contents of intro.csv appear below: Jack, 22, German Shepard, true Habin, 24, Golden Retriever, NULL Kyle, 1 5, NULL, NULL Niles, 23, T e r r i e r, f a l s e Chelci, NULL, Golden Doodle, true The developer knows maintaining the data in this format is wasteful due to all the null values, so he or she decides that it should be converted to JSON format and stored in a document called intro.json. The developer writes the following program using LOON to convert the data to JSON and create intro.json: intro.loon: S t r i n g readline ( S t r i n g f i l e S t r i n g ) Array breakline ( char delimchar, S t r i n g t e x t L i n e ) S t r i n g r e a d F i l e ( S t r i n g FileName ) i n t main ( ) { //Read CSV f i l e i n t o a s t r i n g S t r i n g mycsv = r e a d F i l e (mycsv. csv ) // Set up your custom f i e l d names Array fieldnames = [ name, age, dog ] Array doginfo = [ type, i s F r i e n d l y ] S t r i n g csvline = //Make a l i s t o f people who own dogs JSON r e s u l t = { ; r e s u l t += < dogpeople, [] > // For each l i n e, d e l i m i t by commas and manipulate data a c c o r d i n g l y while ( csvline = readline (mycsv) ) { JSON i n d i v i d u a l R e s u l t = { Array v a l u e s = breakline (,, csvline ) 5

// For each value, match i t to the a p p r o p r i a t e f i e l d name f o r ( i n t i = 0, k = 0 ; i < s i z e ( v a l u e s ) && k < s i z e ( fieldnames ), i ++, k++){ i f ( fieldnames [ k ] == dogs ){ // I n i t i a l i z e dogs f i e l d to be o f type JSON i n d i v i d u a l R e s u l t += <fieldnames [ k ], {> //Knowing that next two f i e l d s contain i n f o about // person s dog, we can i t e r a t e through and add them // to dog o b j e c t f o r ( i n t j = 0 ; j < s i z e ( doginfo ) && i < s i z e ( v a l u e s ) ; j ++, i ++){ i f ( v a l u e s [ i ] ) { i n d i v i d u a l R e s u l t. dogs += <doginfo [ j ], v a l u e s [ i ]> e l s e { // Concatenate to i n d i v i d u a l s o b j e c t i f ( v a l u e s [ i ] ) { i n d i v i d u a l R e s u l t += <fieldnames [ k ], v a l u e s [ i ]> //Add i n d i v i d u a l s data to dogpeople array r e s u l t. dogpeople += i n d i v i d u a l R e s u l t printjson ( r e s u l t, i n t r o.json) After running intro.loon on the intro.csv input file, the developer has created intro.json: { dogpeople : [ { name : Jack, age : 22, type : German Shepard, i s F r i e n d l y : true, { name : Habin, age : 25, type : Golden R e t r i e v e r, { name : Kyle, 6

age : 15,, { name : N i l e s, age : 23, type : T e r r i e r, i s F r i e n d l y : f a l s e, { name : C h e l c i, type : German Shepard, i s F r i e n d l y : true ] 7