Author: kjs
Date: Sun Mar 25 07:30:09 2007
New Revision: 17723

Modified:
   trunk/compilers/pirc/src/pirlexer.c
   trunk/compilers/pirc/src/pirlexer.h
   trunk/compilers/pirc/src/pirparser.c

Log:
compilers/pirc:
* added '//' and '//=' (fdiv).

Modified: trunk/compilers/pirc/src/pirlexer.c
==============================================================================
--- trunk/compilers/pirc/src/pirlexer.c (original)
+++ trunk/compilers/pirc/src/pirlexer.c Sun Mar 25 07:30:09 2007
@@ -131,6 +131,7 @@
     "+",                        /* T_PLUS,                  */
     "-",                        /* T_MINUS,                 */
     "/",                        /* T_DIVIDE,                */
+    "//",                       /* T_FDIVIDE,               */
     "%",                        /* T_MODULO,                */
     "*",                        /* T_MULTIPLY,              */
     ".",                        /* T_CONCAT,                */
@@ -191,6 +192,7 @@
     "-=",                       /* T_MINUS_ASSIGN,          */
     "'register'",               /* T_REGISTER,              */
     "/=",                       /* T_DIVIDE_ASSIGN,         */
+    "//=",                      /* T_FDIVIDE_ASSIGN,        */
     "%=",                       /* T_MODULO_ASSIGN,         */
     "~=",                       /* T_BXOR_ASSIGN,           */
     "&=",                       /* T_BAND_ASSIGN,           */
@@ -1005,7 +1007,7 @@
 
 =head3 Augmented operators
 
-    **=   *=    %=   /=   +=   -=   >>=  >>>=   <<=  &=   |=   ~=
+    **=   *=    %=   /=   //=   +=   -=   >>=  >>>=   <<=  &=   |=   ~=
 
 =head3 Conditional operators
 
@@ -1038,13 +1040,22 @@
                 case EOF_MARKER: return T_EOF;
                 default:
                     unread_char(lexer->curfile, c);
-                    return T_MODULO;
+                    return T_MODULO;              /* % */
             }
         }
         else if (c == '/') {
             c = read_char(lexer->curfile);
             switch(c) {
-                case '/': return T_ERROR; /* // --> return FDIV or w/e */
+                case '/': 
+                    c = read_char(lexer->curfile);
+                    if (c == '=') {
+                        return T_FDIVIDE_ASSIGN; /* //= */
+                    }
+                    else {
+                        unread_char(lexer->curfile, c);
+                        return T_FDIVIDE;   
+                    }
+                    break;
                 case '=': return T_DIVIDE_ASSIGN; /* /= */
                 case EOF_MARKER: return T_EOF;
                 default:

Modified: trunk/compilers/pirc/src/pirlexer.h
==============================================================================
--- trunk/compilers/pirc/src/pirlexer.h (original)
+++ trunk/compilers/pirc/src/pirlexer.h Sun Mar 25 07:30:09 2007
@@ -70,6 +70,7 @@
         T_PLUS,                             /* "+",                       */
         T_MINUS,                            /* "-",                       */
         T_DIVIDE,                           /* "/",                       */
+        T_FDIVIDE,                          /* "//",                      */
         T_MODULO,                           /* "%",                       */
         T_MULTIPLY,                         /* "*",                       */
         T_CONCAT,                           /* ".",                       */
@@ -130,6 +131,7 @@
         T_MINUS_ASSIGN,                     /* "-=",                      */
         T_REGISTER,                         /* "'register'",              */
         T_DIVIDE_ASSIGN,                    /* "/=",                      */
+        T_FDIVIDE_ASSIGN,                   /* "//=",                     */
         T_MODULO_ASSIGN,                    /* "%=",                      */
         T_BXOR_ASSIGN,                      /* "~=",                      */
         T_BAND_ASSIGN,                      /* "&=",                      */

Modified: trunk/compilers/pirc/src/pirparser.c
==============================================================================
--- trunk/compilers/pirc/src/pirparser.c        (original)
+++ trunk/compilers/pirc/src/pirparser.c        Sun Mar 25 07:30:09 2007
@@ -458,7 +458,7 @@
 
   arith_expr -> [ binop expression ]
 
-  binop      -> '+' | '-' | '*' | '/' | '%' | '~~' | '~' | '&&' | '&' | '||' | 
'|' | '<<' | '>>' | '>>>' | '.'
+  binop      -> '+' | '-' | '*' | '/' | '//' | '%' | '~~' | '~' | '&&' | '&' | 
'||' | '|' | '<<' | '>>' | '>>>' | '.'
 
 =cut
 
@@ -469,6 +469,7 @@
         case T_PLUS:
         case T_MINUS:
         case T_DIVIDE:
+        case T_FDIVIDE:
         case T_MULTIPLY:
         case T_MODULO:
         case T_XOR:
@@ -1089,7 +1090,7 @@
                     | target '->' (stringconstant|IDENT) arguments '\n'
                     | target arguments '\n'
 
-  augmented_op    -> '+=' | '-=' | '%=' | '/=' | '*=' | '~=' | '&=' | '|=' | 
'**=' | '<<=' | '>>=' | '>>>='
+  augmented_op    -> '+=' | '-=' | '%=' | '/=' | '//=' | '*=' | '~=' | '&=' | 
'|=' | '**=' | '<<=' | '>>=' | '>>>='
 
 =cut
 
@@ -1106,6 +1107,7 @@
         case T_PLUS_ASSIGN: /* target '+=' simple_expr '\n' (and '-=' etc.) */
         case T_MINUS_ASSIGN:
         case T_DIVIDE_ASSIGN:
+        case T_FDIVIDE_ASSIGN:
         case T_POWER_ASSIGN:
         case T_MULTIPLY_ASSIGN:
         case T_BXOR_ASSIGN:

Reply via email to