Geo. A geometric solution language. Qi Wang, Yuechen Zhao Zichen Chao, Ziyi Luo

Similar documents
Geo. A geometric solution language. Project Report

Geo. A geometric solution language. Proposal

EZ-ASCII A Language for ASCII-Art Manipulation

tiler. A 2D turn-based gaming language Tester: Jacky Cheung Manager: Jason Lei System Architects: Jiayin Tang, Evan Ziebart Language Guru: Monica Ting

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Introduction to Programming Using Java (98-388)

The role of semantic analysis in a compiler

Matt Meisinger, Akshata Ramesh, Alex Dong, Kate Haas

Static Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1

Types and Static Type Checking (Introducing Micro-Haskell)

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

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

Lecture 09: Data Abstraction ++ Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree.

Project Compiler. CS031 TA Help Session November 28, 2011

Experiences in Building a Compiler for an Object-Oriented Language


egrapher Language Reference Manual

Types and Static Type Checking (Introducing Micro-Haskell)

Today. Assignments. Lecture Notes CPSC 326 (Spring 2019) Quiz 5. Exam 1 overview. Type checking basics. HW4 due. HW5 out, due in 2 Tuesdays

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

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

CS 6353 Compiler Construction Project Assignments

Lecture 16: Static Semantics Overview 1

Syntax Errors; Static Semantics

Your first C++ program

Flow Control. CSC215 Lecture

Language Proposal: tail

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Building Compilers with Phoenix

PHPoC vs PHP > Overview. Overview

Ruby: Introduction, Basics

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

COP 3402 Systems Software Top Down Parsing (Recursive Descent)

CMSC 330: Organization of Programming Languages

Introduction to Compilers Professor Jeremy Siek

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

PHPoC. PHPoC vs PHP. Version 1.1. Sollae Systems Co., Ttd. PHPoC Forum: Homepage:

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

Binary Search. CS 5010 Program Design Paradigms Bootcamp Lesson 8.2

Chapter 11 :: Functional Languages

Typescript on LLVM Language Reference Manual

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

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml

CSE 401 Midterm Exam Sample Solution 2/11/15

Outline CS4120/4121. Compilation in a Nutshell 1. Administration. Introduction to Compilers Andrew Myers. HW1 out later today due next Monday.

GBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN

COLOGO A Graph Language Reference Manual

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

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

CMSC 330: Organization of Programming Languages

Storage class in C. Automatic variables External variables Static variables Register variables Scopes and longevity of above types of variables.

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Decaf Language Reference

Motivation was to facilitate development of systems software, especially OS development.

Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres

Scala : an LLVM-targeted Scala compiler

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Semantic Analysis. Compiler Architecture


Language Reference Manual simplicity

Language Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

LESSON 6 FLOW OF CONTROL

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CS 6353 Compiler Construction Project Assignments

OCaml. ML Flow. Complex types: Lists. Complex types: Lists. The PL for the discerning hacker. All elements must have same type.

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

Funk Programming Language Reference Manual

Hardware versus software

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

CS 11 Ocaml track: lecture 6

Motivation was to facilitate development of systems software, especially OS development.

CS558 Programming Languages

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #49. Structures in C -1

HANDLING NONLOCAL REFERENCES

Lecture 04 FUNCTIONS AND ARRAYS

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

The New C Standard (Excerpted material)

Working with Z3 (10 points)

String Computation Program

Classes. C++ Object Oriented Programming Pei-yih Ting NTOU CS

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

UNIVERSITY OF COLUMBIA ADL++ Architecture Description Language. Alan Khara 5/14/2014

Chapter 2: Using Data

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Writing Evaluators MIF08. Laure Gonnord

Compilers Project 3: Semantic Analyzer

CSE 401 Midterm Exam Sample Solution 11/4/11

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

Semantic Processing. Semantic Errors. Semantics - Part 1. Semantics - Part 1

CMSC 330: Organization of Programming Languages. Operational Semantics

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont.

We do not teach programming

SCoLang - Language Reference Manual

Transcription:

Geo A geometric solution language Qi Wang, Yuechen Zhao Zichen Chao, Ziyi Luo

Motivation n Geometry is useful in mathematics, physics, computer science and so many fields. n But built-in support for graphs are not provided in most programming languages. n Geo is here to help! n A simple while powerful language for graph creation and manipulation. n The best part about Geo - dynamic graphs.

Language Tutorial No entry function A basic sample control structures: if-else, while, for keyword defines the scope function gcd(a:int, b:int): int: while(a!= b): if(a>b): a = a - b; else: b = b - a; return a; data types: int, float, bool, char, string

