Jerzy Nawrocki, Introduction to informatics

Size: px
Start display at page:

Download "Jerzy Nawrocki, Introduction to informatics"

Transcription

1 Jerzy Nawrocki Faculty of Computing & Information Sci. Poznan University of Technology File conversion problem FName:John SName:Great Salary 585 Text processing and AWK FName:Ann SName:Nice Salary 7 FName SName Salary John Great 585 Ann Nice 7 Text processing & AWK (2) File conversion problem File conversion problem #include <stdio.h> #include <stdlib.h> FILE *fin; char token[2]; char gettoken(void) {int i=; char c; do {c = getc(fin); if (c == EOF) return (EOF); } while (c <! ); Solution in C: 4 lines of code Text processing & AWK (3) Solution in AWK BEGIN {FS=": ";} NR == 1 {print $1, "\t", $3, "\t", $5;} {gsub(/,/, "., $6); print $2, "\t", $4, "\t", $6;} Text processing & AWK (4) Origins of AWK Authors of AWK Bell Labs, Murray Hill (New Jersey), Foto: Bell Labs, New Jersey (USA), 1977 AWK: Aho, Weinberger, Kernighan Platforms: Unix, MS DOS/Windows Similarity to C Text processing & AWK (5) Alfred Aho Peter Weinberger Brian Kernighan Text processing & AWK (6) Text processing and AWK 1

2 Aim of the lecture Agenda To present: Another programming paradigm (rule-based programming) Basics of AWK Fundamentals of AWK Simplest programs Patterns Variables Text processing & AWK (7) Text processing & AWK (8) Fundamental question Input file What is text? Field Jerzy Nawrocki 4389 I1 Jane Kowalski 4378 I2 Line Fields: $1, $2, $3,... Text processing & AWK (9) Text processing & AWK (1) Program structure Execution principle pattern1 {instruction1} pattern2 {instruction2} Processing rule Jerzy Nawrocki Jane Kowalski Adam Malinowski pattern1 {instruction1} pattern2 {instruction2} Text processing & AWK (11) Text processing & AWK (12) Text processing and AWK 2

3 Agenda Simplest programs Fundamentals of AWK Simplest programs Patterns Variables How many fields on the output? Jerzy Nawrocki 4389 I1 Jane Kowalski 4378 I2 $4== I1 { print $2, $1; } Nawrocki Jerzy Malinowski Adam Text processing & AWK (13) Text processing & AWK (14) Simplest programs Simplest programs How many fields on the output? Jerzy Nawrocki 4389 I1 Jane Kowalski 4378 I2 What field will be first? Jerzy Nawrocki 4389 I1 Jane Kowalski 4378 I2 $4== I1 { print $2, $1; } Jerzy Nawrocki 4389 I1 Nawrocki Jerzy Kowalski Jane Malinowski Adam Text processing & AWK (15) Text processing & AWK (16) Agenda Patterns Fundamentals of AWK Simplest programs Patterns Variables Begining and end of text Relations Compound patterns Range patterns Text processing & AWK (17) Text processing & AWK (18) Text processing and AWK 3

4 Begining and end of text Begining and end of text Jerzy Nawrocki Jane Kowalski BEGIN { print ; } $4== I2 { print $2, $1; } END { print ***** ; } Kowalski Jane ***** 4389 I I2 Text processing & AWK (19) Jerzy Nawrocki Jane Kowalski END { print ***** ; } $4== I2 { print $2, $1; } BEGIN { print ; } Kowalski Jane ***** 4389 I I2 Text processing & AWK (2) Relations Compound patterns $1 > $ or $1==1 $2==1 && and $1==1 && $2==1! not! $1==1 Text processing & AWK (21) Text processing & AWK (22) Compound patterns Agenda Jerzy Adam 4389 I1 Adam Kowalski 4378 I2 $4== I1 && $1== Adam { print $2, $1; } Fundamentals of AWK Simplest programs Patterns Variables Malinowski Adam Text processing & AWK (23) Text processing & AWK (24) Text processing and AWK 4

