Exercises Software Development I. 02 Algorithm Testing & Language Description Manual inspection, test plan, grammar, metasyntax notations (BNF, EBNF)

Size: px
Start display at page:

Download "Exercises Software Development I. 02 Algorithm Testing & Language Description Manual inspection, test plan, grammar, metasyntax notations (BNF, EBNF)"

Transcription

1 Exercises Software Development I 02 Algorithm Testing & Language Description Manual inspection, test plan, grammar, metasyntax notations (BNF, EBNF) October 15th, 2014 Software Development I Winter term 2014/2015 Priv.-Doz. Dipl.-Ing. Dr. Andreas Riener Institute for Pervasive Computing Johannes Kepler University Linz riener@pervasive.jku.at

2 I Remember: Slides marked this way contain important concepts and should be carefully reviewed! Algorithm Testing: Manual Inspection In order to understand an algorithm (especially one written by another person), it is necessary to understand how it works. To get an idea of its structure, operation sequences, etc. (i.e., what it does ), manual inspection is a reasonable approach Code review Dry run ( Schreibtischtest ) Procedure Put yourself in the place of a computer and pass through the algorithm in a gradual manner (step by step) Examine all important variables and note down their values on specific, neuralgic code positions (e.g., before a branch, in the body of a loop, etc.) Software Development I // Exercises // 02 Testing and Language Description // 2

3 I Example: Manual Inspection of Algorithm Sum Sum() Input: 1, 9, 6, 8, 0 sum = 0 read( number) while number > 0 sum = sum + number read( number) write( sum) Position 0 Position 1 Position 2 Variables: sum, number Neuralgic code positions Result: Position sum number 0 0??? Software Development I // Exercises // 02 Testing and Language Description // 3

4 Manual Code Inspection: Advantages and Disadvantages Advantages Accurate Warranty to find and identify all errors ( bugs ) Disadvantages Time consuming Not feasable as it comes to complex algorithms (e.g., deep recursions, nested loops, etc.) advice: simulate only central parts of an algorithm manually/by hand Software Development I // Exercises // 02 Testing and Language Description // 4

5 Algorithm Testing: Automatic Inspection Source-level debuggers can be used for assisted or automatic inspection of algorithms Step by step execution Variable inspection Flow control Breakpoint toggling etc. Live Demo Debugging of Sum.java Debug view of Sum.java in the Eclipse framework Software Development I // Exercises // 02 Testing and Language Description // 5

6 Algorithm Testing: Test Plan for Sum Quite simple to generate: Input Expected Output Program Results any integers sum of the integers up to the first nonpositive value 24. Text as input, for example characters Non integer numbers Tell the user this is an invalid input and ask them to re-enter a valid integer: e.g., Value not valid, re-enter: Tell the user this is an invalid input and ask them to re-enter a valid integer: e.g., Value not valid, re-enter: Software Development I // Exercises // 02 Testing and Language Description // 6

7 Algorithm Testing: Test Plan for Sum Quite simple to generate: Input Expected Output Program Results any integers Text as input, for example characters Non integer numbers sum of the integers up to the first nonpositive value 24 Why? Should this not cause a These errors are covered by the Input class. If you crash, use program error, etc.? System.in.* to read-in variable 10 values, you have to 10 take. care of input errors by yourself. For that reason, you are requested to cover all possible input errors already now in your programs! Tell the user this is an invalid input and ask them to re-enter a valid integer: e.g., Value not valid, re-enter: Tell the user this is an invalid input and ask them to re-enter a valid integer: e.g., Value not valid, re-enter: Not a valid int, please try again: Not a valid int, please try again: Software Development I // Exercises // 02 Testing and Language Description // 7

8 I SWE1 UE02 PrimeFact.zip Algorithm Testing: Prime Factor Decomposition (PrimeFact.java) Algorithm We are looking for an algorithm that determines and displays the prime factors of a number entered by the user. For more details on the prime factor decomposition see Input: positive integer numbers Output: prime factors of the entered number, in ascending order Examples Input: 2 Output: 2 Input: 6 Output: 2 * 3 (2x3) Ask yourself What are special cases of this algorithm? Try to generate a complete table Based on this table, create the test plan for the algorithm Software Development I // Exercises // 02 Testing and Language Description // 8

9 I Algorithm Testing: Prime Factor Decomposition (PrimeFact.java) Group 1: Special cases, boundary values -1 invalid input (only positive integers); has no prime factors 0 has no prime factors 1 has no prime factors 2 smallest value with prime factors (only one) 3 number with one prime factor 4 smallest input with two prime factors (same) 6 smallest value with two different prime factors 8 smallest value with more than 2 prime factors 256 multiple, same prime factors 8085 multiple prime factors, different size 1031 greater number with only one prime factor (= prime number) Group 2: Illegal inputs -1 invalid (negativ) hallo not a number 123hallo not a number 1.12 not integer exceeds max. input number Software Development I // Exercises // 02 Testing and Language Description // 9

