CSC 312 Assignment Solution
CSC 312 Assignment Solution
^[+-]?[0-9]+$
b. Octal Integers:
^[+-]?[0-7]+$
Explanation: This matches an optional + or - sign, followed by one or more digits between 0
and 7.
^[a-zA-Z_][a-zA-Z0-9_]*$
Explanation: The first character must be a letter or underscore, followed by any number of
letters, digits, or underscores.
d. Integer Constant:
^[+-]?([0-9]+|0[0-7]*|0[xX][0-9a-fA-F]+)$
e. String Constant:
^"([^"\\]|\\.)*"$
Explanation: This matches a string enclosed in double quotes where the contents are either
any character except " and \, or an escaped character like \" or \\.
q2 {q0} {q2} ∅
{q1} ∅ {q2}
2. State Complexity: NFA can have fewer states than DFA, but DFA is simpler to implement
since it has a deterministic path for each input.
q0 q1 ∅ ∅
q1 q1, q2 q1 ∅
q2 ∅ q3 ∅
q3 ∅ ∅ (Accepting)
q0 q1 q3 ∅
q1 ∅ q2 ∅
q2 ∅ ∅ (Accepting)
q3 q4 ∅ ∅
q4 ∅ ∅ (Accepting)