5 Stephen Kleene , Connecticut, USA 1934: Dr, Princeton Univ., (Alonzo Church) 1935: Univ. of Wisconsin- Madison (USA) : Inst. for Advanced Study, Princeton recursion theory 199: National Medal of Sci , Madison Text processing & AWK (25) Regular expressions Arithmetic expressions Value: Text Number Value( ) = 9 Regular expressions Value: Text SetOfCharacterStrings Value(/Ala Ola/) = {"Ala", "Ola"} Text processing & AWK (26) $, $1, $2,.. $, $1, $2,.. Begining String ~ /^ reg_exp / $1 ~ /^I$/ $1 ~ /^I/ Text processing & AWK (27) Text processing & AWK (28) $, $1, $2,.. $, $1, $2,.. Begining String ~ /^ reg_exp / End String ~ / reg_exp $/ $3 ~ /e$/ Begining String ~ /^ reg_exp / End String ~ / reg_exp $/ Substring String ~ / reg_exp / $3 ~ /e/ Text processing & AWK (29) Text processing & AWK (3) Text processing and AWK 5

6 $, $1, $2,.. $, $1, $2,.. Begining String ~ /^ reg_exp / End String ~ / reg_exp $/ Substring String ~ / reg_exp / $ ~ /ne/ Text processing & AWK (31) Begining String ~ /^ reg_exp / End String ~ / reg_exp $/ Substring String ~ / reg_exp / $ ~ / wyr_reg / = / wyr_reg / /ne/ Text processing & AWK (32) Special characters Special characters. Any character [ ] Set of characters \n New line \. Dot \ Quotation \ddd Character of octal code = ddd What does it mean? /^.$/ /[ ]/ /[-9]/ Text processing & AWK (33) Text processing & AWK (34) Complement of a set of characters Disjunction (or) reg_exp reg_exp What s the difference? [^... ] /[^-9]/ /^[-9]/ /im in/ Text processing & AWK (35) Text processing & AWK (36) Text processing and AWK 6

7 Parentheses and disjunction Parentheses change precedence of operators: 3*(4 + 5) = 3* 9 = 27 Distributive law: 3*(4 + 5) = 3*4 + 3*5 = = 27 (4 + 5)*3 = 4*3 + 5*3 = = 27 Select all lines for which the first field is a number AD 1984 $1 ~ /[-9]/ Distributivity of concatenation over disjunction: /i(m n)/ = /Lond(o y)n/ = /im in/ /London Londyn/ Text processing & AWK (37) Text processing & AWK (38) Select all lines for which the first field is a number tune: AD cents Select all lines for which the first field is a 1-digit number tune: 4tune: AD cents 32 cents $1 ~ /[-9]/ $1 ~ /^ [-9] $/ tune: 2 cents Text processing & AWK (39) Text processing & AWK (4) Select all lines for which the first field is a 1- or 2-digit number tune: 4tune: AD cents 32 cents Select all lines for which the first field is a 1- or 2-digit number tune: 4tune: 4tune: AD cents 32 cents 32 cents 12 euro $1 ~ /^( [-9] [-9][-9] )$/ $1 ~ /^( [-9] [-9][-9] )$/ 1 digit 2 digits cents 32 cents Text processing & AWK (41) Text processing & AWK (42) Text processing and AWK 7

8 $1 ~ /^( [-9] [-9][-9] [-9][-9][-9] )$/ Select all lines for which the first field is a number tune: 4tune: 4tune: AD cents 32 cents 32 cents 12 euro 1 digit 2 digits 3 digits [-9] = [-9] 1 [-9][-9] = [-9] 2 [-9][-9][-9] = [-9] [-9] 1 [-9] 2 [-9] 3... = [-9]+ Text processing & AWK (43) Text processing & AWK (44) $1 ~ /^ [-9]+ $/ Select all lines for which the first field is a number tune: 4tune: 4tune: AD cents 32 cents 32 cents 12 euro cents 32 cents 32 cents 12 euro Text processing & AWK (45) A non-empty sequence Can be a of w s. sequence of w s. w+ = w ww Empty string w* = w ww x = x x = x w+ = w w* = w* w x w* = x x w+ w*x = x w+x w( w ww )= w ww www wwww.. Text processing & AWK (46) Riddle Riddle What s its meaning? What on the output? Payment 21/11 ================ Nawrocki 16 Antczak 359 $2 ~ /^[-9][-9]*$/ $2 ~ /^[-9]+$/ Text processing & AWK (47) Text processing & AWK (48) Text processing and AWK 8

