11import { useContext , useEffect , useState } from "react" ;
22import { DraggableStateModel , RowModel , TransitionModel } from "../models" ;
3- import { NfaToDfaProps } from "./props/NfaToDfaProps" ;
43import { NullClosure } from "./components/nfaToDfa/NullClosure" ;
54import { NullClosureProps } from "./components/nfaToDfa/props/NullClosureProps" ;
65import { PossibleTransitionValues } from "../consts/PossibleTransitionValues" ;
@@ -9,6 +8,11 @@ import { ModifiedTableProps } from "./components/nfaToDfa/props/ModifiedTablePro
98import { ResultantDfa } from "./components/nfaToDfa/ResultantDfa" ;
109import { ResultantDfaProps } from "./components/nfaToDfa/props/ResultantDfaProps" ;
1110import { DataContext } from "../components/Editor" ;
11+ import {
12+ NullCLosureStateId ,
13+ ModifiedTableStateId ,
14+ ResultantDfaStateId ,
15+ } from "../consts/StateIdsExtensions" ;
1216
1317export const NfaToDfa = ( ) => {
1418 console . log ( "re rendering NfaToDfa" ) ;
@@ -45,7 +49,7 @@ export const NfaToDfa = () => {
4549 . toString ( )
4650 . split ( " " )
4751 . filter ( ( key ) => key !== "" )
48- . map ( ( tv ) => tv . replace ( tv , tv + "nc" ) )
52+ . map ( ( tv ) => tv . replace ( tv , tv + NullCLosureStateId ) )
4953 . join ( " " ) ?? row [ key === "^" ? "nul" : key ] ,
5054 ] )
5155 ) ,
@@ -56,7 +60,7 @@ export const NfaToDfa = () => {
5660 const nullClosureStatesUnique = dataContext . states . map ( ( state ) => {
5761 return {
5862 ...state ,
59- id : ` ${ state . id } nc` ,
63+ id : state . id + NullCLosureStateId ,
6064 } ;
6165 } ) ;
6266 console . log ( "nullClosureStatesUnique" , nullClosureStatesUnique ) ;
@@ -65,8 +69,8 @@ export const NfaToDfa = () => {
6569 ( transition ) => {
6670 return {
6771 ...transition ,
68- start : ` ${ transition . start } nc` ,
69- end : ` ${ transition . end } nc` ,
72+ start : transition . start + NullCLosureStateId ,
73+ end : transition . end + NullCLosureStateId ,
7074 } ;
7175 }
7276 ) ;
@@ -99,7 +103,7 @@ export const NfaToDfa = () => {
99103 . toString ( )
100104 . split ( " " )
101105 . filter ( ( key ) => key !== "" )
102- . map ( ( tv ) => tv . replace ( "nc" , "mtt" ) )
106+ . map ( ( tv ) => tv . replace ( NullCLosureStateId , ModifiedTableStateId ) )
103107 . join ( " " ) ?? row [ key === "^" ? "nul" : key ] ,
104108 ] )
105109 ) ,
@@ -120,7 +124,9 @@ export const NfaToDfa = () => {
120124 . toString ( )
121125 . split ( " " )
122126 . filter ( ( key ) => key !== "" )
123- . map ( ( tv ) => tv . replace ( "mtt" , "ntd" ) )
127+ . map ( ( tv ) =>
128+ tv . replace ( ModifiedTableStateId , ResultantDfaStateId )
129+ )
124130 . join ( " " ) ?? row [ key === "^" ? "nul" : key ] ,
125131 ] )
126132 ) ,
0 commit comments