Regular Expression

Definition

Regular expresssions are a more convenient way(than a regular grammar) to specify a regular language.

Construct a Regular Expression for a Language

in lex rule.
[chars] : Any number of the set of characters chars
[c1-c2] : Any character from c1 through c2
[^chars] : not chars
{category} : An instance of a previously named category
“string" : Exactly the specified string.
s1 | s2 : s1 or s2
a : zero or more a
a+ : one or more a
a? : zero or one a
* a{2,5} : 2 to 5 a

Construct the Language Denoted by a Regular Expression

Follow the rule.

Relation Between Regular Expression and Finite Automata

Always can change into DFA.

Automatic Construction of Finite Automata from Regular Expressions

Citation:

  • Aho, Lam, Sethi, & Ullman, Compilers: Principles, Techniques, and Tools
  • UT Austin CS375: Compilers by G.Novak.