Short example of regular expression converted to a state machine?

A rather convenient way to help look at this to use python’s little-known re.DEBUG flag on any pattern: >>> re.compile(r'<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>’, re.DEBUG) literal 60 subpattern 1 in range (65, 90) max_repeat 0 65535 in range (65, 90) range (48, 57) at at_boundary max_repeat 0 65535 not_literal 62 literal 62 subpattern 2 min_repeat 0 65535 any None … Read more

How to implement a FSM – Finite State Machine in Java

The heart of a state machine is the transition table, which takes a state and a symbol (what you’re calling an event) to a new state. That’s just a two-index array of states. For sanity and type safety, declare the states and symbols as enumerations. I always add a “length” member in some way (language-specific) … Read more