QUark Language Reference Manual

Similar documents
Language Reference Manual

Decaf Language Reference Manual

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Language Reference Manual simplicity

ARG! Language Reference Manual

1 Lexical Considerations

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

FRAC: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Lexical Considerations

egrapher Language Reference Manual

CSc Introduction to Computing

Lexical Considerations

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

VLC : Language Reference Manual

JME Language Reference Manual

Language Reference Manual

Getting started with Java

Typescript on LLVM Language Reference Manual

The MaSH Programming Language At the Statements Level

corgi Language Reference Manual COMS W4115

The Warhol Language Reference Manual

The pixelman Language Reference Manual. Anthony Chan, Teresa Choe, Gabriel Kramer-Garcia, Brian Tsau

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

MR Language Reference Manual. Siyang Dai (sd2694) Jinxiong Tan (jt2649) Zhi Zhang (zz2219) Zeyang Yu (zy2156) Shuai Yuan (sy2420)

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

GOLD Language Reference Manual

Java Basic Datatypees

GraphQuil Language Reference Manual COMS W4115

DaMPL. Language Reference Manual. Henrique Grando

Java Notes. 10th ICSE. Saravanan Ganesh

CS149: Elements of Computer Science. Fundamental C++ objects

Decaf Language Reference

Lecture 2 Tao Wang 1

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

3. Java - Language Constructs I

COMS W4115 Programming Languages & Translators GIRAPHE. Language Reference Manual

RTL Reference 1. JVM. 2. Lexical Conventions

SCoLang - Language Reference Manual

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

Language Reference Manual

Key Differences Between Python and Java

Chapter-8 DATA TYPES. Introduction. Variable:

MELODY. Language Reference Manual. Music Programming Language

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

Chapter 2: Introduction to C++

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

CS242 COMPUTER PROGRAMMING

Cellular Automata Language (CAL) Language Reference Manual

The SPL Programming Language Reference Manual

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

Introduction to Programming Using Java (98-388)

X Language Definition

L-System Fractal Generator: Language Reference Manual

Angela Z: A Language that facilitate the Matrix wise operations Language Reference Manual

Chapter 2 Getting Started with Python

B.V. Patel Institute of BMC & IT, UTU 2014

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

XQ: An XML Query Language Language Reference Manual

REVIEW. The C++ Programming Language. CS 151 Review #2

Number Systems, Scalar Types, and Input and Output

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

The PCAT Programming Language Reference Manual

DAVE. Language Reference Manual. Hyun Seung Hong. October 26, 2015

SSOL Language Reference Manual

Exercise: Using Numbers

The C++ Language. Arizona State University 1

Sprite an animation manipulation language Language Reference Manual

CSI33 Data Structures

IC Language Specification

10/9/2012. Computers are machines that process data. assignment in C# Primitive Data Types. Creating and Running Your First C# Program

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

Java+- Language Reference Manual

PieNum Language Reference Manual

d-file Language Reference Manual

Language Reference Manual

Programming Languages & Translators. XML Document Manipulation Language (XDML) Language Reference Manual

ASML Language Reference Manual

BASIC ELEMENTS OF A COMPUTER PROGRAM

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation

VARIABLES AND CONSTANTS

Variables, Constants, and Data Types

LECTURE 02 INTRODUCTION TO C++

Visual C# Instructor s Manual Table of Contents

4. Inputting data or messages to a function is called passing data to the function.

Sketchpad Graphics Language Reference Manual. Zhongyu Wang, zw2259 Yichen Liu, yl2904 Yan Peng, yp2321

easel LANGUAGE REFERENCE MANUAL

Datatypes, Variables, and Operations

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

Programming Lecture 3

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Template Language and Syntax Reference

GeoCode Language Reference Manual

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

BTE2313. Chapter 2: Introduction to C++ Programming

COMP519 Web Programming Lecture 11: JavaScript (Part 2) Handouts

Transcription:

QUark Language Reference Manual Daria Jung (djj2115), Jamis Johnson (jmj2180), Jim Fan (lf2422), Parthiban Loganathan (pl2487) Introduction This is the reference manual for QUark, a high level language for quantum computing. Lexical Conventions Comments Single line comments are denoted using a % while multi-line comments use %{ }%. Anything between the brackets will be commented out. Identifiers Identifiers are made up of alphabetical characters, numbers, underscores, and the first character cannot be a number. Identifiers are case sensitive. Keywords The following identifiers are reserved: qreg num complex frac bool str if i f elif else while return for in len bit and or null import mod Constants Number Constants Numbers are represented as either a sequence of digits or an integer part, a decimal point, a fraction part, and an optionally-signed exponent part which consists of an 'e' and a sequence of integers. If the decimal point and the exponent part are included then the fraction part is necessary. All numbers are considered as floats and will be compiled down to c++'s 8-byte, double precision type. String Constants Strings can one or more string constants enclosed in double or single quotes. Individual string constants can be alphabetical characters - both lower and uppper case - and special reserved escape sequences which are composed of a backslash \ followed by an alphabetical character. The following escape sequences are defined: \\ \n \' \" 1 of 7

