Jump to content

Logical operator

- - - - -

  • Please log in to reply
10 replies to this topic

#1
jaiii

jaiii

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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.

#2
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript
So... what do you need help with? And is this for an assignment?

#3
JCoder

JCoder

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 245 posts
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
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript
Was that an answer to my question(s)?

#5
jaiii

jaiii

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Are you saying you need to create a parser/interpreter?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
jaiii

jaiii

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
Yes something like this.

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
jaiii

jaiii

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
Thanks for help

#10
JCoder

JCoder

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 245 posts
One of the best parser / lexer generators: ANTLR Parser Generator
Just write the grammar and the parser will be generated for you.

#11
jaiii

jaiii

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
Thankx I ytry it

By.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users