473,395 Members | 1,639 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,395 software developers and data experts.

Parser for conditions with logical operators

Hi,

before I rack my brain about something others have thought about, here
my question:

Is there any description how to write a parser that evaluates
expressions with logical operators like "(condition1 OR condition2 AND
(condition3 OR condition4))" in the right way?

Best regards,
André

Apr 11 '06 #1
2 3786

André Hänsel wrote:
Hi,

before I rack my brain about something others have thought about, here
my question:

Is there any description how to write a parser that evaluates
expressions with logical operators like "(condition1 OR condition2 AND
(condition3 OR condition4))" in the right way?

Best regards,
André


Check out this article at Wikipedia for an brief intro on
bottom-up-parsing: http://en.wikipedia.org/wiki/Bottom-up_parsing

Apr 12 '06 #2
Are you doing a template engine?

We parse <$TEST.TestName.otherparams> and write a cache file which will
contain this instead of the tag:

if($oForObj->Test_TestName($otherparam1,$otherparam2)){

<$TEST.ELSE> is replaced as '} else {'
and <$/TEST> as '}'

$oForObj is set to be the object that displays the template and would
therefore be expected to have the required method.

All the logic then goes into that method, and you can get as
complicated as you like.

I suppose you could do something similar with switch, but we haven't
yet.

Apr 12 '06 #3

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

Similar topics

3
by: Andrew Durdin | last post by:
In Python, you can override the behaviour of most operators for a class, by defining __add__, __gt__, and the other special object methods. I noticed that, although there are special methods for...
80
by: Christopher Benson-Manica | last post by:
Of course one can get the effect with appropriate use of existing operators, but a ^^ operator would make for nice symmetry (as well as useful to me in something I'm working on). Am I the only one...
2
by: ThunderMusic | last post by:
Hi, I have a value that contains flags that I must get using a bitmask. I tryied with the && operator, but the compiler outputs this error : Operator '&&' cannot be applied to operands of type...
6
by: Protoman | last post by:
I'm writing a program to calc truth tables of arguments to prove that they are logically valid. Currently, I have to tell the program to print a truth table, and check it by hand to prove it's...
10
by: Jonathan | last post by:
Hi all, I'm having an argument with a co-worker about the difference between the & and && operators when applied to boolean operands in C#. His point of view is that the expression (false &...
9
by: marko | last post by:
/* code start */ int a = 0; /* expected evaluation and excution order with precedence in mind /* False(3) , True(1), False(2) */ if ( (a=1) == 0 || 0 != 1 && (a =2) == 1) putchar('T');...
1
by: Kosmos | last post by:
So apparently my last post wasn't for MS Access specific VBA...the following forum is and helps with MS Access If statements in this specific link...suprisingly I found it hard to simply find about...
13
by: TheLostLeaf | last post by:
Hi, Does anyone know if these 2 code segments would operate the same way. for instance if the first condition fails does it bother to check the second? if (MyList.Count 0 && CheckDate) {
19
by: werdan | last post by:
G'day all I'm bitmapping integers to store combined boolean values and have hit a bit of a snag. I want to be able to turn off certain bits if they they match in a number but not turn them on...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.