9 Agenda Variables Fundamentals of AWK Simplest programs Patterns Variables Variables introduced by a programmer (type: string of characters; initial value: empty string / zero) Built-in variables (standard meaning) Field variables $1, $(i+j-1),.. Text processing & AWK (49) Text processing & AWK (5) Some built-in variables NF number of fields in a row NR row number FILENAME file name with input data NR NF total Variables If you have a hammer, everything looks like a nail {total= total + NF;} END {print "Fields: ", total; print "Rows: ", NR;} Text processing & AWK (51) Text processing & AWK (52) Input file Summary Field Jerzy Nawrocki 4389 I1 Jane Kowalski 4378 I2 Line Fields: $1, $2, $3,... Text processing & AWK (53) Text processing & AWK (54) Text processing and AWK 9

10 Program structure Execution principle pattern1 {instruction1} pattern2 {instruction2} Processing rule Jerzy Nawrocki Jane Kowalski Adam Malinowski pattern1 {instruction1} pattern2 {instruction2} Text processing & AWK (55) Text processing & AWK (56) Regular expressions Summary (1)* = {ε, 1, 11, 111, } ε x = x ε L 1 L 2 = {xy: x L 1 y L 2 } L (r) = { ε } L n+1 (r) = L(r) L n (r) L n (r) = {xx x: x L(r) } n L(r*) = U L n (r) n= L(r*) = {ε,x, xx, xxx, : x L(r)} Text processing & AWK (57) At last! gawk -f prog.awk <in.txt >out.txt Other features of AWK: Compound instructions (if, while,..) Dynamic arrays Built-in functions (gsub,..) Text processing & AWK (58) Literature A. Aho, B. Kernighan, P. Weinberger, The AWK Programming Language, Addison-Wesley, Reading, J. Nawrocki, W. Complak, Wprowadzenie do przetwarzania tekstów w języku AWK, Pro Dialog 2 (1994), J. Cybulka, B. Jankowska, J.R. Nawrocki, Automatyczne przetwarzanie tekstów. AWK, Lex i YACC, Nakom, Poznań, 22. Text processing & AWK (59) Thank you for your attention! Text processing & AWK (6) Text processing and AWK 1

AWK: The Duct Tape of Computer Science Research. Tim Sherwood UC Santa Barbara

AWK: The Duct Tape of Computer Science Research. Tim Sherwood UC Santa Barbara AWK: The Duct Tape of Computer Science Research Tim Sherwood UC Santa Barbara Duct Tape Systems Research Environment Lots of simulators, data, and analysis tools Since it is research, nothing works together

More information

awk A UNIX tool to manipulate and generate formatted data

awk A UNIX tool to manipulate and generate formatted data awk A UNIX tool to manipulate and generate formatted data Alexander Voigt Technische Universität Dresden Institut für Kern- und Teilchenphysik Version_05_21 /01234/546 78994: IKTP Computing Kaffee 10 January

More information

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print In the simplest terms, grep (global regular expression print) will search input

More information

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 CMPSCI 250: Introduction to Computation Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 Regular Expressions and Their Languages Alphabets, Strings and Languages

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

COS 333: Advanced Programming Techniques

COS 333: Advanced Programming Techniques COS 333: Advanced Programming Techniques How to find me bwk@cs, www.cs.princeton.edu/~bwk 311 CS Building 609-258-2089 (but email is always better) TA's: Stephen Beard, Chris Monsanto, Srinivas Narayana,

More information

C H A P T E R Regular Expressions regular expression

C H A P T E R Regular Expressions regular expression 7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

More information

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

Introduction to Lex. General Description Input file Output file How matching is done Regular expressions Local names Using Lex

Introduction to Lex. General Description Input file Output file How matching is done Regular expressions Local names Using Lex Introduction to Lex General Description Input file Output file How matching is done Regular expressions Local names Using Lex General Description Lex is a program that automatically generates code for

More information

Lecture 5. sed and awk

Lecture 5. sed and awk Lecture 5 sed and awk Last week Regular Expressions grep egrep Today Stream manipulation: sed awk Sed: Stream-oriented, Non- Interactive, Text Editor Look for patterns one line at a time, like grep Change

More information

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing

More information

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

Compiler I: Syntax Analysis Human Thought

Compiler I: Syntax Analysis Human Thought Course map Compiler I: Syntax Analysis Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator Chapters 7-8 Assembly

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

2110711 THEORY of COMPUTATION

2110711 THEORY of COMPUTATION 2110711 THEORY of COMPUTATION ATHASIT SURARERKS ELITE Athasit Surarerks ELITE Engineering Laboratory in Theoretical Enumerable System Computer Engineering, Faculty of Engineering Chulalongkorn University

