473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Parser program

Hi all, i need one help from u.when u give expression like 10+4*2-6/8 the expression should be evaluated in hierarchy order and the result will be displayed. the expression may be any longer or shorter.the operands used are +,-,*,/,mod, pow..please any one help in writing coding on this...
Mar 20 '07 #1
7 1193
Motoma
3,237 Expert 2GB
Hi all, i need one help from u.when u give expression like 10+4*2-6/8 the expression should be evaluated in hierarchy order and the result will be displayed. the expression may be any longer or shorter.the operands used are +,-,*,/,mod, pow..please any one help in writing coding on this...
I'm not sure what you are asking for; please elaborate on your problem, and ask a question.
Mar 20 '07 #2
code green
1,726 Expert 1GB
In any computer language, to force the order of precedence of calculations use brackets () as these have the highest order of precedence in computers and mathematics
Mar 21 '07 #3
steven
143 100+
As far as I was aware, languages usually take mathematical precedence in such calculations, doing multiplications, divisions, etc, then addition and subtraction.

You can force precedence with the use of brackets though.
Mar 21 '07 #4
i know, there ia already predefined function that calculate the expression, but i need the program that perform the calculation
Mar 22 '07 #5
code green
1,726 Expert 1GB
i know, there ia already predefined function that calculate the expression, but i need the program that perform the calculation
If you know, why are you asking us? And what are you asking for? A PHP predefined function or a user defined function? Both seem pointless and inefficient because it can be done using basic mathematics
Mar 22 '07 #6
ronverdonk
4,258 Expert 4TB
What you are asking is to write an interpreter written in an interpreter language, i.e. PHP. That is not a good idea. If you want to develop such an interpreter you should use a compiled language, like C.
Or is this just an exercide for a class assignment?

Ronald :cool:
Mar 23 '07 #7
10+4*2-6/8

here evaluation order will be

step1-- 4*2
step2-- 6/8
step3-- 10+step1
step4--step3-step2

so accordingly arrange your variables.........
Mar 23 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Himanshu Garg | last post by:
Hello, I am using HTML::Parser to extract text from html pages from http://bbc.co.uk/urdu/ However the encoding of the input text seems to change to some unknown encoding in the output. The...
1
by: Vineeth | last post by:
Hi, I am using xerces2.6.0 and am developing a program for converting an xml document to a text file. My program is extending the DefaultHandler. The first problem I am facing is that even...
1
by: Patrick Gunia | last post by:
Hi, i´m trying to build a xml - parser, which should simply list all used tokens an dattributes including their values. So far, so good, this works, but now i try to check for illegal phrases in...
5
by: qqcq6s59 | last post by:
Hi all I am a newbie and I just saw a ongoing thread on Fileprocessing which talks abt config parser. I have writen many pyhton program to parse many kind of text files by using string module and...
2
by: friend.05 | last post by:
I have never used xml. how can I run XML parser? I am having to file *.xml amd *.phps (xml parser). But how should I run this files. Do I need any software or not. By using xml parser I...
4
by: Greg B | last post by:
Well since getopt() doesn't seem to be compatible with Windows, and the free implementation of it for Windows that I found still had some annoying restrictions, I thought I'd whip up a simple...
4
by: mitsura | last post by:
Hi, I think I ran into a bug in the XML SAX parser. part of my program consist of reading a rather large XML file (about 10Mb) containing a few thousand elements. I have the following...
7
by: (Jamie Andrews) | last post by:
For a research project, we're looking for a reliable parser for C that will take an ANSI C program and yield a tree representation of the program (as a Java or C++ object). Of course a grammar...
6
by: Mike C# | last post by:
Hi all, Can anyone recommend a good and *easy to use* lexer and parser generator? Preferably one that was written specifically for VC++ and not mangled through 20 different platforms. I've had...
18
by: Just Another Victim of the Ambient Morality | last post by:
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.