473,785 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jan 16 '08 #1
3 2617
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" <ki********@hot mail.comwrote in message
news:D8******** *************** ***********@mic rosoft.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

Jan 16 '08 #2
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...
Jan 17 '08 #3


"Brian Gideon" <br*********@ya hoo.comwrote in message
news:f6******** *************** ***********@21g 2000hsj.googleg roups.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
Jan 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16311
by: entoone | last post by:
I'm getting the following error Parse error: parse error, expecting `','' or `';'' in /home/notarywe/public_html/php/update2.php on line 108 Here is line 108 <input type="text" name="ud_first" value="<? echo "$first" size="20"?>"></td> Any help would be appreciated.
3
2932
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
3
15063
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title> </head> <style type="text/css">
22
872
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to tokenize the comma separated values.I used strtok function reading line by line using fgets.but it gives some weird behavior.It doesnot stripout the "" fully.Could any body have sample code for the same so that it will be helfful for my...
4
6017
by: learning_C++ | last post by:
Hi, I try to use input = new istrstream(argv,strlen(argv)); in my code, but it always says error: " error: parse error before `(' token" please help me! Thanks, #include <map>
3
3133
by: Nobody | last post by:
I'm trying to put together code to deal with a SOAP with attachements response, and I'd like to process the response in a single pass. The SOAP with attachments specification returns XML in a MIME message, so it looks like this: --4389012.48390 Content-Type: text/xml <?xml version="1.0" encoding="UTF-8"?> <soap-env:Envelope
2
3415
plumpnation
by: plumpnation | last post by:
I have now got this bulky piece of script working, it reads the form correctly, which sends the request to the web service using SOAP. It conforms to their DTD and the web service then responds and sends an xml document back to the page. I would very much like the contents of the form to be entered into an sql database as it is sent to the web service, as their reply does not contain the full details filled into the form. Aside from the...
4
3302
by: Peter Proost | last post by:
Hi group, it's been a long time since the last time I've been here but I have a question. I'm working with timespan.parse for calculating a duration, I have to add strings which are in the following format 15:36:12 ==Hours, minutes, seconds but sometimes there is a string like 55:26:32 ==which is correct cause the production machine was busy for 55 hours, but the timespan.parse crashes on this value because it expects 2.7:26:32. I've...
5
64651
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
1
64196
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.