Solved

Regular Expression... Evaluator?

Posted on 2004-10-21
400 Views
Last Modified: 2013-11-17
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++.
0
Question by:gabriella_leveron
    8 Comments
     
    LVL 45

    Expert Comment

    by:Kdo

    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
    0
     

    Author Comment

    by:gabriella_leveron
    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.
    0
     
    LVL 45

    Expert Comment

    by:Kdo


    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
    0
     
    LVL 12

    Expert Comment

    by:andrewjb
    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..
    0
     
    LVL 9

    Expert Comment

    by:Cayce
    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.
    0
     

    Author Comment

    by:gabriella_leveron
    I actually have to write the code for it :S
    0
     
    LVL 9

    Expert Comment

    by:Cayce
    So, is it homework/school project or not?
    0
     
    LVL 9

    Accepted Solution

    by:
    This links could give you some insight:
    http://fpl.cs.depaul.edu/cpitcher/csc448/
    http://www3.sympatico.ca/dbiggar/
    http://www.cs.vassar.edu/~cs240/
    http://www.cs.unc.edu/~anderson/teach/comp181/comp181.html
    http://www.clemburg.com/resources/MS_Word_Regexes_and_Special_Chars.html
    http://www.clemburg.com/resources/find_with_tso.html
    http://enterprise.ic.gc.ca/~jfriedl/regex/

    Guess you'll have to research in your school/local library for most of what you want to do.
    There's tons of books that go thru the subjects you need (http://theory.lcs.mit.edu/~iandc/References/bruggemann-kleinw1998:229.html). Coding will be the easiest part, but you need to research about the concepts behing of what you are asking for. Don't expect EE experts to give you all the code you need.

    I hope the papers and college courses I point you to will be of any help.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now