Hi,
Can enybody help me ?
I urgent need :
logic expresion vhere logic operateor (> < == != AND OR >= <=) in logical expresion is substitute expresion (function or array)
for example
1 > 3
1 op() 3
where op is function returns operator >
or
1 <expresion> 3
epresion can be function,array,value,macro... etc.
thanka very much.
10 replies to this topic
#1
Posted 14 June 2010 - 12:56 AM
|
|
|
#2
Posted 14 June 2010 - 01:11 AM
So... what do you need help with? And is this for an assignment?
#3
Posted 14 June 2010 - 01:18 AM
You cannot do it in C. Operators and functions are not first class objects in C/C++. They cannot be passed as arguments to / from functions.
#4
Posted 14 June 2010 - 01:22 AM
Was that an answer to my question(s)?
#5
Posted 14 June 2010 - 01:42 AM
No
I need create logical expresuion from parts:
for examle:
bool a= 1> 3
int i1=1;
int i2=3;
Byte op ='>'
int b= I1 op I2 or enythink like this
I need create logical expresuion from parts:
for examle:
bool a= 1> 3
int i1=1;
int i2=3;
Byte op ='>'
int b= I1 op I2 or enythink like this
#6
Posted 14 June 2010 - 02:48 AM
Are you saying you need to create a parser/interpreter?
#7
Posted 14 June 2010 - 03:00 AM
Yes something like this.
#8
Posted 14 June 2010 - 03:28 AM
To do that, you'll need to create a tokenizer, along with a parser. Then, you'll have to analyze the tokens to decide what to do with them.
1<3 has three tokens: "1", "<", and "3". "1" would need to be converted to an integer, as would "3". "<" would then have to be interpreted as an operator and you would need to call the corresponding operator on the two converted integers.
1<3 has three tokens: "1", "<", and "3". "1" would need to be converted to an integer, as would "3". "<" would then have to be interpreted as an operator and you would need to call the corresponding operator on the two converted integers.
#9
Posted 14 June 2010 - 03:38 AM
Thanks for help
#10
Posted 14 June 2010 - 09:39 AM
One of the best parser / lexer generators: ANTLR Parser Generator
Just write the grammar and the parser will be generated for you.
Just write the grammar and the parser will be generated for you.
#11
Posted 14 June 2010 - 12:37 PM
Thankx I ytry it
By.
By.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