More information

Antlr ANother TutoRiaL

Antlr ANother TutoRiaL Antlr ANother TutoRiaL Karl Stroetmann March 29, 2007 Contents 1 Introduction 1 2 Implementing a Simple Scanner 1 A Parser for Arithmetic Expressions 4 Symbolic Differentiation 6 5 Conclusion 10 1 Introduction

More information

Scanner. tokens scanner parser IR. source code. errors

Scanner. tokens scanner parser IR. source code. errors Scanner source code tokens scanner parser IR errors maps characters into tokens the basic unit of syntax x = x + y; becomes = + ; character string value for a token is a lexeme

More information

CISC 181 Project 3 Designing Classes for Bank Accounts

CISC 181 Project 3 Designing Classes for Bank Accounts CISC 181 Project 3 Designing Classes for Bank Accounts Code Due: On or before 12 Midnight, Monday, Dec 8; hardcopy due at beginning of lecture, Tues, Dec 9 What You Need to Know This project is based on

More information

Command Scripts. 13.1 Running scripts: include and commands

Command Scripts. 13.1 Running scripts: include and commands 13 Command Scripts You will probably find that your most intensive use of AMPL s command environment occurs during the initial development of a model, when the results are unfamiliar and changes are frequent.

More information

Module 816. File Management in C. M. Campbell 1993 Deakin University

Module 816. File Management in C. M. Campbell 1993 Deakin University M. Campbell 1993 Deakin University Aim Learning objectives Content After working through this module you should be able to create C programs that create an use both text and binary files. After working

More information

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

More information

Reading 13 : Finite State Automata and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

More information

6.087 Lecture 1 January 11, 2010

6.087 Lecture 1 January 11, 2010 6.087 Lecture 1 January 11, 2010 Introduction to C Writing C Programs Our First C Program 1 What is C? Dennis Ritchie AT&T Bell Laboratories 1972 16-bit DEC PDP-11 computer (right) Widely used today extends

More information

The current topic: Scheme. Announcements. Numeric operators. Review: car, cdr, and cons

The current topic: Scheme. Announcements. Numeric operators. Review: car, cdr, and cons The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction Next up: Numeric operators, REPL, quotes, functions, conditionals Types and values

More information

Computer Science. General Education Students must complete the requirements shown in the General Education Requirements section of this catalog.

Computer Science. General Education Students must complete the requirements shown in the General Education Requirements section of this catalog. Computer Science Dr. Ilhyun Lee Professor Dr. Ilhyun Lee is a Professor of Computer Science. He received his Ph.D. degree from Illinois Institute of Technology, Chicago, Illinois (1996). He was selected

More information

Lecture 2: Regular Languages [Fa 14]

Lecture 2: Regular Languages [Fa 14] Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to jeffe@illinois.edu. But the Lord came down to see the city and the tower the people were building.

More information

PHP Tutorial From beginner to master

PHP Tutorial From beginner to master PHP Tutorial From beginner to master PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.

More information

SCR. Scripting. Goals of this lab: Prerequisites: LXB

SCR. Scripting. Goals of this lab: Prerequisites: LXB SCR Scripting Goals of this lab: To learn the basics of writing shell scripts. To gain insight in the gains with automating administrative work. To gain practical experience of automating administrative

More information

Lecture 18 Regular Expressions

Lecture 18 Regular Expressions Lecture 18 Regular Expressions Many of today s web applications require matching patterns in a text document to look for specific information. A good example is parsing a html file to extract tags

More information

Finite Automata and Formal Languages

Finite Automata and Formal Languages Finite Automata and Formal Languages TMV026/DIT321 LP4 2011 Lecture 14 May 19th 2011 Overview of today s lecture: Turing Machines Push-down Automata Overview of the Course Undecidable and Intractable Problems

More information

Compiler Construction

Compiler Construction Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

More information

Turing Machines, Part I

Turing Machines, Part I Turing Machines, Part I Languages The $64,000 Question What is a language? What is a class of languages? Computer Science Theory 2 1 Now our picture looks like Context Free Languages Deterministic Context

More information

Information Systems SQL. Nikolaj Popov

Information Systems SQL. Nikolaj Popov Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at Outline SQL Table Creation Populating and Modifying

More information

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459) Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459) Class Time: 6:00 8:05 p.m. (T,Th) Venue: WSL 5 Web Site: www.pbvusd.net/mis260 Instructor Name: Terrell Tucker Office: BDC 127

