• R/O
  • SSH
  • HTTPS

blanguage: Commit


Commit MetaInfo

Revision5 (tree)
Time2007-10-01 00:46:36
Authoraloha

Log Message

support / (div),% (mod),! (not) operator

Change Summary

Incremental Difference

--- bl/trunk/bl1.c (revision 4)
+++ bl/trunk/bl1.c (revision 5)
@@ -338,6 +338,10 @@
338338 return MINUS_EXPR;
339339 else if(get_identifier("*") == t)
340340 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;
341345 else {
342346 fprintf(stderr, "Invalid operator : %s\n", IDENTIFIER_POINTER(t));
343347 gcc_unreachable();
@@ -379,6 +383,8 @@
379383 * | Term
380384 *
381385 * Term ::= Fact * Fact
386+ * | Fact / Fact
387+ * | Fact % Fact
382388 * | Fact
383389 *
384390 * Fact ::= id '(' {Expr} (,Expr)* ')' // function call
@@ -385,6 +391,7 @@
385391 * | '(' Expr ')'
386392 * | id // variable
387393 * | integer
394+ * | ! Fact // not
388395 */
389396
390397 static tree parse_expr(void);
@@ -394,6 +401,7 @@
394401
395402 // function call : id '(' {Expr} (, Expr)* ')'
396403 if(TREE_CODE(T1) == IDENTIFIER_NODE &&
404+ T1 != get_identifier("!") &&
397405 check("(")) {
398406 tree fn_decl = lookup_variable(T1);
399407 if(TREE_CODE(fn_decl) != FUNCTION_DECL) {
@@ -415,8 +423,10 @@
415423 return build_function_call_expr(fn_decl, args);
416424 }
417425
418- if(T1 != get_identifier("("))
419- return eval_value(T1);
426+ if(T1 == get_identifier("!")) {
427+ tree exp = parse_fact();
428+ return build1(BIT_NOT_EXPR,TREE_TYPE(exp),exp);
429+ }
420430
421431 if(T1 == get_identifier("(")) {
422432 tree t = parse_expr();
@@ -424,8 +434,7 @@
424434 return t;
425435 }
426436
427- debug_tree(T1);
428- gcc_unreachable();
437+ return eval_value(T1);
429438 }
430439
431440 static tree parse_term(void) {
@@ -432,7 +441,9 @@
432441 tree T1 = parse_fact();
433442
434443 while(next_p()) {
435- if(!check("*")) {
444+ if(!check("*")
445+ && !check("/")
446+ && !check("%")) {
436447 break;
437448 }
438449 tree op = next();
Show on old repository browser