Develop and Download Open Source Software

Browse Subversion Repository

Diff of /bl/trunk/bl1.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by aloha, Sun Sep 30 11:12:14 2007 UTC revision 5 by aloha, Sun Sep 30 15:46:36 2007 UTC
# Line 338  static enum tree_code get_operator(tree Line 338  static enum tree_code get_operator(tree
338      return MINUS_EXPR;      return MINUS_EXPR;
339    else if(get_identifier("*") == t)    else if(get_identifier("*") == t)
340      return MULT_EXPR;      return MULT_EXPR;
341      else if(get_identifier("/") == t)
342        return TRUNC_DIV_EXPR;
343      else if(get_identifier("%") == t)
344        return TRUNC_MOD_EXPR;
345    else {    else {
346      fprintf(stderr, "Invalid operator : %s\n",  IDENTIFIER_POINTER(t));      fprintf(stderr, "Invalid operator : %s\n",  IDENTIFIER_POINTER(t));
347      gcc_unreachable();      gcc_unreachable();
# Line 379  static void bl_finalize_function(tree fn Line 383  static void bl_finalize_function(tree fn
383   *         | Term   *         | Term
384   *   *
385   *  Term ::= Fact * Fact   *  Term ::= Fact * Fact
386     *         | Fact / Fact
387     *         | Fact % Fact
388   *         | Fact   *         | Fact
389   *   *
390   *  Fact ::= id '(' {Expr} (,Expr)*  ')'           // function call   *  Fact ::= id '(' {Expr} (,Expr)*  ')'           // function call
391   *         | '(' Expr ')'   *         | '(' Expr ')'
392   *         | id                                    // variable   *         | id                                    // variable
393   *         | integer   *         | integer
394     *         | ! Fact                                //  not
395   */   */
396    
397  static tree parse_expr(void);  static tree parse_expr(void);
# Line 394  static tree parse_fact(void) { Line 401  static tree parse_fact(void) {
401    
402    // function call : id '(' {Expr} (, Expr)* ')'    // function call : id '(' {Expr} (, Expr)* ')'
403    if(TREE_CODE(T1) == IDENTIFIER_NODE &&    if(TREE_CODE(T1) == IDENTIFIER_NODE &&
404          T1 != get_identifier("!") &&
405        check("(")) {        check("(")) {
406      tree fn_decl = lookup_variable(T1);      tree fn_decl = lookup_variable(T1);
407      if(TREE_CODE(fn_decl) != FUNCTION_DECL) {      if(TREE_CODE(fn_decl) != FUNCTION_DECL) {
# Line 415  static tree parse_fact(void) { Line 423  static tree parse_fact(void) {
423      return build_function_call_expr(fn_decl, args);      return build_function_call_expr(fn_decl, args);
424    }    }
425    
426    if(T1 != get_identifier("("))    if(T1 == get_identifier("!")) {
427      return eval_value(T1);      tree exp = parse_fact();
428        return build1(BIT_NOT_EXPR,TREE_TYPE(exp),exp);
429      }
430    
431    if(T1 == get_identifier("(")) {    if(T1 == get_identifier("(")) {
432      tree t = parse_expr();      tree t = parse_expr();
# Line 424  static tree parse_fact(void) { Line 434  static tree parse_fact(void) {
434      return t;      return t;
435    }    }
436    
437    debug_tree(T1);    return eval_value(T1);
   gcc_unreachable();  
438  }  }
439    
440  static tree parse_term(void) {  static tree parse_term(void) {
441    tree T1 = parse_fact();    tree T1 = parse_fact();
442    
443    while(next_p()) {    while(next_p()) {
444      if(!check("*")) {      if(!check("*")
445            && !check("/")
446            && !check("%")) {
447        break;        break;
448      }      }
449      tree op = next();      tree op = next();

Legend:
Removed from v.4  
changed lines
  Added in v.5

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26