More information

Outline Basic concepts of Python language

Outline Basic concepts of Python language Data structures: lists, tuples, sets, dictionaries Basic data types Examples: int: 12, 0, -2 float: 1.02, -2.4e2, 1.5e-3 complex: 3+4j bool: True, False string: "Test string" Conversion between types int(-2.8)

More information

A Lex Tutorial. Victor Eijkhout. July 2004. 1 Introduction. 2 Structure of a lex file

A Lex Tutorial. Victor Eijkhout. July 2004. 1 Introduction. 2 Structure of a lex file A Lex Tutorial Victor Eijkhout July 2004 1 Introduction The unix utility lex parses a file of characters. It uses regular expression matching; typically it is used to tokenize the contents of the file.

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Python Programming: An Introduction to Computer Science Sequences: Strings and Lists Python Programming, 2/e 1 Objectives To understand the string data type and how strings are represented in the computer.

More information

Engineering Problem Solving with C++, Etter

Engineering Problem Solving with C++, Etter Engineering Problem Solving with C++, Etter Chapter 7 Strings 12-11-13 1 Strings Character Strings The string Class. 2 C style strings functions defined in cstring CHARACTER STRINGS 3 C Style Character

More information

Advanced Query for Query Developers

Advanced Query for Query Developers for Developers This is a training guide to step you through the advanced functions of in NUFinancials. is an ad-hoc reporting tool that allows you to retrieve data that is stored in the NUFinancials application.

More information

IV-1Working with Commands

IV-1Working with Commands Chapter IV-1 IV-1Working with Commands Overview... 2 Multiple Commands... 2 Comments... 2 Maximum Length of a Command... 2 Parameters... 2 Liberal Object Names... 2 Data Folders... 3 Types of Commands...

More information

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions Theory of Formal Languages In the English language, we distinguish between three different identities: letter, word, sentence.

More information

Java Basics: Data Types, Variables, and Loops

Java Basics: Data Types, Variables, and Loops Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables

More information

AP Computer Science Static Methods, Strings, User Input

AP Computer Science Static Methods, Strings, User Input AP Computer Science Static Methods, Strings, User Input Static Methods The Math class contains a special type of methods, called static methods. A static method DOES NOT operate on an object. This is because

More information

Jeri R. Hanly and Elliot B. Koffman, Problem Solving and Program Design in C, 7th ed., 2012, Addison- Wesley. (Required)

Jeri R. Hanly and Elliot B. Koffman, Problem Solving and Program Design in C, 7th ed., 2012, Addison- Wesley. (Required) University of Macau Faculty of Science and Technology Department of Computer and Information Science CISB110 Programming Science Syllabus 1 st Semester 2014/2015 Part A Course Outline Compulsory course

More information

In this lecture you will learn:

In this lecture you will learn: Data Types and Variables Imed Hammouda Department of Software Systems Tampere University of Technology Objectives In this lecture you will learn: What is a data type and how types are represented in C++.

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina This Lecture Database Systems Lecture 5 Natasha Alechina The language, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly and Begg chapter

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Fast string matching

Fast string matching Fast string matching This exposition is based on earlier versions of this lecture and the following sources, which are all recommended reading: Shift-And/Shift-Or 1. Flexible Pattern Matching in Strings,

More information

Automata and Formal Languages

Automata and Formal Languages Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

Fondamenti di C++ - Cay Horstmann 1

Fondamenti di C++ - Cay Horstmann 1 Fondamenti di C++ - Cay Horstmann 1 Review Exercises R10.1 Line 2: Can't assign int to int* Line 4: Can't assign Employee* to Employee Line 6: Can't apply -> to object Line 7: Can't delete object Line

More information

Biinterpretability up to double jump in the degrees

Biinterpretability up to double jump in the degrees Biinterpretability up to double jump in the degrees below 0 0 Richard A. Shore Department of Mathematics Cornell University Ithaca NY 14853 July 29, 2013 Abstract We prove that, for every z 0 0 with z

More information

So far we have considered only numeric processing, i.e. processing of numeric data represented

So far we have considered only numeric processing, i.e. processing of numeric data represented Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate

More information

Introduction to Microsoft Jet SQL

Introduction to Microsoft Jet SQL Introduction to Microsoft Jet SQL Microsoft Jet SQL is a relational database language based on the SQL 1989 standard of the American Standards Institute (ANSI). Microsoft Jet SQL contains two kinds of

