comparison lwasm/expr.c @ 226:c8787fad0f9f

Added && and || to lwasm
author lost
date Fri, 12 Jun 2009 00:06:13 +0000
parents bae1e3ecdce1
children 1bdb4e256fc9
comparison
equal deleted inserted replaced
225:058f18119025 226:c8787fad0f9f
624 { LWASM_OPER_TIMES, "*", 150 }, 624 { LWASM_OPER_TIMES, "*", 150 },
625 { LWASM_OPER_DIVIDE, "/", 150 }, 625 { LWASM_OPER_DIVIDE, "/", 150 },
626 { LWASM_OPER_MOD, "%", 150 }, 626 { LWASM_OPER_MOD, "%", 150 },
627 { LWASM_OPER_INTDIV, "\\", 150 }, 627 { LWASM_OPER_INTDIV, "\\", 150 },
628 628
629 // boolean AND/OR
630 { LWASM_OPER_AND, "&&", 25 },
631 { LWASM_OPER_OR, "||", 25 },
632
633 // bitwise ops
629 { LWASM_OPER_BWAND, "&", 50 }, 634 { LWASM_OPER_BWAND, "&", 50 },
630 { LWASM_OPER_BWOR, "|", 50 }, 635 { LWASM_OPER_BWOR, "|", 50 },
631 636
632 // this collides with the unary complement but shouldn't cause 637 // this collides with the unary complement but shouldn't cause
633 // any trouble because of operator precedence 638 // any trouble because of operator precedence
650 return 0; 655 return 0;
651 656
652 // expecting an operator here 657 // expecting an operator here
653 for (opern = 0; operators[opern].opernum != LWASM_OPER_NONE; opern++) 658 for (opern = 0; operators[opern].opernum != LWASM_OPER_NONE; opern++)
654 { 659 {
655 for (i = 0; (*p)[i] && operators[opern].operstr[i] && (*p[i] == operators[opern].operstr[i]); i++) 660 for (i = 0; (*p)[i] && operators[opern].operstr[i] && ((*p)[i] == operators[opern].operstr[i]); i++)
656 /* do nothing */ ; 661 /* do nothing */ ;
657 if (operators[opern].operstr[i] == '\0') 662 if (operators[opern].operstr[i] == '\0')
658 break; 663 break;
659 } 664 }
660 if (operators[opern].opernum == LWASM_OPER_NONE) 665 if (operators[opern].opernum == LWASM_OPER_NONE)