CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation
|
|
- Piers Holland
- 5 years ago
- Views:
Transcription
1 CS /534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 NOTHING: A Language for Practice Implementation 1 Introduction NOTHING is a programming language designed for practice implementation. NOTHING is a simplified version of Pascal that supports simple integer and floating point calculations, as well as simple string manipulation. It is not intended as a replacement for Pascal, C, or other more full-fledged languages. By design, it has few of the features that programmers found useful in writing programs. It is intended to be simple enough to implement in a single semester, but powerful enough to illustrate many common programming language features. It avoids complications, like arbitrarily deep nesting of blocks, that have little instructional value while retaining some features, like recursion, that illuminate fundamental problems of compiler design. The various features included in the language were added specifically to illustrate some problem that arises in the design and implementation of a compiler. NOTHING supports three basic data types: integer, floating point, and character. Each of these types may be aggregated into one dimensional arrays. A number of operators are defined for each type. You can assume that the underlying hardware supports integers with 32-bit, two s-complement arithmetic and floating point with a 32-bit implementation of the IEEE floating point standard. Control structures in NOTHING are limited. It has an if statement, a while statement, a case statement, and a compound statement. Procedures may be recursive. They can only be declared within the main program, but not within other procedures. (NOTHING supports only one level of lexical nesting.) The notion of separate compilation is foreign to NOTHING. The entire program is presented to the compiler in a single compilation step. This simplifies some kinds of context-sensitive analysis that are otherwise difficult. For example, the compiler can check argument lists at call sites against the definitions of the corresponding formal parameters. The language has a trivial type system: the type of each expression can be determined at compile time. Some coercions from one type to another are permitted. Since there is no boolean data type, integers are used as logicals in a manner similar to C. 2 Lexical Properties of NOTHING 1. In NOTHING, blanks are significant. 2. NOTHING is case sensitive, that is, X and x are distinct names. Keywords are written in capital letters. All keywords are reserved the programmer cannot use a NOTHING keyword as the name Part of the documents are based on Prof. Keith Cooper, Prof. Ken Kennedy and Dr. Linda Torczon s teaching materials at Rice University. All rights reserved. 1
2 of a variable. The valid keywords are: AND, ARRAY,, CASE, CHARACTER, DO, ELSE,, FLOAT, FUNCTION, IF, INTEGER, MOD, NOT, OF, OR, PROCEDURE, PROGRAM, READ, RETURN, THEN, VAR, WHILE, WRITE. Thus, is a keyword, but end can be a variable name. 3. The following special characters have meaning in a Nothing program: { } < > = + - * [ ] ( )., ; : The grammar and section notes provide the details. 4. Comments are delimited by the characters { and }. A { begins a comment; it is valid in no other context. A } ends a comment; it cannot appear inside a comment. Comments cannot be nested. { can appear inside a comment; the first } closes the comment. Comments may appear before or after any other token. 5. Identifiers are written with upper and lowercase letters and are defined as follows: Letter a b c... z A B... Z Digit Identifier Letter ( Letter Digit ) The implementor may restrict the length of identifiers to any number larger than 31 characters. 6. Constants are defined as follows: Constant IntNum FloatNum CharConst Positive Sign + - ɛ IntNum Positive Digit 0 FloatNum IntNum. IntNum. IntNum IntNum. E Sign IntNum IntNum. IntNum E Sign IntNum CharConst Letter StringConstant Letter Multi-letter string constants are acceptable in WRITE statements. 7. Operators: RelOp < <= >= > = <> Note: <> denotes inequality. AddOp + - MulOp * MOD LogOp OR AND 3 NOTHING Syntax The syntax of NOTHING is described using a modernized BNF grammar. (See Section 3.2 of Cooper & Torczon, or the lecture notes.) Following the BNF are implementation notes for the various parts of the grammar. The grammar, as stated, defines the language. It may require some massaging before implementation with any particular parser generator system. For example, you may need to remove left-recursions if you use ANTLR or other top-down parser generators. The following grammar describes the context-free syntax of NOTHING: 2
3 Program PROGRAM Identif ier; CaseStmt CASE Expr OF Cases DeclSet Cases CaseElt SubProgs Cases ; CaseElt Block CaseElt CaseLabels : Stmt DeclSet VAR Decls ɛ ɛ CaseLabels Constant Decls Idents: Type ; CaseLabels, Constant Decls Idents : Type ; IfStmt IF Expr THEN Stmt ELSE Stmt Idents Identif ier IF Expr THEN Stmt Idents, Identifier IOStmt READ ( V ariable ) Type StdType WRITE ( Expr ) ArrayType WRITE ( StringConstant ) StdT ype INTEGER Invocation Identif ier () FLOAT Identif ier ( Exprs ) CHARACTER Block Stmts ArrayType ARRAY [ Dim ] OF StdType Stmts Stmt Dim IntNum.. IntNum Stmts ; Stmt CharConst.. CharConst Return RETURN Expr SubProgs SubProgs SubProg ; RETURN SubProg Head DeclSet Block Exprs Expr Head FUNCTION Identif ier Exprs, Expr Args : StdType Expr Expr Op Expr PROCEDURE Identif ier NOT Expr Args ; Factor Args ( Params ) Op LogOp Params Idents : Type RelOp Params ; Idents : Type AddOp Stmt Assignment MulOp IfStmt Factor V ariable WhileStmt Constant CaseStmt ( Expr ) Invocation Function IOStmt V ariable Identif ier Block Identifier [ Expr ] Return Function Identif ier () Assignment V ariable := Expr Identif ier ( Exprs ) WhileStmt WHILE Expr DO Stmt 4 NOTHING Specification Notes 4.1 Declarations NOTHING supports three standard data types: INTEGER, FLOAT and CHARACTER. Integers and floats occupy in a single machine word, while a character is stored in a single byte. These standard types may be composed into the structured ARRAY type. An identifier may represent one of four types of objects: 1. an integer variable or array 2. a floating point variable or array 3. a character variable or array 4. a procedure or function name 3
4 Identifiers are declared to be variables or arrays by a VAR declaration. They are declared to be procedure names by PROCEDURE and FUNCTION declarations. Only singly dimensioned arrays are permitted in NOTH- ING, but arbitrary upper and lower index bounds are permitted. Arrays may be indexed by characters. As mentioned earlier, NOTHING is case-sensitive. Procedure names are drawn from the same set as variable names. Thus, foo can be either a variable or a procedure. No single name scope can contain both a procedure named foo and a variable named foo, but both FOO and Foo can be declared in the same scope as foo. Example: VAR x,y : INTEGER; c1, c2, c3 : CHARACTER; a : ARRAY [ ] OF INTEGER; s1, s2 : ARRAY [ ] OF CHARACTER; table : ARRAY [ a.. z ] OF INTEGER; 4.2 Procedure Declarations The distinction between a function and a procedure lies in the mechanism for returning a value to the calling procedure. A FUNCTION returns a value; a PROCEDURE does not. A FUNCTION returns the value of the expression specified in the RETURN statement that it executes. The RETURN statement also transfers control back to the calling procedure, to the point immediately after the FUNCTION s invocation. A PROCEDURE returns control to the calling routine by executing the last statement in the PROCEDURE or the blank RETURN statement which has no return value. Example: FUNCTION max ( a, b: INTEGER ) : INTEGER; IF a < b { return the larger value } THEN RETURN b ELSE RETURN a { tie goes to 1st value } ; 4.3 Assignment Statement The assignment statement requires that its left-hand side (the V ariable) and its right-hand side (the Expr) evaluate to the same type. If they have different types, either coercion is required or a context-sensitive error has occurred. The coercion rules for assignment are simple. If both sides are numeric (of type INTEGER or FLOAT), the right-hand side is converted to the type of the left-hand side. If either side is of type CHARACTER, both sides must be CHARACTER (or the program contains a context-sensitive error). 4.4 If Statement The grammar for the IF-THEN-ELSE construct embodies one of the classic examples of a context-free ambiguity the dangling else problem. You should rewrite that portion of the grammar to resolve the ambiguity. The language designer intends that an ELSE be bound to the nearest unbound THEN. To evaluate an IF statement, the expression is evaluated. If the expressions type is CHARACTER, the procedure contains a context-sensitive error. If its type is FLOAT, it should be converted to an INTEGER. For an integer value, NOTHING defines 0 as false; any other value is equivalent to true. Examples: IF c=d THEN d := a IF b=0 THEN b := 2*a ELSE b := b/2 4
5 4.5 While Statement The WHILE statement provides a simple mechanism for iteration. The WHILE statement executes the statement under its control, sometimes called the loop body, until the controlling expression becomes false. Again, 0 is treated as false while any other value is treated as true. The controlling expression will be treated as a boolean value encoded into an INTEGER expression. If the expression is not of type INTEGER, the same coercion rules apply as in the IF statement. 4.6 Case Statement The expression in the CASE statement must evaluate to the same type as the case label constants. (Of course, this implies that all the label constants must be of the same type within a single CASE statement. Example: CASE i OF 1: x:=a; 2: x:=b; 3,4: x:= c 4.7 Procedure Invocation NOTHING uses parentheses to indicate invocation and square brackets to indicate subscripting of an array. Any procedure invocation has parentheses even if it has no arguments. (These are called niladic parentheses.) This avoids an ambiguity that occurs if (1) zero-argument functions have no parentheses, or (2) parentheses are used for both arrays and procedure calls. Nothing passes all parameters as call-by-reference formal parameters. At execution, actual parameters are evaluated left-to-right. The compiler must create unique storage copies of any literal constants passed as actual parameters. 4.8 Input-Output Statements NOTHING provides two primitives for input and output. The READ and WRITE statements are intended to provide direct access to primitives implemented in the target abstract machine. Examples: READ (x) WRITE (x+y) WRITE (error) 4.9 Expressions Nothing expressions compute simple values of type INTEGER, FLOAT, or CHARACTER. Addition, subtraction, multiplication, and comparison are defined for both integer and floating point numbers. (Division is omitted deliberately.) For characters, comparison is the only defined operation. The standard ASCII collating sequence is assumed. Coercion If an expression contains operands of only one type, evaluation is straight forward. When an operand contains mixed types, the situation is more complex. Characters cannot appear as operands of any addop or mulop. Such usage constitutes a context-sensitive error. If an addop or mulop has an INTEGER operand and a FLOAT operand, the INTEGER operand should be converted to a FLOAT before the operation is performed. The relational operators are only defined when both operands have the same type. For numbers, comparison is based on both sign and magnitude. For characters, comparison is based on the standard ASCII collating sequence. Any comparison between unlike types constitutes a context-sensitive error. 5
6 Note In an assignment, the value of a numeric expression gets converted to match the type of the variable that appears on its left hand side. (See Section 4.3) Booleans Because NOTHING has no boolean values, relational expressions are defined to yield integer results. Thus, a relational expression of the form a = b is considered to be an arithmetic expression whose value is 1 if the relation holds and 0 otherwise. Hence, both the IF-THEN-ELSE and WHILE statements test integer values; the expression is considered false if it evaluates to 0 and to true if it evaluates to anything else. Consider the following example which tests for either of two conditions being true: READ (a); READ (b); READ (c); READ (d); IF (a = b) + (c < d) THEN WRITE ( error ) Note that relational expressions must be enclosed in parentheses because they have very low precedence. In the above example, a, b, c, and d may be variables of any type. In the above example, the OR operator could have been used instead of +. TheOR operator takes two integer operands and produces the result 0 if both operands evaluate to 0; otherwise, it produces 1. The operator AND evaluates to 1 if both operands are nonzero; otherwise it evaluates to 0. The unary logical operator NOT evaluates to 1 if its argument is zero and to 0 otherwise. Notice that using OR would make the parentheses redundant. Unary Minus NOTHING does not include either a unary minus operator or an optional negative sign on the front of a numeric constant. If you finish your parser early, consider adding a unary minus to the grammar. Of course, it should have highest precedence. 5 An Example Program The following program represents a simple example program written in NOTHING. This program successively reads pairs of integers from the input and prints out their greatest common divisor. PROGRAM example; VAR x, y : INTEGER; FUNCTION gcd (a,b: INTEGER):INTEGER; IF b=0 THEN RETURN a ELSE RETURN gcd(b, a MOD b) ; READ (x); READ (y); WHILE (x <> 0) OR (y <> 0) DO WRITE (gcd (x,y)); READ (x); READ (y) 6
Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a
More informationDEMO A Language for Practice Implementation Comp 506, Spring 2018
DEMO A Language for Practice Implementation Comp 506, Spring 2018 1 Purpose This document describes the Demo programming language. Demo was invented for instructional purposes; it has no real use aside
More informationCS /534 Compiler Construction University of Massachusetts Lowell
CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 Lab Project 2: Parser and Type Checker for NOTHING Due: Sunday, November 14, 2004, 11:59 PM 1 Introduction
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More informationLanguage Reference Manual simplicity
Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna
More informationContents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual
Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9
More informationEECS 6083 Intro to Parsing Context Free Grammars
EECS 6083 Intro to Parsing Context Free Grammars Based on slides from text web site: Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. 1 Parsing sequence of tokens parser
More informationDecaf Language Reference Manual
Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented
More informationMATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards
MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards Language Reference Manual Introduction The purpose of
More informationThis book is licensed under a Creative Commons Attribution 3.0 License
6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars
More informationIPCoreL. Phillip Duane Douglas, Jr. 11/3/2010
IPCoreL Programming Language Reference Manual Phillip Duane Douglas, Jr. 11/3/2010 The IPCoreL Programming Language Reference Manual provides concise information about the grammar, syntax, semantics, and
More informationChapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part2 3.3 Parse Trees and Abstract Syntax Trees
Chapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part2 3.3 Parse Trees and Abstract Syntax Trees 3.3.1 Parse trees 1. Derivation V.S. Structure Derivations do not uniquely represent the structure of the strings
More informationCS 406/534 Compiler Construction Parsing Part I
CS 406/534 Compiler Construction Parsing Part I Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy and Dr.
More informationCPS 506 Comparative Programming Languages. Syntax Specification
CPS 506 Comparative Programming Languages Syntax Specification Compiling Process Steps Program Lexical Analysis Convert characters into a stream of tokens Lexical Analysis Syntactic Analysis Send tokens
More informationCA4003 Compiler Construction Assignment Language Definition
CA4003 Compiler Construction Assignment Language Definition David Sinclair 2017-2018 1 Overview The language is not case sensitive. A nonterminal, X, is represented by enclosing it in angle brackets, e.g.
More informationDecaf Language Reference
Decaf Language Reference Mike Lam, James Madison University Fall 2016 1 Introduction Decaf is an imperative language similar to Java or C, but is greatly simplified compared to those languages. It will
More informationSprite an animation manipulation language Language Reference Manual
Sprite an animation manipulation language Language Reference Manual Team Leader Dave Smith Team Members Dan Benamy John Morales Monica Ranadive Table of Contents A. Introduction...3 B. Lexical Conventions...3
More informationMirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006
Mirage Language Reference Manual Image drawn using Mirage 1.1 Columbia University COMS W4115 Programming Languages and Translators Fall 2006 Prof. Stephen Edwards Team Members: Abhilash I ai2160@columbia.edu
More informationThe Decaf Language. 1 Lexical considerations
The Decaf Language In this course, we will write a compiler for a simple object-oriented programming language called Decaf. Decaf is a strongly-typed, object-oriented language with support for inheritance
More informationA Short Summary of Javali
A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler
More informationSMPL - A Simplified Modeling Language for Mathematical Programming
SMPL - A Simplified Modeling Language for Mathematical Programming Mihály Csaba Markót November 3, 2008 1 Purpose and Scope This working paper describes SMPL, an initiative of a Simplified Modeling Language
More informationASML Language Reference Manual
ASML Language Reference Manual Tim Favorite (tuf1) & Frank Smith (fas2114) - Team SoundHammer Columbia University COMS W4115 - Programming Languages & Translators 1. Introduction The purpose of Atomic
More informationReference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 6 Decaf Language Definition Wednesday, September 4 The project for the 12-unit flavor
More informationIC Language Specification
CS 301 Spring 2016 IC Language Specification The IC Language For the implementation project, you will build a compiler for an object-oriented language called IC (for Irish Coffee 1 ), which is essentially
More informationA Simple Syntax-Directed Translator
Chapter 2 A Simple Syntax-Directed Translator 1-1 Introduction The analysis phase of a compiler breaks up a source program into constituent pieces and produces an internal representation for it, called
More information2.2 Syntax Definition
42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions
More informationCHIL CSS HTML Integrated Language
CHIL CSS HTML Integrated Language Programming Languages and Translators Fall 2013 Authors: Gil Chen Zion gc2466 Ami Kumar ak3284 Annania Melaku amm2324 Isaac White iaw2105 Professor: Prof. Stephen A. Edwards
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationAngela Z: A Language that facilitate the Matrix wise operations Language Reference Manual
Angela Z: A Language that facilitate the Matrix wise operations Language Reference Manual Contents Fei Liu, Mengdi Zhang, Taikun Liu, Jiayi Yan 1. Language definition 3 1.1. Usage 3 1.2. What special feature
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationPetros: A Multi-purpose Text File Manipulation Language
Petros: A Multi-purpose Text File Manipulation Language Language Reference Manual Joseph Sherrick js2778@columbia.edu June 20, 2008 Table of Contents 1 Introduction...................................................
More informationTypescript on LLVM Language Reference Manual
Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String
More informationL-System Fractal Generator: Language Reference Manual
L-System Fractal Generator: Language Reference Manual Michael Eng, Jervis Muindi, Timothy Sun Contents 1 Program Definition 3 2 Lexical Conventions 3 2.1 Comments...............................................
More informationSEMANTIC ANALYSIS TYPES AND DECLARATIONS
SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether
More informationM/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567)
1 M/s Managing distributed workloads Language Reference Manual Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567) Table of Contents 1. Introduction 2. Lexical elements 2.1 Comments 2.2
More informationA simple syntax-directed
Syntax-directed is a grammaroriented compiling technique Programming languages: Syntax: what its programs look like? Semantic: what its programs mean? 1 A simple syntax-directed Lexical Syntax Character
More informationThe Warhol Language Reference Manual
The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming
More informationChapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF)
Chapter 3: Describing Syntax and Semantics Introduction Formal methods of describing syntax (BNF) We can analyze syntax of a computer program on two levels: 1. Lexical level 2. Syntactic level Lexical
More informationGAWK Language Reference Manual
GAWK Language Reference Manual Albert Cui, Karen Nan, Mei-Vern Then, & Michael Raimi So good, you re gonna GAWK. 1.0 Introduction This manual describes the GAWK language and is meant to be used as a reliable
More informationKU Compilerbau - Programming Assignment
716.077 KU Compilerbau - Programming Assignment Univ.-Prof. Dr. Franz Wotawa, Birgit Hofer Institute for Software Technology, Graz University of Technology April 20, 2011 Introduction During this semester
More informationThe Decaf language 1
The Decaf language 1 In this course, we will write a compiler for a simple object-oriented programming language called Decaf. Decaf is a strongly-typed, object-oriented language with support for inheritance
More informationProgramming Languages Third Edition. Chapter 9 Control I Expressions and Statements
Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE
More information3.5 Practical Issues PRACTICAL ISSUES Error Recovery
3.5 Practical Issues 141 3.5 PRACTICAL ISSUES Even with automatic parser generators, the compiler writer must manage several issues to produce a robust, efficient parser for a real programming language.
More informationPrinciples of Programming Languages COMP251: Syntax and Grammars
Principles of Programming Languages COMP251: Syntax and Grammars Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong, China Fall 2007
More informationSpoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03
CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS Spoke Language Reference Manual* William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03 (yw2347, ct2459, zy2147, xc2180)@columbia.edu Columbia University,
More informationTML Language Reference Manual
TML Language Reference Manual Jiabin Hu (jh3240) Akash Sharma (as4122) Shuai Sun (ss4088) Yan Zou (yz2437) Columbia University October 31, 2011 1 Contents 1 Introduction 4 2 Lexical Conventions 4 2.1 Character
More informationCrayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)
Crayon (.cry) Language Reference Manual Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) 1 Lexical Elements 1.1 Identifiers Identifiers are strings used
More informationCS415 Compilers. Syntax Analysis. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Syntax Analysis These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Limits of Regular Languages Advantages of Regular Expressions
More informationSECTION II: LANGUAGE BASICS
Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++ Prof. Amr Goneid, AUC 1 Overview of C++ Prof. Amr Goneid, AUC 2 Overview of C++ Historical C++ Basics Some Library
More informationReference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 7 Espresso Language Definition Wednesday, September 4 The project for the 18-unit
More informationLearning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)
Learning Language Reference Manual 1 George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) A. Introduction Learning Language is a programming language designed
More informationSyntax. A. Bellaachia Page: 1
Syntax 1. Objectives & Definitions... 2 2. Definitions... 3 3. Lexical Rules... 4 4. BNF: Formal Syntactic rules... 6 5. Syntax Diagrams... 9 6. EBNF: Extended BNF... 10 7. Example:... 11 8. BNF Statement
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationARG! Language Reference Manual
ARG! Language Reference Manual Ryan Eagan, Mike Goldin, River Keefer, Shivangi Saxena 1. Introduction ARG is a language to be used to make programming a less frustrating experience. It is similar to C
More informationFlow Language Reference Manual
Flow Language Reference Manual PLT 4115 Fall 2015 Mitchell Gouzenko ( mag2272), Zachary Gleicher (zjg2012) Adam Chelminski (apc2142), Hyonjee Joo (hj2339) 1 Introduction 2 Lexical Conventions 2.1 Identifiers
More informationParsing II Top-down parsing. Comp 412
COMP 412 FALL 2018 Parsing II Top-down parsing Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled
More informationFRAC: Language Reference Manual
FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More information3. Context-free grammars & parsing
3. Context-free grammars & parsing The parsing process sequences of tokens parse tree or syntax tree a / [ / index / ]/= / 4 / + / 2 The parsing process sequences of tokens parse tree or syntax tree a
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationDINO. Language Reference Manual. Author: Manu Jain
DINO Language Reference Manual Author: Manu Jain Table of Contents TABLE OF CONTENTS...2 1. INTRODUCTION...3 2. LEXICAL CONVENTIONS...3 2.1. TOKENS...3 2.2. COMMENTS...3 2.3. IDENTIFIERS...3 2.4. KEYWORDS...3
More informationSyntax Intro and Overview. Syntax
Syntax Intro and Overview CS331 Syntax Syntax defines what is grammatically valid in a programming language Set of grammatical rules E.g. in English, a sentence cannot begin with a period Must be formal
More informationDefining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1
Defining Program Syntax Chapter Two Modern Programming Languages, 2nd ed. 1 Syntax And Semantics Programming language syntax: how programs look, their form and structure Syntax is defined using a kind
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationGBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN
GBIL: Generic Binary Instrumentation Language Language Reference Manual By: Andrew Calvano COMS W4115 Fall 2015 CVN Table of Contents 1) Introduction 2) Lexical Conventions 1. Tokens 2. Whitespace 3. Comments
More informationCS 315 Programming Languages Syntax. Parser. (Alternatively hand-built) (Alternatively hand-built)
Programming languages must be precise Remember instructions This is unlike natural languages CS 315 Programming Languages Syntax Precision is required for syntax think of this as the format of the language
More informationSMURF Language Reference Manual Serial MUsic Represented as Functions
SMURF Language Reference Manual Serial MUsic Represented as Functions Richard Townsend, Lianne Lairmore, Lindsay Neubauer, Van Bui, Kuangya Zhai {rt2515, lel2143, lan2135, vb2363, kz2219}@columbia.edu
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCOP4020 Programming Languages. Syntax Prof. Robert van Engelen
COP4020 Programming Languages Syntax Prof. Robert van Engelen Overview n Tokens and regular expressions n Syntax and context-free grammars n Grammar derivations n More about parse trees n Top-down and
More informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationCS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)
CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going
More informationThere are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:
Numeric Types There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: 1-123 +456 2. Long integers, of unlimited
More informationVENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals
VENTURE COMS 4115 - Language Reference Manual Zach Adler (zpa2001), Ben Carlin (bc2620), Naina Sahrawat (ns3001), James Sands (js4597) Section 1. Lexical Elements 1.1 Identifiers An identifier in VENTURE
More informationCLIP - A Crytographic Language with Irritating Parentheses
CLIP - A Crytographic Language with Irritating Parentheses Author: Duan Wei wd2114@columbia.edu Yi-Hsiu Chen yc2796@columbia.edu Instructor: Prof. Stephen A. Edwards July 24, 2013 Contents 1 Introduction
More informationEZ- ASCII: Language Reference Manual
EZ- ASCII: Language Reference Manual Dmitriy Gromov (dg2720), Feifei Zhong (fz2185), Yilei Wang (yw2493), Xin Ye (xy2190), Joe Lee (jyl2157) Table of Contents 1 Program Definition... 3 2 Lexical Conventions...
More informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
More informationThe Chirp Language Specification
The Chirp Language Specification Li Xu and Fred Martin {xu, fredm}@cs.uml.edu Department of Computer Science University of Massachusetts Lowell Lowell, MA 01854, USA July 2005 1 Introduction Chirp is a
More informationCS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Procedure Abstractions These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Where are we? Well understood Engineering Source Code
More informationEXPRESSIONS AND ASSIGNMENT CITS1001
EXPRESSIONS AND ASSIGNMENT CITS1001 Scope of this lecture Assignment statements Expressions ASSIGNMENT STATEMENT Assignment Statements!!!mark = 50;!! Read as the value in variable on the LHS becomes equal
More informationCOP4020 Programming Languages. Syntax Prof. Robert van Engelen
COP4020 Programming Languages Syntax Prof. Robert van Engelen Overview Tokens and regular expressions Syntax and context-free grammars Grammar derivations More about parse trees Top-down and bottom-up
More informationScheme Quick Reference
Scheme Quick Reference COSC 18 Fall 2003 This document is a quick reference guide to common features of the Scheme language. It is not intended to be a complete language reference, but it gives terse summaries
More informationCOLOGO A Graph Language Reference Manual
COLOGO A Graph Language Reference Manual Advisor: Stephen A. Edwards Shen Wang (sw2613@columbia.edu) Lixing Dong (ld2505@columbia.edu) Siyuan Lu (sl3352@columbia.edu) Chao Song (cs2994@columbia.edu) Zhou
More informationd-file Language Reference Manual
Erwin Polio Amrita Rajagopal Anton Ushakov Howie Vegter d-file Language Reference Manual COMS 4115.001 Thursday, October 20, 2005 Fall 2005 Columbia University New York, New York Note: Much of the content
More informationOperators. Java operators are classified into three categories:
Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.
More informationJME Language Reference Manual
JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.
More informationIntroduction to Parsing
Introduction to Parsing The Front End Source code Scanner tokens Parser IR Errors Parser Checks the stream of words and their parts of speech (produced by the scanner) for grammatical correctness Determines
More informationProject 2 Interpreter for Snail. 2 The Snail Programming Language
CSCI 2400 Models of Computation Project 2 Interpreter for Snail 1 Overview In this assignment you will use the parser generator yacc to construct an interpreter for a language called Snail containing the
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationString Computation Program
String Computation Program Reference Manual Scott Pender scp2135@columbia.edu COMS4115 Fall 2012 10/31/2012 1 Lexical Conventions There are four kinds of tokens: identifiers, keywords, expression operators,
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationFlow Control. CSC215 Lecture
Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements
More informationFunctional Programming Languages (FPL)
Functional Programming Languages (FPL) 1. Definitions... 2 2. Applications... 2 3. Examples... 3 4. FPL Characteristics:... 3 5. Lambda calculus (LC)... 4 6. Functions in FPLs... 7 7. Modern functional
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More information