10 I Algorithm Testing: Test Plan for PrimeFact.java Aim (Group 1) Input Expected output Program output smallest number w/o prime factor 0 0 has no prime factors? first number >0 with no prime factors 1 1 has no prime factors? smallest value with one prime factor 2 2? second value with one prime factor 3 3? smallest value with two prime factors 4 2 * 2? smallest value with two different prime factors 6 2 * 3? smallest value with more than 2 prime factors 8 2 * 2 * 2? smallest value with more than two prime factors (> 2) 27 3 * 3 * 3? number with multiple (equal) prime factors * 2 * 2 * 2 * 2 * 2 * 2 * 2? number with mutiple different prime factors * 5 * 7 * 7 * 11? larger number with only one prime factor ? Software Development I // Exercises // 02 Testing and Language Description // 10

11 I Algorithm Testing: Test Plan for PrimeFact.java (2) Aim (Group 1, cont.) Input Expected output Program output common case 10 2 * 5? common case * 3 * 3 * 3 * 11 * 11? common case * 2 * 3 * 11 * 101? Aim (Group 2) Input Expected output Program output negative number (smallest) -1 invalid, no prime factors? invalid, text instead of integer hallo valid number required? invalid, valid number folllowed by text 123hallo valid number required? invalid, float value valid number required? no/empty input (finalized with \n) valid number required? largest integer number ? largest integer number valid number required? largest negative integer number invalid, no prime factors? Software Development I // Exercises // 02 Testing and Language Description // 11

12 I Algorithm Testing: Test Plan...highly relevant for assignments in most of the exercise sheets we call for the inclusion of a test plan. Before actually testing your program (i.e., implementation of an algorithm) you have to think about WHICH behavior, what special cases should be tested? HOW to reach these cases in the program (input values)? WHAT is the expected result (i.e., output values)? Testplan (tabular form) should contain Case, input, expected result, program output for some normal cases all (!) special cases and boundary values (over-/underflow, division by zero, infinity, etc.) illegal input configurations For additional information see (German language only) Software Development I // Exercises // 02 Testing and Language Description // 12

13 (Programming) Language Description: Metasyntax

14 Programming Languages: Representation / Description Notation of algorithms (see last week!) Textual form (prose) Graphical representation (Nassi-Shneiderman diagram) flow chart structure chart Programming language The programming language itself calls also for a representation/description Grammar = syntactical rules of a (programming) language Syntax = sentence structure, order of symbols, instructions Semantics = the meaning of a program, code fragment, expression Such a rule base enables the compiler to detect and announce programming errors/mistakes already at compile time Software Development I // Exercises // 02 Testing and Language Description // 14

15 I Language Descriptions: Types of Notations Metasyntax notations Backus-Naur-Form (BNF) Extended Backus-Naur-Form (EBNF) BNF vs. EBNF BNF is a formal, mathematical oriented notation form to describe the syntax of the programming language ALGOL60 BNF only defines terminal symbols, nonterminal symbols (production rules) and alternatives EBNF is an extension of BNF to better (easier) define complex syntax (take use of e.g. recursive definitions) - EBNF extends BNF by adding additional constructs (see next slide) - readability of EBNF as apposed to BNF is much improved as well - functional range of BNF is similar to EBNF (each EBNF description can also be represented with BNF) Syntax diagram Finite-state machine more details on Turing machines etc. in other lectures Software Development I // Exercises // 02 Testing and Language Description // 15

16 I Metasyntax Notation: Example Positive Integers in BNF A positive Integer number is represented by at least one, but in general an arbitrary number of digits; no leading sign; zero (0) number included, e.g Nonterminal symbols Alternative RECURSION PosIntBNF = number number PosIntBNF number = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" Terminal symbols Software Development I // Exercises // 02 Testing and Language Description // 16

17 I Metasyntax Notation: Extended Backus-Naur-Form (EBNF) Terminal symbols are literal, final characters that cannot be broken down into smaller units (also called tokens ) if, while, for, int, class, etc. special characters, such as ;,. - % = " + Nonterminal symbols. Using production rules, nonterminal symbols can be refined by different combinations of terminal symbols, further nonterminal symbols and by using meta-symbols, e.g. Paragraph = Sentence { Sentence } Sentence = Subject Predicate Object EBNF defines several meta symbols also called control symbols : =,., [], {},, () (as opposed to BNF, which only defines the alternative or ) = Production rule. End of production rule [] occurrence: one time or never {} occurrence: optional (0, 1,, ) alternative (left or right side) () precedence (group for priority) Software Development I // Exercises // 02 Testing and Language Description // 17 Valid meta symbols in EBNF.

18 I Metasyntax Notation: Example Positive Integers in EBNF A positive Integer number is represented by at least one, but in general an arbitrary number of digits; no leading sign; zero (0) number included, e.g altered representation of the recursion production rules are terminated by a period PosIntEBNF = number {number}. number = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9". Software Development I // Exercises // 02 Testing and Language Description // 18

19 Derivation Tree (BNF): Example Positive Integers PosIntBNF = number number PosIntBNF number = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" Wanted: Derivation tree for the number 3140 PosIntBNF number PosIntBNF 3 number PosIntBNF 3 1 number PosIntBNF number Software Development I // Exercises // 02 Testing and Language Description // 19

