|
|
Line 1: |
Line 1: |
| __NOTOC__ | | __NOTOC__ |
| + | <div class="section-container auto" data-section> |
| + | <div class="section"> |
| + | <p class="title" data-section-title>Problem</p> |
| + | <div class="content" data-section-content> |
| + | <!-- ====================== START OF PROBLEM ====================== --> |
| + | Compute the non-deterministic finite automaton (NFA) by using Thompson's algorithm. Compute the minimal deterministic finite automaton (DFA).<br/>The alphabet is Σ = { a, b }. Indicate the number of processing steps for the given input string. |
| + | * <nowiki>G = { ab, ab*, a|b }</nowiki>, input string = abaabb |
| + | <!-- ====================== END OF PROBLEM ====================== --> |
| + | </div> |
| + | </div> |
| + | <div class="section"> |
| + | <p class="title" data-section-title>Solution</p> |
| + | <div class="content" data-section-content> |
| + | <!-- ====================== START OF SOLUTION ====================== --> |
| Compute the non-deterministic finite automaton (NFA) by using Thompson's algorithm. Compute the minimal deterministic finite automaton (DFA).<br/>The alphabet is Σ = { a, b }. Indicate the number of processing steps for the given input string. | | Compute the non-deterministic finite automaton (NFA) by using Thompson's algorithm. Compute the minimal deterministic finite automaton (DFA).<br/>The alphabet is Σ = { a, b }. Indicate the number of processing steps for the given input string. |
| * <nowiki>G = { ab, ab*, a|b }</nowiki>, input string = abaabb | | * <nowiki>G = { ab, ab*, a|b }</nowiki>, input string = abaabb |
− |
| |
− | == NFA ==
| |
− |
| |
| The following is the result of applying Thompson's algorithm. State '''3''' recognizes the first expression (token '''T1'''); state '''8''' recognizes token '''T2'''; and state '''14''' recognizes token '''T3'''. | | The following is the result of applying Thompson's algorithm. State '''3''' recognizes the first expression (token '''T1'''); state '''8''' recognizes token '''T2'''; and state '''14''' recognizes token '''T3'''. |
| | | |
Line 11: |
Line 22: |
| </runphp> | | </runphp> |
| | | |
− | == DFA ==
| + | Applying the determination algorithm to the above NFA, the following determination table is obtained: |
− | | |
− | Determination table for the above NFA:
| |
| | | |
| {| cellspacing="2" | | {| cellspacing="2" |
Line 161: |
Line 170: |
| | | |
| The input string ''abaabb'' is, after 9 steps, split into three tokens: '''T1''' (corresponding to lexeme ''ab''), '''T2''' (''a''), and '''T2''' (''abb''). | | The input string ''abaabb'' is, after 9 steps, split into three tokens: '''T1''' (corresponding to lexeme ''ab''), '''T2''' (''a''), and '''T2''' (''abb''). |
| + | <!-- ====================== END OF SOLUTION ====================== --> |
| + | </div> |
| + | </div> |
| + | </div> |
| | | |
| [[category:Teaching]] | | [[category:Teaching]] |
| [[category:Compilers]] | | [[category:Compilers]] |
| [[en:Theoretical Aspects of Lexical Analysis]] | | [[en:Theoretical Aspects of Lexical Analysis]] |