\t \r Syntax Notation In this definition we will use bold to define literals and italics for categories. We use Backus- Naur Form to speficy the grammar. Types type-specifier ::= primitive-type array-type function-type null Identifiers have an associated type and the null type has no value. Primitive Types primitive-type ::= number-type fraction-type complex-type quantum-register-type booleantype string-type Number Type Numbers are denoted using the following the literal num All numbers will be compiled to c++ doubles. Fraction Type Fractions are given by the following literal frac and can be constructed using the syntax fraction-type ::= number-type $ number-type Complex Type complex is the literal used to denote the complex type and is composed of numbers having the form: complex-type ::= number +/- number i The real and imaginary parts can be accessed using re and im. Quantum Register Type There are two quantum register types: sparse and dense. The bracket literals, < and > are used to denote a quantum register and an optional apostrophe suffix, ' means the quantum register is treated as sparse. quantum-register-type ::== \ \' The first number is the size of the quantum register and the right number is the initial state. Boolean Type Booleans use the literal bool and can take the value of the literals true or false. String Type 2 of 7

We use the str literal to indicate a string type, and strings are sequential alphabetic characters or escape sequences wrapped in single or double quotes. List Type list-type :== [primitive-type] Function Type Functions accept zero or more variables and return a primitive type or list type. Expressions expression :== base-expression multiplicative-expression additive-expression relationalexpression equality-expression logical-expression assignment function-call Base Expression base-expression ::= identifier constant (expression) Multiplicative Expression multiplicative-expression ::= expression \ expression expression / expression expression mod expression* Additive Expression additive-expression ::= expression + expression expression - expression Relational Expression relational-expression :== expression > expression expression < expression expression <= expression expression >= expression Equality Expression equality-expression :== expression == expression expression!= expression Logical Expression logical-expression ::= expression and expression expression or expression Assignment assignment :== identifier type = expression Assignments are right associative and therefore can be chained together such as: alice = bob = "missing" Functions function-call ::= identifier( argument-list ) argument-list ::= argument-list, expression expression Expressions are evaluated before passed into the function and all parameters are pass byvalue. Declarations 3 of 7

declaration ::= primitive-declaration array-declaration function-declaration Primitive Type Declarations primitive-declaration ::= identifier primitive-type-specifier identifier primitive-type-specifier = expression Array Type Declarations array-declaration ::= identifier [primitive-type-specifier] identifier [primitive-type-specifier] = [index-list] index-list ::= index-list, expression expression Function Type Declarations function-call ::= def identifier return-type ( parameter-list ) statement-block parameter-list ::= param, parameter-list param ϵ Statements statement ::= expression declaration statement-block selection-statement iterationstatement return-statement Blocks statement-block ::= { statement-list } statement-list ::= statement, statement-list ϵ Selection Statements selection-statement ::= if ( expression ) statement else statement if ( expression ) statement You can nest if statements by writing else if ( expression ) statement. Selection Statements return-statement ::= return statement Iteration Statements iteration-statement ::= while ( expression ) statement for ( iterator ) statement iterator ::= identifier in array-expression identifier in range range ::= expression : expression : expression expression : expression Import Statements import-statement ::= import string-literal Grammar top-level ::= top-level-statement top-level top-level-statement top-level-statement ::= 4 of 7

datatype identifier ( param-list ) { statment-block } datatype identifier ( param-list ) declaration import-statement statement-block ::= statement statement-block ϵ import-statement ::= import string-literal datatype ::= number frac complex qreg bool string null expression ::= expression + expression expression - expression expression expression* expression / expression expression mod expression expression < expression expression <= expression expression > expression expression >= expression expression == expression expression!= expression expression or expression expression and expression (expression) constant {expression-list} identifier () identifier (expression-list) 5 of 7

expression-list ::= expression, expression-list expression declaration ::= identifier = expression datatype identifier datatype [identifier] statement ::= if (expression) statement else statement if (expression)statement while ( expression ) statement for ( iterator ) statement { statement-block } expression declaration return expression return iterator ::= identifier in range identifier in expression range ::= expression : expression : expression expression : expression param ::= datatype identifier datatype [identifier] param-list ::= param, param-list 6 of 7

param ϵ constant ::= number frac complex qreg bool string null 7 of 7