gabriella_leveron
asked on
Regular Expression... Evaluator?
I was assigned a project, looks pretty simple but I just don't know where to begin!
In a command window, enter a regular expression...
Then take that RE and change it to a NFA-e, then that NFA-e to NFA, then that NFA to DFA, then that DFA to MDFA... and that result, I should create a file wich I can open in AFER (don't know if you've heard of it...)
Anyways, I need someone to give me a very good push; code is, of course, quite welcome... keep in mind it is strictly c/c++.
In a command window, enter a regular expression...
Then take that RE and change it to a NFA-e, then that NFA-e to NFA, then that NFA to DFA, then that DFA to MDFA... and that result, I should create a file wich I can open in AFER (don't know if you've heard of it...)
Anyways, I need someone to give me a very good push; code is, of course, quite welcome... keep in mind it is strictly c/c++.
ASKER
I've done Mathematical Expression Evaluators before...
But that is what has me, confused I guess...
When I say RE I mean the user will type in something like (11+0)*(00+1)* and then continue with what i told ya in the original post...
I'm not even crawling with this, dude! If it were a homework assignment, like simple homework, I wouldn't bother posting, I would google.
But that is what has me, confused I guess...
When I say RE I mean the user will type in something like (11+0)*(00+1)* and then continue with what i told ya in the original post...
I'm not even crawling with this, dude! If it were a homework assignment, like simple homework, I wouldn't bother posting, I would google.
Cool. Then you should be off to a good start. Build the tree such that it can be traversed to produce RPN. From there the only difficulty should be in the understanding of each of the other notations. (Sorry -- I don't know them all.)
Kent
Do you want to actually write the code, or just produce the outcome? The boost library has RE handling routines which I think are quite flexible..
Check out this link:
http://www.undu.com/Articles/021016.html
It shows how to use the Microsoft VBScript Regular Expression library in Delphi. The procedure to use it under BCB is the same (just the code changes from Pascal to C++, no big deal). This library comes with almost every version of windows.
http://www.undu.com/Articles/021016.html
It shows how to use the Microsoft VBScript Regular Expression library in Delphi. The procedure to use it under BCB is the same (just the code changes from Pascal to C++, no big deal). This library comes with almost every version of windows.
ASKER
I actually have to write the code for it :S
So, is it homework/school project or not?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi gabriella_leveron,
This looks like a homework assignment, so I'll nudge a little and you can follow iwht more questions. :)
The first thing that you're going to have to do is "tokenize" the items in the expression. You can grab them "on the fly" from the input stream or build a list. I'd suggest building a list.
TAN(1+SQRT(PI)) /* A meaningless calculation, but a valid example */
Token[0] = "TAN"
Token[1] = "("
Token[2] = "1"
Token[3] = "+"
etc...
Then convert this list of tokens into a tree structure that when perused, accesses the items in NFA-e form.
First we walk, then we run.... :)
Kent