Language Tutorial n Geometric types: line, dot, polygon, circle dot(x:float, y:float); line(dot1:dot,dot2:dot); polygons: polygons(num_of_apex:int,apex[]:dot); circle: circle(center:dot,radius:float); n Presets: @panel panelname (essential) - defines a panel @ (essential) - the boundary of a specific panel Something special n Dynamics: model runset: runset(times_of_run:int, g1:geometric_shape, run_para_g1:char,...); function setrunstep(val:float,pos:char):void;

Language Tutorial! geometric types: dot, line, circle and polygons geometric control type - runset keyword run - dynamic analysis //panel presets! @panel panel_demo! //geometric shape declaration and initialization! line1 = line(2.0,3.0);! circle1 = circle([3,4], 5);! //runset declaration and initialization! line1.setrunstep(-0.5,'a');! circle1.setrunstep(0.1,'b');! rs = runset(50, line1, 'a', circle1, 'b');! //run statement description! run rs:! set = line1.intersect(circle1);! if (!set.empty())!! @! print_dot_list(set);! Advanced stuff print intersection points

Architecture

Architecture n Source code statistics File Lines Role scanner.mll 95 Breaks input stream into tokens parser.mly 135 Parses tokens into an AST ast.ml 50 Defines acceptable AST structure pyast.ml 38 Defines acceptable python AST structure compile_sc_py.ml 377 Translates geo AST to python AST compile_to_pycode.ml 78 Generates python code geo_sc_py.ml 13 Top level

Semantic Check n Semantic Check Ø Use StringMap to implement translation environments vars: keep information about variables funcs: keep information about functions func_opt: keep information about types of function parameters Ø Check for: undeclared variables and functions mismatched types wrong types function parameters not match undefined operations Geo syntax error..

Code Generation n Algorithm Example (demo_fb.g)

Code Generation n Algorithm Example @panel qsort function qsort(a:list, l:int, r:int):list: i = l;j = r; mid = (l+r)/2; while (i <= j): while (i <= j & a#[i] < a#[mid]): i = i+1; while (i <= j & a#[j]> a#[mid]): j = j-1; if (i <= j): k = a#[i];a#[i] = a#[j]; a#[j] = k; i = i+1;j = j-1; if (l < j): a = qsort(a, l, j); if (i < r): a = qsort(a, i, r); return(a); b = {3,7,8,32,1,4,7,9,2,5}; b = qsort(b, 0, len(b)-1); print(b); @

Code Generation n Graph Example

Testing n Test case statistics comprehensive check File Lines File Lines Role test-assignments.g 14 test-assignments.ref 6 All kinds of assignments test-circle.g 19 test-circle.ref 12 Geo type circle & obj funcs test-comparison.g 11 test-comparison.ref 6 Comparison & boolean opts test-dot.g 7 test-dot.ref 3 Geo type dot & obj funcs test-fib.g 18 test-fib.ref 9 Recursive function test-for.g 5 test-for.ref 10 For statements test-function.g 37 test-function.ref 1 Function & if & while test-gcd.g 15 test-gcd.ref 2 Function & if statement test-if.g 11 test-if.ref 1 If statements (nested) test-line.g 35 test-line.ref 15 Geo type line & obj funcs test-list.g 8 test-list.ref 4 List test-operations.g 20 test-operations.ref 9 Check +-*/^% opertations test-polygon.g 20 test-polygon.ref 11 Geo type polygon & obj funcs test-print.g 10 test-print.ref 8 Print function test-qsort.g 35 test-qsort.ref 1 List & recursive function test-while.g 7 test-while.ref 6 While statement

Testing n Test case statistics error check File Name Lines Role error-semantics1.g 2 Undeclared funtion error-semantics2.g 5 Funtion input para type error error-semantics3.g 6 Undefined argument error-semantics4.g 3 Char cannot plus int/float error-syntax1.g 1 Lose error-syntax2.g 1 Unrecognized token error-syntax3.g 1 Lose semicolon error-syntax4.g 2 Wrong function declaration error-syntax4.g 1 If statement error

Testing n Auto check geotestall.sh First: Check whether all files can be successfully compiled; Then: Compared the output with the ref answer.

Lessons Learned n Qi Wang: Start early on the project and make a plan ahead, if things are different from scheduled, discuss together and activate soon. n Yuechen Zhao: Effective communications are the key to success, do not waste too much time on arguing plans, but discussion is important. n Zichen Chao: Keep the whole picture in mind, modify the plan as the project progressed and learn Ocaml as early as possible! n Ziyi Luo: Comprehensive test cases are important and test early, you can never imagine how many problems you may encounter when testing.