C Code for If Evaluation

This is a discussion on C Code for If Evaluation within the C Programming forums, part of the General Programming Boards category; $IF exp $THEN "text" $ENDIF Consider above if statement, i need a C code to evaluate if statement(Nested if), the ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    5

    C Code for If Evaluation

    $IF exp $THEN
    "text"
    $ENDIF

    Consider above if statement, i need a C code to evaluate if statement(Nested if), the above eg will be given as a text file, purpose is to read this file , interpret it and do if Evaluation

    In this case it needs code to evaluate complex Expression too...


    Can anybody help me in this regard..

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    What you need for this is to create a grammer first. Without that you will not be able to do anything. Look through some compiler construction books.

    There might be chapter realated to grammer creation or something. Which tell you how to solve create a grammer.

    ssharish2005

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    It's grammar not grammer.

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    lex & yacc should help a little

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    5
    i set grammer first after checking grammer i gone for node in which left pointer points to true condition of if statement and right points to false. i tried this for simple if statement it was working fine. Now i am trying to do expression evaluation, if anybody have idea regarding this kindly do me favour

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,849
    > Now i am trying to do expression evaluation, if anybody have idea regarding this kindly do me favour
    Search the board, it's been done many times.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Posts
    326

    Being a smart ass

    Here's the C code for If evaluation:

    Code:
    if (condition) {
      // run statements
    }
    answer ur question?

    Expression evaluation? That could range from the simple (x <= 10?) to the complex... (ie, Regular Expressions)...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 08:34 AM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21