§ A rule to describe finite combinations of symbols (sequences) that are considered well-formed. § Regular expression has symbols and operators. § Symbols are defined in the alphabet. § The operators used in regular expressions are: § * (0 or more), § + (1 or more), § ? (0 or 1), § | (or). § [ ] to enclose sets of symbols without enumerating all of them, such as [0- 9] or [A-Z]. § Parenthesis.
| Examples * These definitions are NOT fully complete or correct. The purpose is only to exemplify RE. For instance, 07 matches as an integer, which will NOT be the case for our language. Token1 Regular Expression (rule) Example (word) digit 0 | 1 | 2 | 3 | ... | 9 3 integer digit+ 1945 fraction .digit+ .55 exponent e(+|-)?digit+ e+210 floatDraftOne integer(fraction?) (exponent?) 340.08e-14 floatDraftTwo {[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)([eE][-+]?[0- 9]+)?} binary 0b(0|1)+ 0b1010
slides can only be used as study material for the Compilers course at Universidad Panamericana. They cannot be distributed or used for another purpose.