Let's say I have two deterministic finite state automata represented by the following transition diagrams:
FSA for the keyword IF: IF
___ ___ _ / \ I / \ F // \\ >| 0 |----->| 1 |----->||2|| \___/ \___/ \\_//
FSA for identifier: [AZ] [A-Z0-9] *
------------ ___ | _ LET | / \ LET // \\<------ >| 0 |----->||1|| \___/ \\_
Which algorithm can I use to combine them into one deterministic finite state machine with three final states, represented by the following transition diagram:
----------------------- | LETTER BUT F OR NUM | -------- ___ | _ _ LET v _ | LET | / \ I // \\ F // \\----->// \\<------ >| 0 |----->||1||----->||2|| ||3||<-------- \___/ \\_// \\_//----->\\_//<------ | | NUM | NUM | | | ANY LETTER OTHER THAN I ------------ | --------------------------------------------- 1: ID 2: IF (IT ALSO AN ID, BUT THE KEYWORD IF HAS A HIGHER PRECEDENCE) 3: ID
source share