CyberZHG / toolbox

https://cyberzhg.github.io/toolbox/ Encoding and parsing tools.
GNU General Public License v3.0
949 stars 81 forks source link

min-dfa web is working but lexical.js is not in some cases #32

Open arater opened 11 months ago

arater commented 11 months ago

I got your lexical.js file and create main function to test it and i have print function to print mn.dfa ` function printMinDfa(node, visited = new Set()) { if (!node || visited.has(node.id)) { return; }

visited.add(node.id);
console.log(`State ID: ${node.id}, Type: ${node.type}`);

if (node.edges) {
    node.edges.forEach(edge => {
        console.log(`  Transition on '${edge[0]}' to State ID: ${edge[1].id}`);
        printMinDfa(edge[1], visited);
    });
}

} `

But for instance my regex is "abc+d*x" My output is State ID: 1, Type: Transition on 'a' to State ID: 2 State ID: 2, Type: Transition on 'b' to State ID: 3 State ID: 3, Type: Transition on 'c' to State ID: 4 State ID: 4, Type: Transition on 'c' to State ID: 4 Transition on 'd' to State ID: 5 State ID: 5, Type: Transition on 'd' to State ID: 5 Transition on 'x' to State ID: 6 State ID: 6, Type: accept Transition on 'x' to State ID: 6

But it is not correct i do not have transition from state4 to state6 if there is no "d" char, but in your website https://cyberzhg.github.io/toolbox/min_dfa it is working fine. Are you using any other resources to convert regex to dfa. Please let me know because this is also part of my thesis process.