Docsity

OOPS - Regular Exression and FA, Study notes of Object Oriented Programming

Partial preview of the text

Download OOPS - Regular Exression and FA and more Study notes Object Oriented Programming in PDF only on Docsity!

Regular Expression and Finite

Automata

Regular Expressions

 (^) We use regular expressions to describe

tokens of a programming language.

 (^) Languages use regular expressions to

describe patterns

 (^) Each regular expression denotes a language.

 (^) A language denoted by a regular expression

is called as a regular set.

Regular Expressions (cont.)

Regular Definitions

Regular Definitions (cont.)

 (^) Unsigned numbers in Pascal

  • (^) 5280
  • (^) 32.
  • (^) 6.336E
  • (^) 1.894E- Regular Expression for these strings are as follows

Notational Shorthand

 (^) The unary postfix operator + means "one of

more instances of " (r)+ = rr*

 (^) The unary postfix operator? means "zero or

one instance of" r? = (r | ε)

Non-Deterministic Finite Automaton (NFA)

 (^) A non-deterministic finite automaton (NFA) is a mathematical model that consists of:

  • (^) S - a set of states
  • (^) S - a set of input symbols (alphabet)
  • (^) move – a transition function move to map state-symbol pairs to sets of states.
  • (^) s0 - a start (initial) state
  • (^) F – a set of accepting states (final states)  (^) ε - transitions are allowed in NFAs. In other words, we can move from one state to another one without consuming any symbol.  (^) A NFA accepts a string x, if and only if there is a path from the starting state to one of accepting states such that edge labels along this path spell out x.

NFA (Example)

Recognizer accepts input strings ab, aab, bab, aaab. aab is accepted by

a a b 0 0 1 2