20 Metasyntax Notation: Examples for BNF, EBNF Representation Example 1: Decimal numbers A decimal number is positive or negative has a leading minus sign or is unsigned has any number of pre-decimal places (but at least 1) has an optional decimal symbol (".") followed by any number of decimal places (again at least one digit) Examples Software Development I // Exercises // 02 Testing and Language Description // 20

21 Metasyntax Notation: Examples for BNF, EBNF Representation BNF representation: Decimal number BNFDec = "-" Decnumber Decnumber Decnumber = Digitlist Digitlist "." Digitlist Digitlist = Digit Digit Digitlist Digit = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" Software Development I // Exercises // 02 Testing and Language Description // 21

22 Metasyntax Notation: Examples for BNF, EBNF Representation EBNF representation: Decimal number EBNFDec = ["-"] Digitlist ["." Digitlist]. Digitlist = Digit {Digit}. Digit = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9". Software Development I // Exercises // 02 Testing and Language Description // 22

23 Derivation Tree (BNF, EBNF): Example Decimal Numbers BNFDec = "-" Decnumber Decnumber Decnumber = Digitlist Digitlist "." Digitlist Digitlist = Digit Digit Digitlist Digit = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" EBNFDec = ["-"] Digitlist ["." Digitlist]. Digitlist = Digit {Digit}. Digit = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9". Try on your own: Derivation tree for the number PI (3.1415) in BNF or EBNF Software Development I // Exercises // 02 Testing and Language Description // 23

24 Derivation Tree (BNF, EBNF): Example Decimal Numbers BNF representation: Software Development I // Exercises // 02 Testing and Language Description // 24

25 Derivation Tree (BNF, EBNF): Example Decimal Numbers EBNF representation: Software Development I // Exercises // 02 Testing and Language Description // 25

26 Metasyntax Notation: Examples for BNF, EBNF Representation Example 2: Date formats (Prose) Two date formats: (a) short form, (b) extensive version Short form: Day (numeric) followed by the month (numeric), and finally the year (numeric, last two digits only); the three values are separated by a. or / symbol (mixed usage not allowed) Extensive version: Identifier of the day of the week (English language) followed by a comma; after that, the date is continued with a month identifier (English language) and the day of the month in numeric format; after another comma the year (numeric, last two digits only) concludes a date In both notations it is allowed to insert any number of spaces ( ) between the individual values and symbols Examples short: , 15/ 10/ 14 long: Wednesday, October 15, 14 Software Development I // Exercises // 02 Testing and Language Description // 26

27 Metasyntax Notation: Examples for BNF, EBNF Representation EBNF representation: Date formats Date = ShortDate LongDate. ShortDate = Space Number Space ( "." Space Number Space "." "/" Space Number Space "/" ) Space YearNumber. LongDate = Day Space "," Space Month Space Number Space "," Space YearNumber. Day = "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday". Month = "January" "February" "March" "April" "May" "June" "July" "August" "September" "October "November" "December". Number = Digit [ Digit ]. YearNumber = Digit Digit. Digit = "0" "1" "2" "3" "4" "5" "6" "7" "8" "9". Space = {" "}. Software Development I // Exercises // 02 Testing and Language Description // 27

28 Language Descriptions: Types of Notations Syntax diagram Terminal symbols circles or ovals Nonterminal symbols rectangles '/' 'Monday' LongDate Alternatives illustrated as branches, T-junctions Software Development I // Exercises // 02 Testing and Language Description // 28

29 Syntax Diagram: Date Formats Date ShortDate Space Number Digit Digit LongDate YearNumber Digit Digit ShortDate Space Number Space 9. Space Number Space. / Space Number Space / Digit 8... Space YearNumber 0 Software Development I // Exercises // 02 Testing and Language Description // 29

30 Syntax Diagram: Date Formats (continued) LongDate Space Day Space, Space Month Space Number Space, Space YearNumber Monday January Day Tuesday... Month February... Sunday December Software Development I // Exercises // 02 Testing and Language Description // 30

31 Exercises Software Development I 02 Algorithm Testing & Language Description Manual inspection, test plan, grammar, metasyntax notations (BNF, EBNF) October 15th, 2014 Software Development I Winter term 2014/2015 Priv.-Doz. Dipl.-Ing. Dr. Andreas Riener Institute for Pervasive Computing Johannes Kepler University Linz riener@pervasive.jku.at

Example. Section: PS 709 Examples of Calculations of Reduced Hours of Work Last Revised: February 2017 Last Reviewed: February 2017 Next Review:

Example. Section: PS 709 Examples of Calculations of Reduced Hours of Work Last Revised: February 2017 Last Reviewed: February 2017 Next Review: Following are three examples of calculations for MCP employees (undefined hours of work) and three examples for MCP office employees. Examples use the data from the table below. For your calculations use

More information

Syntax. A. Bellaachia Page: 1

Syntax. 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 information

CPS 506 Comparative Programming Languages. Syntax Specification

