Parens group regular expressions as expected examples

This preview shows page 8 - 13 out of 20 pages.

Parens group regular expressions as expected Examples: (a|b)c matches …ac… and …bc… (a|b)*c matches …c… and …ac… and … bac… and … ababababbbabbabaaaababaababbbbc… and (a|b)?c matches …c… and …ac… and …bc…
Image of page 8

Subscribe to view the full document.

Regular Expression Extensions (e.g. Google Regular Expressions) Additional shorthand and notation [A-Z] = A|B|…|Z [ABC] = A|B|C \ is an escape character: \* matches …*… Languages and language extensions/packages Perl Java regular-expression packages Examples: Google Regular Expressions regexpal
Image of page 9
Regular Expressions & Finite State Machines abc a(b|c) ab* (a(b?c)) + a b c Note the special double-circle designation of an accepting state. a a a b b b a c c c
Image of page 10

Subscribe to view the full document.

Formal Definition of a Finite State Machine & a Finite State Transducer A deterministic finite state machine is a quintuple (Σ, S , s 0 ,δ, F ), where: Σ is the input alphabet (a finite, non-empty set of symbols). S is a finite, non-empty set of states. s 0 is an initial state, an element of S . δ is the state-transition function: δ : S × Σ → S . F is the set of final states, a (possibly empty) subset of S . A finite state transducer is a 6-tuple (Σ,Γ, S , s 0 ,δ, F ) as above except: Γ is the output alphabet (a finite, non-empty set of symbols). δ is the state-transition function: δ : S × Σ → S × Γ.
Image of page 11
Project 1: Lexical Analyzer Varieties Description Example <String> Any sequence of characters enclosed in single quotes. Two single quotes denote an apostrophe within the string. For line- number counts, count all '\n's within a string. A string token’s line number is the line where the string starts. 'quoted string' 'this isn''t two strings' '' (empty string) 'don''t forget about multi- line strings' <Keyword> One of the following four character sequences: Schemes , Facts , Rules , Queries. These keywords are case sensitive. Example: Schemesa is a single identifier and not a keyword and an identifier. <Identifier> An identifier is a letter followed by a sequence of zero or more letters or numbers. No underscores. Legal identifiers: Invalid identifiers: Identifier1 1stPerson Person Person_Name <Symbol> One of the following character sequences: : , < > = ( * ?
Image of page 12

Subscribe to view the full document.

Image of page 13
You've reached the end of this preview.
  • Winter '12
  • MichaelGoodrich
  • Regular expression, Finite State Machines, regular expressions

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern