Parse Input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mythran

    #1

    Parse Input

    Sorry, this was originally posted in VB.Net newsgroup, but I meant for it to
    be posted to the C# group initially, so I'm sorry for the multi-post, my
    mistake.
    -------------------------------------

    I have a console app that accepts input from the user. This input can be a
    command for the application, or a mathematical equation/formula. Currently,
    I'm using a trick I found on the Internet that creates a dynamic JScript
    assembly, loads it, which I then send any non-commands the user entered to a
    method that simply passes this input to the val() function. This works, but
    I'd like to go further and create my own (or somebody else's) val()
    equivalent. I understand that it may be difficult and take awhile to do,
    but every time I start on this trek, I just select all and delete because I
    confuse myself too much...anyone have any pointers??

    Thanks,
    Mythran



  • Fred Mellender

    #2
    Re: Parse Input

    Depending on exactly what you are trying to parse, your problem can be easy
    or difficult. The easiest solution is a "recursive descent parser". Use
    Google to find links. Search the usual places for implementations in C#.

    E.G. http://en.wikipedia.org/wiki/Recursive_descent_parser

    I wrote a more general purpose parser in C#, but it is probably overkill for
    your problem. http://www.frontiernet.net/~fredm/pa...istWebPage.htm



    "Mythran" <kip_potter@hot mail.comwrote in message
    news:D86A2B8C-FD3A-47E7-9CD5-5AE9D6D18B27@mi crosoft.com...
    Sorry, this was originally posted in VB.Net newsgroup, but I meant for it
    to be posted to the C# group initially, so I'm sorry for the multi-post,
    my mistake.
    -------------------------------------
    >
    I have a console app that accepts input from the user. This input can be
    a
    command for the application, or a mathematical equation/formula.
    Currently,
    I'm using a trick I found on the Internet that creates a dynamic JScript
    assembly, loads it, which I then send any non-commands the user entered to
    a
    method that simply passes this input to the val() function. This works,
    but
    I'd like to go further and create my own (or somebody else's) val()
    equivalent. I understand that it may be difficult and take awhile to do,
    but every time I start on this trek, I just select all and delete because
    I
    confuse myself too much...anyone have any pointers??
    >
    Thanks,
    Mythran
    >
    >
    >

    Comment

    • Brian Gideon

      #3
      Re: Parse Input

      On Jan 16, 1:36 pm, "Mythran" <kip_pot...@hot mail.comwrote:
      Sorry, this was originally posted in VB.Net newsgroup, but I meant for it to
      be posted to the C# group initially, so I'm sorry for the multi-post, my
      mistake.
      -------------------------------------
      >
      I have a console app that accepts input from the user.  This input can be a
      command for the application, or a mathematical equation/formula.  Currently,
      I'm using a trick I found on the Internet that creates a dynamic JScript
      assembly, loads it, which I then send any non-commands the user entered toa
      method that simply passes this input to the val() function.  This works,but
      I'd like to go further and create my own (or somebody else's) val()
      equivalent.  I understand that it may be difficult and take awhile to do,
      but every time I start on this trek, I just select all and delete because I
      confuse myself too much...anyone have any pointers??
      >
      Thanks,
      Mythran
      Those dynamic code variants make for easy work arounds, but they have
      a lot of disadvantages. The infix to postfix techniques are pretty
      easy, but if the expressions are too complex you'll have to explore
      the more advanced parsing techniques.

      There are a few compiler compilers out there for C#. ANTLR is one
      example. However, I think they have a big learning curve and it's
      probably overkill for an expression evaluator.

      I was *very* disappointed with the expression evaluators in C# I found
      the internet. Even the commercial ones were deficient in some way or
      another. I eventually wrote my own. Maybe I should release it to the
      public sometime...

      Comment

      • Mythran

        #4
        Re: Parse Input



        "Brian Gideon" <briangideon@ya hoo.comwrote in message
        news:f610224e-a96b-4b92-a6be-15e831357acf@21 g2000hsj.google groups.com...
        On Jan 16, 1:36 pm, "Mythran" <kip_pot...@hot mail.comwrote:
        >Sorry, this was originally posted in VB.Net newsgroup, but I meant for it
        >to
        >be posted to the C# group initially, so I'm sorry for the multi-post, my
        >mistake.
        >-------------------------------------
        >>
        >I have a console app that accepts input from the user. This input can be
        >a
        >command for the application, or a mathematical equation/formula.
        >Currently,
        >I'm using a trick I found on the Internet that creates a dynamic JScript
        >assembly, loads it, which I then send any non-commands the user entered
        >to a
        >method that simply passes this input to the val() function. This works,
        >but
        >I'd like to go further and create my own (or somebody else's) val()
        >equivalent. I understand that it may be difficult and take awhile to do,
        >but every time I start on this trek, I just select all and delete because
        >I
        >confuse myself too much...anyone have any pointers??
        >>
        >Thanks,
        >Mythran
        >
        Those dynamic code variants make for easy work arounds, but they have
        a lot of disadvantages. The infix to postfix techniques are pretty
        easy, but if the expressions are too complex you'll have to explore
        the more advanced parsing techniques.
        >
        There are a few compiler compilers out there for C#. ANTLR is one
        example. However, I think they have a big learning curve and it's
        probably overkill for an expression evaluator.
        >
        I was *very* disappointed with the expression evaluators in C# I found
        the internet. Even the commercial ones were deficient in some way or
        another. I eventually wrote my own. Maybe I should release it to the
        public sometime...
        Basically, I'm writing a console calculator that allows you to store
        variables, write function addons that can be called from the console app
        (which also needs to be parsed), set application commands (change
        background/foreground color in application), etc. I got the function call
        parsing to work (I successfully parse out these *commands* and run their
        associated code blocks, but I don't have the 'addon' portion working yet).

        <shrug Thanks for the reply :) I'll continue diggin and reviewing the
        link(s) posted by Fred too...

        Thanks again,
        Mythran


        Comment

        Working...