Parse Input

M

Mythran

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
 
B

Brian Gideon

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...
 
M

Mythran

Brian Gideon said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top