More information

Visual Logic Instructions and Assignments

Visual Logic Instructions and Assignments Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.

More information

Regular Expression Syntax

Regular Expression Syntax 1 of 5 12/22/2014 9:55 AM EmEditor Home - EmEditor Help - How to - Search Regular Expression Syntax EmEditor regular expression syntax is based on Perl regular expression syntax. Literals All characters

More information

Evaluation of JFlex Scanner Generator Using Form Fields Validity Checking

Evaluation of JFlex Scanner Generator Using Form Fields Validity Checking ISSN (Online): 1694-0784 ISSN (Print): 1694-0814 12 Evaluation of JFlex Scanner Generator Using Form Fields Validity Checking Ezekiel Okike 1 and Maduka Attamah 2 1 School of Computer Studies, Kampala

More information

#1-12: Write the first 4 terms of the sequence. (Assume n begins with 1.)

#1-12: Write the first 4 terms of the sequence. (Assume n begins with 1.) Section 9.1: Sequences #1-12: Write the first 4 terms of the sequence. (Assume n begins with 1.) 1) a n = 3n a 1 = 3*1 = 3 a 2 = 3*2 = 6 a 3 = 3*3 = 9 a 4 = 3*4 = 12 3) a n = 3n 5 Answer: 3,6,9,12 a 1

More information

Forensic Analysis of Internet Explorer Activity Files

Forensic Analysis of Internet Explorer Activity Files Forensic Analysis of Internet Explorer Activity Files by Keith J. Jones keith.jones@foundstone.com 3/19/03 Table of Contents 1. Introduction 4 2. The Index.dat File Header 6 3. The HASH Table 10 4. The

More information

THE DEGREES OF BI-HYPERHYPERIMMUNE SETS

THE DEGREES OF BI-HYPERHYPERIMMUNE SETS THE DEGREES OF BI-HYPERHYPERIMMUNE SETS URI ANDREWS, PETER GERDES, AND JOSEPH S. MILLER Abstract. We study the degrees of bi-hyperhyperimmune (bi-hhi) sets. Our main result characterizes these degrees

More information

B A S I C S C I E N C E S

B A S I C S C I E N C E S B A S I C S C I E N C E S 10 B A S I C S C I E N C E S F I R S T S E M E S T E R C O U R S E S : H U M A N S T R U C T U R E A N D F U N C T I O N [ H S F I ] M O L E C U L A R B A S I S O F M E D I C

More information

Python Lists and Loops

Python Lists and Loops WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show

More information

CS106A, Stanford Handout #38. Strings and Chars

CS106A, Stanford Handout #38. Strings and Chars CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes

More information

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016 Master s Degree Course in Computer Engineering Formal Languages FORMAL LANGUAGES AND COMPILERS Lexical analysis Floriano Scioscia 1 Introductive terminological distinction Lexical string or lexeme = meaningful

More information

Form Validation. Server-side Web Development and Programming. What to Validate. Error Prevention. Lecture 7: Input Validation and Error Handling

Form Validation. Server-side Web Development and Programming. What to Validate. Error Prevention. Lecture 7: Input Validation and Error Handling Form Validation Server-side Web Development and Programming Lecture 7: Input Validation and Error Handling Detecting user error Invalid form information Inconsistencies of forms to other entities Enter

More information

590.7 Network Security Lecture 2: Goals and Challenges of Security Engineering. Xiaowei Yang

590.7 Network Security Lecture 2: Goals and Challenges of Security Engineering. Xiaowei Yang 590.7 Network Security Lecture 2: Goals and Challenges of Security Engineering Xiaowei Yang Roadmap What is security? Examples of secure systems Security properties Challenges What is security? System

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Social Science Research Lab American University, Washington, D.C. Web. www.american.edu/provost/ctrl/pclabs.cfm Tel. x3862 Email. SSRL@American.edu Course Objective This course provides

More information

Oracle Database 11g SQL

Oracle Database 11g SQL AO3 - Version: 2 19 June 2016 Oracle Database 11g SQL Oracle Database 11g SQL AO3 - Version: 2 3 days Course Description: This course provides the essential SQL skills that allow developers to write queries

More information

Database Normalization. Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center 415-600-7003 sarkarm@sutterhealth.

Database Normalization. Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center 415-600-7003 sarkarm@sutterhealth. Database Normalization Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center 415-600-7003 sarkarm@sutterhealth.org Definition A database is an organized collection of data whose content

