Behaviour Diagrams UML

Similar documents
Regular Languages. MACM 300 Formal Languages and Automata. Formal Languages: Recap. Regular Languages

CSE450. Translation of Programming Languages. Lecture 20: Automata and Regular Expressions

Lexical Analysis. COMP 524, Spring 2014 Bryan Ward

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Lexical Analysis. Implementation: Finite Automata

Implementation of Lexical Analysis

CS Lecture 2. The Front End. Lecture 2 Lexical Analysis

Structure of a Compiler: Scanner reads a source, character by character, extracting lexemes that are then represented by tokens.

CSE 105 THEORY OF COMPUTATION

Implementation of Lexical Analysis

CS2 Language Processing note 3

Formal Languages and Compilers Lecture VI: Lexical Analysis

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

Lexical Analysis. Lexical analysis is the first phase of compilation: The file is converted from ASCII to tokens. It must be fast!

Compiler Design. 2. Regular Expressions & Finite State Automata (FSA) Kanat Bolazar January 21, 2010

Regular Languages and Regular Expressions

Implementation of Lexical Analysis. Lecture 4

Regular Expressions. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 9

Implementation of Lexical Analysis

Languages and Compilers

Chapter 3 Lexical Analysis

Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

Compiler course. Chapter 3 Lexical Analysis

Lexical Analysis. Lecture 3-4

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

CSE450. Translation of Programming Languages. Automata, Simple Language Design Principles

Dr. D.M. Akbar Hussain

Lexical Analysis. Chapter 2


Lexical Analysis - 2

Announcements! P1 part 1 due next Tuesday P1 part 2 due next Friday

CS415 Compilers. Lexical Analysis

6 NFA and Regular Expressions

CSE 105 THEORY OF COMPUTATION

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

CT32 COMPUTER NETWORKS DEC 2015

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

Lexical Analysis. Lecture 2-4

Concepts Introduced in Chapter 3. Lexical Analysis. Lexical Analysis Terms. Attributes for Tokens

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2]

Monday, August 26, 13. Scanners

Wednesday, September 3, 14. Scanners

CS 310: State Transition Diagrams

CSE 105 THEORY OF COMPUTATION

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Theory of Programming Languages COMP360

Requirements Checking for Object-Oriented Software Design with different Unified Modelling Language (UML) notations

Introduction to Lexical Analysis

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

CSE Theory of Computing Spring 2018 Project 2-Finite Automata

Scanners. Xiaokang Qiu Purdue University. August 24, ECE 468 Adapted from Kulkarni 2012

Homework 1 Due Tuesday, January 30, 2018 at 8pm

Introduction to Lexing and Parsing

COMP Logic for Computer Scientists. Lecture 25

lec3:nondeterministic finite state automata

CSE 105 THEORY OF COMPUTATION

Sequencing and control

CMPE 4003 Formal Languages & Automata Theory Project Due May 15, 2010.

Introduction to Software Testing Chapter 2, Sec#: 2.5 Graph Coverage for Specifications

CSCE 314 Programming Languages

CSE Theory of Computing Spring 2018 Project 2-Finite Automata

Theory of Computations Spring 2016 Practice Final Exam Solutions

Non-deterministic Finite Automata (NFA)

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

CSE 105 THEORY OF COMPUTATION

CS 432 Fall Mike Lam, Professor. Finite Automata Conversions and Lexing

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

CSE 413 Programming Languages & Implementation. Hal Perkins Winter 2019 Grammars, Scanners & Regular Expressions

KEY. A 1. The action of a grammar when a derivation can be found for a sentence. Y 2. program written in a High Level Language

THE INTERNATIONAL JOURNAL OF SCIENCE & TECHNOLEDGE

Automating Construction of Lexers

2010: Compilers REVIEW: REGULAR EXPRESSIONS HOW TO USE REGULAR EXPRESSIONS

Front End: Lexical Analysis. The Structure of a Compiler

Compiler Construction

The Language for Specifying Lexical Analyzer

CSE 413 Programming Languages & Implementation. Hal Perkins Autumn 2012 Grammars, Scanners & Regular Expressions

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

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

Answer All Questions. All Questions Carry Equal Marks. Time: 20 Min. Marks: 10.

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 5

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

Chapter 3: Lexing and Parsing

Lecture 2 Finite Automata

Theory and Compiling COMP360

CSEP 501 Compilers. Languages, Automata, Regular Expressions & Scanners Hal Perkins Winter /8/ Hal Perkins & UW CSE B-1

Lexical Analysis. Finite Automata. (Part 2 of 2)

Lexical Error Recovery

