0

I have a regular expression in postfix form and I have to convert it to epsilon-NFA. I have read a lot of codes but it was complex, hard and I couldn't understand.

My question is there an express simple code(c#, c++) to do this or even a pseudo code could helps me?

Arun A S
  • 6,421
  • 4
  • 29
  • 43
lole
  • 1
  • 1
  • 3
  • What you are trying to achieve *is* complex, that's why the code you have found is complex. It really helps if you know the actual theory and math behind it all, because then the complex code will no longer be as complex to you. – Some programmer dude May 01 '15 at 01:23
  • Convert to infix, then run Thompson or Berry-Sethi (lesser-known, but epsilon-free and uses exactly `n+1` states where `n` is size of the regex)? – G. Bach May 01 '15 at 01:59
  • @G.Bach my regular expression is in infix form and I have to convert to postfix then to nfa , is there a way or code to convert to nfa directly without transit over e-nfa ? thank you – lole May 01 '15 at 02:50
  • Russ Cox wrote an excellent essay on reducing regexes to DFAs, which includes a lot of C++ code. https://swtch.com/~rsc/regexp/regexp1.html – rici May 01 '15 at 03:53
  • The Thompson algorithm gives you an epsilon-NFA, then you would run epsilon-elimination (basically, calculate the epsilon-closure for the NFA) and after that, power set construction. Alternatively, use Berry-Sethi to start out with an epsilon-free NFA, then do the powerset construction. rici's link seems to give a great overview over implementations that are in use in production systems as well. Why you would want to convert to postfix first I don't know unless this is some exercise requirement; only seems to complicate the issue. – G. Bach May 01 '15 at 09:41

0 Answers0