More information

HP-UX Essentials and Shell Programming Course Summary

HP-UX Essentials and Shell Programming Course Summary Contact Us: (616) 875-4060 HP-UX Essentials and Shell Programming Course Summary Length: 5 Days Prerequisite: Basic computer skills Recommendation Statement: Student should be able to use a computer monitor,

More information

ESPResSo Summer School 2012

ESPResSo Summer School 2012 ESPResSo Summer School 2012 Introduction to Tcl Pedro A. Sánchez Institute for Computational Physics Allmandring 3 D-70569 Stuttgart Germany http://www.icp.uni-stuttgart.de 2/26 Outline History, Characteristics,

More information

Philadelphia University Faculty of Information Technology Department of Computer Science First semester, 2008/2009.

Philadelphia University Faculty of Information Technology Department of Computer Science First semester, 2008/2009. Philadelphia University Faculty of Information Technology Department of Computer Science First semester, 2008/2009 Course Syllabus Course Title: Programming Fundamentals Course Level: 1 Lecture Time: Course

More information

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

More information

HOMEWORK # 2 SOLUTIO

HOMEWORK # 2 SOLUTIO HOMEWORK # 2 SOLUTIO Problem 1 (2 points) a. There are 313 characters in the Tamil language. If every character is to be encoded into a unique bit pattern, what is the minimum number of bits required to

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Boolean Algebra Part 1

Boolean Algebra Part 1 Boolean Algebra Part 1 Page 1 Boolean Algebra Objectives Understand Basic Boolean Algebra Relate Boolean Algebra to Logic Networks Prove Laws using Truth Tables Understand and Use First Basic Theorems

More information

CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines. The Basis for Universal Computation CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

More information

Introduction to Programming

Introduction to Programming Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. 3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem

More information

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 7 Scanner Parser Project Wednesday, September 7 DUE: Wednesday, September 21 This

More information

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity. 7 Catalan Numbers Thomas A. Dowling, Department of Mathematics, Ohio State Uni- Author: versity. Prerequisites: The prerequisites for this chapter are recursive definitions, basic counting principles,

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages CHAPTER 3 Finite Automata and Regular Languages 3. Introduction 3.. States and Automata A finite-state machine or finite automaton (the noun comes from the Greek; the singular is automaton, the Greek-derived

More information

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

More information

A Typing System for an Optimizing Multiple-Backend Tcl Compiler

A Typing System for an Optimizing Multiple-Backend Tcl Compiler The following paper was originally published in the Proceedings of the Fifth Annual Tcl/Tk Workshop Boston, Massachusetts, July 1997 A Typing System for an Optimizing Multiple-Backend Tcl Compiler Forest

More information

Section 1.4 Place Value Systems of Numeration in Other Bases

Section 1.4 Place Value Systems of Numeration in Other Bases Section.4 Place Value Systems of Numeration in Other Bases Other Bases The Hindu-Arabic system that is used in most of the world today is a positional value system with a base of ten. The simplest reason

More information

SIMPLIFYING ALGEBRAIC FRACTIONS

SIMPLIFYING ALGEBRAIC FRACTIONS Tallahassee Community College 5 SIMPLIFYING ALGEBRAIC FRACTIONS In arithmetic, you learned that a fraction is in simplest form if the Greatest Common Factor (GCF) of the numerator and the denominator is

More information

03 - Lexical Analysis

03 - Lexical Analysis 03 - Lexical Analysis First, let s see a simplified overview of the compilation process: source code file (sequence of char) Step 2: parsing (syntax analysis) arse Tree Step 1: scanning (lexical analysis)

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Using Static Program Analysis to Aid Intrusion Detection

Using Static Program Analysis to Aid Intrusion Detection Using Static Program to Aid Intrusion Detection M. Egele M. Szydlowski E. Kirda C. Kruegel Secure Systems Lab Vienna University of Technology SIG SIDAR Conference on Detection of Intrusions and Malware

More information

C++ Language Tutorial

C++ Language Tutorial cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

Udacity cs101: Building a Search Engine. Extracting a Link

Udacity cs101: Building a Search Engine. Extracting a Link Udacity cs101: Building a Search Engine Unit 1: How to get started: your first program Extracting a Link Introducing the Web Crawler (Video: Web Crawler)... 2 Quiz (Video: First Quiz)...2 Programming (Video:

More information