CPS 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 information

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer:

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer: Theoretical Part Chapter one:- - What are the Phases of compiler? Six phases Scanner Parser Semantic Analyzer Source code optimizer Code generator Target Code Optimizer Three auxiliary components Literal

More information

Chapter 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) 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 information

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014 Exercises Software Development I 03 Data Representation Data types, range of values, ernal format, literals October 22nd, 2014 Software Development I Wer term 2013/2014 Priv.-Doz. Dipl.-Ing. Dr. Andreas

More information

Lecture 4: Syntax Specification

Lecture 4: Syntax Specification The University of North Carolina at Chapel Hill Spring 2002 Lecture 4: Syntax Specification Jan 16 1 Phases of Compilation 2 1 Syntax Analysis Syntax: Webster s definition: 1 a : the way in which linguistic

More information

Week 2: Syntax Specification, Grammars

Week 2: Syntax Specification, Grammars CS320 Principles of Programming Languages Week 2: Syntax Specification, Grammars Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Week 2: Syntax Specification, Grammars 1/ 62 Words and Sentences

More information

This book is licensed under a Creative Commons Attribution 3.0 License

This 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 information

Syntax. In Text: Chapter 3

Syntax. In Text: Chapter 3 Syntax In Text: Chapter 3 1 Outline Syntax: Recognizer vs. generator BNF EBNF Chapter 3: Syntax and Semantics 2 Basic Definitions Syntax the form or structure of the expressions, statements, and program

More information

Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn

Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn Problem Write and test a Scheme program to compute how many days are spanned by two given days. The program will include a procedure

More information

Structured Programming. Jon Macey

Structured Programming. Jon Macey Structured Programming Jon Macey Structured Programming Structured programming is an attempt to formalise the process of program development. There are several basis for a theorem of structured programming,

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions

More information

Programming Language Definition. Regular Expressions

Programming Language Definition. Regular Expressions Programming Language Definition Syntax To describe what its programs look like Specified using regular expressions and context-free grammars Semantics To describe what its programs mean Specified using

More information

COP 3402 Systems Software Top Down Parsing (Recursive Descent)

COP 3402 Systems Software Top Down Parsing (Recursive Descent) COP 3402 Systems Software Top Down Parsing (Recursive Descent) Top Down Parsing 1 Outline 1. Top down parsing and LL(k) parsing 2. Recursive descent parsing 3. Example of recursive descent parsing of arithmetic

More information

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised:

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised: EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing Görel Hedin Revised: 2017-09-04 This lecture Regular expressions Context-free grammar Attribute grammar

More information

3. Context-free grammars & parsing

3. 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 information

Lecture 10 Parsing 10.1

Lecture 10 Parsing 10.1 10.1 The next two lectures cover parsing. To parse a sentence in a formal language is to break it down into its syntactic components. Parsing is one of the most basic functions every compiler carries out,

More information

Chapter 4. Syntax - the form or structure of the expressions, statements, and program units

Chapter 4. Syntax - the form or structure of the expressions, statements, and program units Syntax - the form or structure of the expressions, statements, and program units Semantics - the meaning of the expressions, statements, and program units Who must use language definitions? 1. Other language

More information

announcements CSE 311: Foundations of Computing review: regular expressions review: languages---sets of strings

announcements CSE 311: Foundations of Computing review: regular expressions review: languages---sets of strings CSE 311: Foundations of Computing Fall 2013 Lecture 19: Regular expressions & context-free grammars announcements Reading assignments 7 th Edition, pp. 878-880 and pp. 851-855 6 th Edition, pp. 817-819

More information

AIMMS Function Reference - Date Time Related Identifiers

AIMMS Function Reference - Date Time Related Identifiers AIMMS Function Reference - Date Time Related Identifiers This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com Aimms 3.13 Date-Time

More information

Visual Basic for Applications

Visual Basic for Applications Visual Basic for Applications Programming Damiano SOMENZI School of Economics and Management Advanced Computer Skills damiano.somenzi@unibz.it Week 1 Outline 1 Visual Basic for Applications Programming

More information

UNIT I Programming Language Syntax and semantics. Kainjan Sanghavi

UNIT I Programming Language Syntax and semantics. Kainjan Sanghavi UNIT I Programming Language Syntax and semantics B y Kainjan Sanghavi Contents Language Definition Syntax Abstract and Concrete Syntax Concept of binding Language Definition Should enable a person or computer

More information

Institute For Arts & Digital Sciences SHORT COURSES

Institute For Arts & Digital Sciences SHORT COURSES Institute For Arts & Digital Sciences SHORT COURSES SCHEDULES AND FEES 2017 SHORT COURSES - GRAPHIC DESIGN Adobe Photoshop Basic 07 February 28 February Tuesdays 14:30-17:30 Adobe Photoshop Basic 07 February

More information

CSE 3302 Programming Languages Lecture 2: Syntax

CSE 3302 Programming Languages Lecture 2: Syntax CSE 3302 Programming Languages Lecture 2: Syntax (based on slides by Chengkai Li) Leonidas Fegaras University of Texas at Arlington CSE 3302 L2 Spring 2011 1 How do we define a PL? Specifying a PL: Syntax:

More information

Objectives/Outcomes. Introduction: If we have a set "collection" of fruits : Banana, Apple and Grapes.

Objectives/Outcomes. Introduction: If we have a set collection of fruits : Banana, Apple and Grapes. 1 September 26 September One: Sets Introduction to Sets Define a set Introduction: If we have a set "collection" of fruits : Banana, Apple Grapes. 4 F={,, } Banana is member "an element" of the set F.

More information

Programming Lecture 3

Programming Lecture 3 Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements

More information

CMPS Programming Languages. Dr. Chengwei Lei CEECS California State University, Bakersfield

CMPS Programming Languages. Dr. Chengwei Lei CEECS California State University, Bakersfield CMPS 3500 Programming Languages Dr. Chengwei Lei CEECS California State University, Bakersfield Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing

More information

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Defining 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 information

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1 INFORMATION TECHNOLOGY SPREADSHEETS Part 1 Page: 1 Created by John Martin Exercise Built-In Lists 1. Start Excel Spreadsheet 2. In cell B1 enter Mon 3. In cell C1 enter Tue 4. Select cell C1 5. At the

More information

Exercises Software Development I. 05 Conversions and Promotions; Lifetime, Scope, Shadowing. November 5th, 2014

Exercises Software Development I. 05 Conversions and Promotions; Lifetime, Scope, Shadowing. November 5th, 2014 Exercises Software Development I 05 Conversions and Promotions; Lifetime, Scope, Shadowing November 5th, 2014 Software Development I Winter term 2014/2015 Priv.-Doz. Dipl.-Ing. Dr. Andreas Riener Institute

More information

programming languages need to be precise a regular expression is one of the following: tokens are the building blocks of programs

programming languages need to be precise a regular expression is one of the following: tokens are the building blocks of programs Chapter 2 :: Programming Language Syntax Programming Language Pragmatics Michael L. Scott Introduction programming languages need to be precise natural languages less so both form (syntax) and meaning

More information

flex is not a bad tool to use for doing modest text transformations and for programs that collect statistics on input.

flex is not a bad tool to use for doing modest text transformations and for programs that collect statistics on input. flex is not a bad tool to use for doing modest text transformations and for programs that collect statistics on input. More often than not, though, you ll want to use flex to generate a scanner that divides

More information

CSCI312 Principles of Programming Languages!

CSCI312 Principles of Programming Languages! CSCI312 Principles of Programming Languages! Chapter 2 Syntax! Xu Liu Review! Principles of PL syntax, naming, types, semantics Paradigms of PL design imperative, OO, functional, logic What makes a successful

More information

6. Control Statements II

6. Control Statements II Visibility Declaration in a block is not visible outside of the block. 6. Control Statements II Visibility, Local Variables, While Statement, Do Statement, Jump Statements main block int main () int i

More information

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2. Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.

More information

CSE 305 Programming Languages Spring, 2010 Homework 5 Maximum Points: 24 Due 10:30 AM, Friday, February 26, 2010

CSE 305 Programming Languages Spring, 2010 Homework 5 Maximum Points: 24 Due 10:30 AM, Friday, February 26, 2010 CSE 305 Programming Languages Spring, 2010 Homework 5 Maximum Points: 24 Due 10:30 AM, Friday, February 26, 2010 Professor Shapiro February 12, 2010 Write the answers in a file named hw5.txt. Put your

More information

Calendar Excel Template User Guide

Calendar Excel Template User Guide Calendar Excel Template User Guide Excel-based simple Calendar Template Version 3 This Excel-based template provides a calendar template for each month of a year. It also incorporates an hourly schedule

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

Scheduling. Scheduling Tasks At Creation Time CHAPTER

Scheduling. Scheduling Tasks At Creation Time CHAPTER CHAPTER 13 This chapter explains the scheduling choices available when creating tasks and when scheduling tasks that have already been created. Tasks At Creation Time The tasks that have the scheduling

More information

September 2015 Calendar This Excel calendar is blank & designed for easy use as a planner. Courtesy of WinCalendar.com

September 2015 Calendar This Excel calendar is blank & designed for easy use as a planner. Courtesy of WinCalendar.com September 2015 Calendar This Excel calendar is blank & designed for easy use as a planner. Courtesy of WinCalendar.com August ~ September 2015 ~ Sunday Monday Tuesday Wednesday Thursday Friday 1 2 3 4

More information

Complex data structures. Cedric Saule

Complex data structures. Cedric Saule Complex data structures Cedric Saule cedric.saule@uni-bielefeld.de Arrays in language C In language C, arrays are contiguous spaces in memory. We make the difference between two kinds of arrays : Static

More information

Dr. D.M. Akbar Hussain

Dr. D.M. Akbar Hussain Syntax Analysis Parsing Syntax Or Structure Given By Determines Grammar Rules Context Free Grammar 1 Context Free Grammars (CFG) Provides the syntactic structure: A grammar is quadruple (V T, V N, S, R)

More information

Read and fill in this page now. Your instructional login (e.g., cs3-ab): Your lab section days and time: Name of the person sitting to your left:

Read and fill in this page now. Your instructional login (e.g., cs3-ab): Your lab section days and time: Name of the person sitting to your left: CS3 Fall 05 Midterm 1 Read and fill in this page now Your name: Your instructional login (e.g., cs3-ab): Your lab section days and time: Your lab T.A.: Name of the person sitting to your left: Name of

More information

Calendar PPF Production Cycles Non-Production Activities and Events

Calendar PPF Production Cycles Non-Production Activities and Events 20-207 Calendar PPF Production Cycles Non-Production Activities and Events Four Productions For non-holiday productions 7 Week Stage Cycles 36 Uses plus strike (as in prior years and per agreement with

More information

COP 3402 Systems Software Syntax Analysis (Parser)

COP 3402 Systems Software Syntax Analysis (Parser) COP 3402 Systems Software Syntax Analysis (Parser) Syntax Analysis 1 Outline 1. Definition of Parsing 2. Context Free Grammars 3. Ambiguous/Unambiguous Grammars Syntax Analysis 2 Lexical and Syntax Analysis

More information

Chapter 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 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 information

CHAPTER 5 FLOW OF CONTROL

CHAPTER 5 FLOW OF CONTROL CHAPTER 5 FLOW OF CONTROL PROGRAMMING CONSTRUCTS - In a program, statements may be executed sequentially, selectively or iteratively. - Every programming language provides constructs to support sequence,

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Write a description of the set. 1) {January, February, March, April, May, June, July, August,

More information

Math in Focus Vocabulary. Kindergarten

Math in Focus Vocabulary. Kindergarten Math in Focus Vocabulary Kindergarten Chapter Word Definition 1 one 1 * 1 two 2 * * 1 three 3 * * * 1 four 4 * * * * 1 five 5 * * * * * 1 same things that have a common property 1 different things that

More information

Syntax and Grammars 1 / 21

Syntax and Grammars 1 / 21 Syntax and Grammars 1 / 21 Outline What is a language? Abstract syntax and grammars Abstract syntax vs. concrete syntax Encoding grammars as Haskell data types What is a language? 2 / 21 What is a language?

More information

Sequential Search (Searching Supplement: 1-2)

Sequential Search (Searching Supplement: 1-2) (Searching Supplement: 1-2) A sequential search simply involves looking at each item in an array in turn until either the value being searched for is found or it can be determined that the value is not

More information

CSCE 314 Programming Languages

CSCE 314 Programming Languages CSCE 314 Programming Languages Syntactic Analysis Dr. Hyunyoung Lee 1 What Is a Programming Language? Language = syntax + semantics The syntax of a language is concerned with the form of a program: how

More information

Describing Syntax and Semantics

Describing Syntax and Semantics Describing Syntax and Semantics Introduction Syntax: the form or structure of the expressions, statements, and program units Semantics: the meaning of the expressions, statements, and program units Syntax

More information

Informatica 3 Syntax and Semantics

Informatica 3 Syntax and Semantics Informatica 3 Syntax and Semantics Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Introduction Introduction to the concepts of syntax and semantics Binding Variables Routines

More information

CS101 Lecture 04: Binary Arithmetic

CS101 Lecture 04: Binary Arithmetic CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary

More information

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays A Beginner s Guide to Programming Logic, Introductory Chapter 6 Arrays Objectives In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested

More information

Building Compilers with Phoenix

Building Compilers with Phoenix Building Compilers with Phoenix Syntax-Directed Translation Structure of a Compiler Character Stream Intermediate Representation Lexical Analyzer Machine-Independent Optimizer token stream Intermediate

More information

MONITORING REPORT ON THE WEBSITE OF THE STATISTICAL SERVICE OF CYPRUS DECEMBER The report is issued by the.

MONITORING REPORT ON THE WEBSITE OF THE STATISTICAL SERVICE OF CYPRUS DECEMBER The report is issued by the. REPUBLIC OF CYPRUS STATISTICAL SERVICE OF CYPRUS MONITORING REPORT ON THE WEBSITE OF THE STATISTICAL SERVICE OF CYPRUS DECEMBER The report is issued by the Monitoring Report STATISTICAL DISSEMINATION AND

More information

Chapter 6 Reacting to Player Input

Chapter 6 Reacting to Player Input Chapter 6 Reacting to Player Input 6.1 Introduction In this chapter, we will show you how your game program can react to mouse clicks and button presses. In order to do this, we need a instruction called

More information

ADVANCED ALGORITHMS TABLE OF CONTENTS

ADVANCED ALGORITHMS TABLE OF CONTENTS ADVANCED ALGORITHMS TABLE OF CONTENTS ADVANCED ALGORITHMS TABLE OF CONTENTS...1 SOLVING A LARGE PROBLEM BY SPLITTING IT INTO SEVERAL SMALLER SUB-PROBLEMS CASE STUDY: THE DOOMSDAY ALGORITHM... INTRODUCTION

More information

Read and fill in this page now

Read and fill in this page now Login: Page - 1 CS3 Midterm 1 Read and fill in this page now Fall 2006 Titterton Name: Instructional Login (eg, cs3-ab): UCWISE login: Lab section (day and time): T.A.: Name of the person sitting to your

More information

A language is a subset of the set of all strings over some alphabet. string: a sequence of symbols alphabet: a set of symbols

A language is a subset of the set of all strings over some alphabet. string: a sequence of symbols alphabet: a set of symbols The current topic:! Introduction! Object-oriented programming: Python! Functional programming: Scheme! Python GUI programming (Tkinter)! Types and values! Logic programming: Prolog! Introduction! Rules,

More information

Computer Grade 5. Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May

Computer Grade 5. Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May Computer Grade 5 1 st Term Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May Summer Vacation: June, July and August 1 st & 2 nd week Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 First term (April) Week

More information

Basic Device Management

Basic Device Management This chapter contains the following sections: About, page 1 Licensing Requirements for, page 2 Default Settings for Basic Device Parameters, page 3 Changing the Device Hostname, page 3 Configuring the

More information

DEPARTMENT OF ACADEMIC UPGRADING

DEPARTMENT OF ACADEMIC UPGRADING DEPARTMENT OF ACADEMIC UPGRADING COURSE OUTLINE WINTER 2013 INTRODUCTION TO MATH 0081 INSTRUCTOR: Sukhvir Sandhu PHONE: (780) 539-2810 or 2234 OFFICE: Math Lab A210 or C310 E-MAIL: ssandhu@gprc.ab.ca OFFICE

More information

EECS 6083 Intro to Parsing Context Free Grammars

EECS 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 information

DECISION CONTROL AND LOOPING STATEMENTS

DECISION CONTROL AND LOOPING STATEMENTS DECISION CONTROL AND LOOPING STATEMENTS DECISION CONTROL STATEMENTS Decision control statements are used to alter the flow of a sequence of instructions. These statements help to jump from one part of

More information

Information Science 1

Information Science 1 Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting

More information

Consider a description of arithmetic. It includes two equations that define the structural types of digit and operator:

Consider a description of arithmetic. It includes two equations that define the structural types of digit and operator: Syntax A programming language consists of syntax, semantics, and pragmatics. We formalize syntax first, because only syntactically correct programs have semantics. A syntax definition of a language lists

More information

afewadminnotes CSC324 Formal Language Theory Dealing with Ambiguity: Precedence Example Office Hours: (in BA 4237) Monday 3 4pm Wednesdays 1 2pm

afewadminnotes CSC324 Formal Language Theory Dealing with Ambiguity: Precedence Example Office Hours: (in BA 4237) Monday 3 4pm Wednesdays 1 2pm afewadminnotes CSC324 Formal Language Theory Afsaneh Fazly 1 Office Hours: (in BA 4237) Monday 3 4pm Wednesdays 1 2pm January 16, 2013 There will be a lecture Friday January 18, 2013 @2pm. 1 Thanks to

More information

We first learn one useful option of gcc. Copy the following C source file to your

We first learn one useful option of gcc. Copy the following C source file to your Lecture 5 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 5: gcc and gdb tools 10-Oct-2018 Location: Teaching Labs Time: Thursday Instructor: Vlado Keselj Lab 5:

More information

Lexical Considerations

Lexical 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 information

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1 Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to

More information

AQA Decision 1 Algorithms. Section 1: Communicating an algorithm

AQA Decision 1 Algorithms. Section 1: Communicating an algorithm AQA Decision 1 Algorithms Section 1: Communicating an algorithm Notes and Examples These notes contain subsections on Flow charts Pseudo code Loops in algorithms Programs for the TI-83 graphical calculator

More information

Software Testing. 1. Testing is the process of demonstrating that errors are not present.

Software Testing. 1. Testing is the process of demonstrating that errors are not present. What is Testing? Software Testing Many people understand many definitions of testing :. Testing is the process of demonstrating that errors are not present.. The purpose of testing is to show that a program

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

CSE 311 Lecture 21: Context-Free Grammars. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 21: Context-Free Grammars. Emina Torlak and Kevin Zatloukal CSE 311 Lecture 21: Context-Free Grammars Emina Torlak and Kevin Zatloukal 1 Topics Regular expressions A brief review of Lecture 20. Context-free grammars Syntax, semantics, and examples. 2 Regular expressions

More information

Aerospace Software Engineering

Aerospace Software Engineering 16.35 Aerospace Software Engineering Ada 95: subtypes, enumeration types, functions, packages, exception handling September 30/2002 Prof. I. K. Lundqvist kristina@mit.edu 16.35 September 30/2002 Prof.

More information

Organizing and Summarizing Data

Organizing and Summarizing Data 1 Organizing and Summarizing Data Key Definitions Frequency Distribution: This lists each category of data and how often they occur. : The percent of observations within the one of the categories. This

More information

Regular Expressions. Agenda for Today. Grammar for a Tiny Language. Programming Language Specifications

Regular Expressions. Agenda for Today. Grammar for a Tiny Language. Programming Language Specifications Agenda for Today Regular Expressions CSE 413, Autumn 2005 Programming Languages Basic concepts of formal grammars Regular expressions Lexical specification of programming languages Using finite automata

More information

B.2 Measures of Central Tendency and Dispersion

B.2 Measures of Central Tendency and Dispersion Appendix B. Measures of Central Tendency and Dispersion B B. Measures of Central Tendency and Dispersion What you should learn Find and interpret the mean, median, and mode of a set of data. Determine

More information

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 1 Tuesday, January 29, 2013 1 Intro to semantics What is the meaning of a program? When we write a program, we use

More information

10/30/2010. Introduction to Control Statements. The if and if-else Statements (cont.) Principal forms: JAVA CONTROL STATEMENTS SELECTION STATEMENTS

10/30/2010. Introduction to Control Statements. The if and if-else Statements (cont.) Principal forms: JAVA CONTROL STATEMENTS SELECTION STATEMENTS JAVA CONTROL STATEMENTS Introduction to Control statements are used in programming languages to cause the flow of control to advance and branch based on changes to the state of a program. In Java, control

More information

YEAR 8 STUDENT ASSESSMENT PLANNER SEMESTER 1, 2018 TERM 1

YEAR 8 STUDENT ASSESSMENT PLANNER SEMESTER 1, 2018 TERM 1 YEAR 8 STUDENT ASSESSMENT PLANNER SEMESTER 1, 2018 TERM 1 Term 1 - Due Dates 22 26 January 29 January 2 February 5 9 February 12 16 February 19 23 February 26 February 2 March 5 9 March 12 16 March 19

More information

11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e CS-3160 Concepts of Programming Languages Spring 2015 EXAM #1 (Chapters 1-6) Name: SCORES MC: /75 PROB #1: /15 PROB #2: /10 TOTAL: /100 Multiple Choice Responses Each multiple choice question in the separate

More information

HP Project and Portfolio Management Center

HP Project and Portfolio Management Center HP Project and Portfolio Management Center Software Version: 8.00 Generating Fiscal Periods Document Release Date: July 2009 Software Release Date: July 2009 Legal Notices Warranty The only warranties

More information

CALENDAR OF FILING DEADLINES AND SEC HOLIDAYS

CALENDAR OF FILING DEADLINES AND SEC HOLIDAYS CALENDAR OF FILING S AND SEC HOLIDAYS INFORMATION IN THIS CALENDAR HAS BEEN OBTAINED BY SOURCES BELIEVED TO BE RELIABLE, BUT CANNOT BE GUARANTEED FOR ACCURACY. PLEASE CONSULT WITH PROFESSIONAL COUNSEL

More information

Introduction to Parsing. Lecture 8

Introduction to Parsing. Lecture 8 Introduction to Parsing Lecture 8 Adapted from slides by G. Necula Outline Limitations of regular languages Parser overview Context-free grammars (CFG s) Derivations Languages and Automata Formal languages

More information

Syntax Intro and Overview. Syntax

Syntax 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 information

Highline Excel 2016 Class 09: Date Functions

Highline Excel 2016 Class 09: Date Functions Highline Excel 2016 Class 09: Date Functions Table of Contents Date Functions... 2 Examples of EOMONTH, EDATE and DATE functions:... 2 Fiscal Year... 3 Example of Data Set with Date Helper Columns, including

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

Homework & Announcements

Homework & Announcements Homework & nnouncements New schedule on line. Reading: Chapter 18 Homework: Exercises at end Due: 11/1 Copyright c 2002 2017 UMaine School of Computing and Information S 1 / 25 COS 140: Foundations of

More information

Programming Language Concepts, cs2104 Lecture 04 ( )

Programming Language Concepts, cs2104 Lecture 04 ( ) Programming Language Concepts, cs2104 Lecture 04 (2003-08-29) Seif Haridi Department of Computer Science, NUS haridi@comp.nus.edu.sg 2003-09-05 S. Haridi, CS2104, L04 (slides: C. Schulte, S. Haridi) 1

More information

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0 SYL-410-2014C CS 410 - Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0 Course location: 107 ERB, Evansdale Campus Course times: Tuesdays and Thursdays, 2:00-3:15 Course

More information

Programming Assignment #2

Programming Assignment #2 Programming Assignment #2 Due: 11:59pm, Wednesday, Feb. 13th Objective: This assignment will provide further practice with classes and objects, and deepen the understanding of basic OO programming. Task:

More information

Formative Benchmark 1

Formative Benchmark 1 Key Tested Formative Benchmark 1 November 213-20, 2013 Section 1: Lessons 1-10 Number Sentences, Show Data through Graphs, Repeating Patterns with Colors, Shapes and Letters Section 2: Lessons 11-20 Fractions

More information

Chapter 3. Describing Syntax and Semantics ISBN

Chapter 3. Describing Syntax and Semantics ISBN Chapter 3 Describing Syntax and Semantics ISBN 0-321-49362-1 Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

Formal Languages. Formal Languages

Formal Languages. Formal Languages Regular expressions Formal Languages Finite state automata Deterministic Non-deterministic Review of BNF Introduction to Grammars Regular grammars Formal Languages, CS34 Fall2 BGRyder Formal Languages

More information