CS 314 Principles of Programming Languages

Concepts. Lexical scanning Regular expressions DFAs and FSAs Lex. Lexical analysis in perspective

Chapter 4. Lexical analysis. Concepts. Lexical scanning Regular expressions DFAs and FSAs Lex. Lexical analysis in perspective

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

HKN CS 374 Midterm 1 Review. Tim Klem Noah Mathes Mahir Morshed

Structure of Programming Languages Lecture 3

CSE Theory of Computing Fall 2017 Project 2-Finite Automata

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Transcription:

Behaviour Diagrams UML

Behaviour Diagrams Structure Diagrams are used to describe the static composition of components (i.e., constraints on what intstances may exist at run-time). Interaction Diagrams are used to describe the communication between the various components. Deployment Diagrams are used to describe the mapping between software artifacts and deployment targets. Behaviour Diagrams are used to describe the behaviour Of the whole application Of a particular process in an application Of a specific object in an application

Different Formalisms... We will look at different formalisms/languages for describing behaviour: Finite State Automata Activity Diagrams Statecharts

Finite State Automaton A finite automaton consists of Set of states Input alphabet (of input events ) Rules for changing state Start State (exactly 1) Accept State(s) (when used for language recognition) Formal definition, from Sipser's Theory of Computation

Example : Automatic Door Automatic Sliding Door

Specification The automatic door can be opened or closed. The sensor at the top of the door can send 4 types of signals: Nobody : There is nobody in front nor behind the doors. Front: There is somebody in front of the doors. Behind: There is somebody behind the doors. Both: There is somebody in front nor behind the doors. The door behaves as follows: The door opens when somebody is in front of the doors. The door closes only when nothing is in front or behind the doors. The door starts off closed.

Formal Specification The automatic door can be opened or closed. (state) The sensor at the top of the door can send 4 types of signals: (input alphabet) Nobody : There is nobody in front nor behind the doors. Front: There is somebody in front of the doors. Behind: There is somebody behind the doors. Both: There is somebody in front and behind the doors. The door behaves as follows: (transition) The door opens when somebody is in front of the doors. The door closes only when nothing is in front or behind the doors. The door starts off as closed. (start state)

Diagrams

Class Diagram of FSA

Describing Reactive System Behaviour: Output and Guards We can extend this by adding the notions of output and guards. Both of these additions can be found on the transition arrow. When a transition is triggered, it can broadcast an output event (or perform an action). Conditions can be imposed on transitions by adding guards. A transition can then only take place if the guard evaluates to true.

Note: total state (modal ++) Example

Executing/Simulating an DFA # initialize the state currentstate = getinitstate() # as long as there is input while environment.inputremaining(): # get input event from the environment currentevent = environment.getinput() # find applicable transition from currentstate currenttransition = None for transition in currentstate.transitions: if transition.inputevent == currentevent: currenttransition = transition break # assumes determinism! if currenttransition == None: print "unrecognized event, rejecting input" sys.exit() # or ignore: pass # generate output event environment.putoutput(transition.outputevent) # could be action # update the current state currentstate = transition.target if currentstate.type == TERM: print "input accepted" else: print "input rejected"

Non Deterministic vs. Deterministic A non-deterministic FSA (NFA) is a finite state automaton where there exists a least one state from which multiple transitions can be triggered by the same event. NFAs can always be transformed into a DFAs.

Regular Expressions Regular expressions can be compiled into finite state automata

What is a Regular Expression? A (text) pattern that describes (matches) a set of strings, according to certain syntax rules. As such, a Regular Expression specifies a language Examples of regular expressions include: Text starting with the letter a and finishing with the letter z. Text with at least one number, but not starting with the letter a or b. Text with a letter repeated three times in a row. Text contains the string abc exactly three times.

RegEx Constructs Most Regular Expression Language offer the following constructs. Sequence: abc (really shorthand for the sequence 'a' 'b' 'c') Alternatives: john bob Grouping: b(o a)b Quantification:? : 0 or 1 : (514)?555-5555 * : 0 or more : abc* + : 1 or more : abc+ Escape character to allow use of meta-characters: \?, \*,... Substitution: P = a*b+ Q = {P}xyz{P}

From RegEx to FSA ab((cd) (de))

Solution

a+b(c df*)(eh gi) RegExp

Corresponding FSA 1 2 3 4 5 6 7 8

Real-world Examples http://msdl.cs.mcgill.ca/people/hv/teaching/softwaredesign/ COMP304B2003/assignments/assignment3/solution/

The Big Picture: testing interactions

From Requirement

To automated Testing