Răsfoiți Sursa

+ added language constructs UNIV, C, ... for mode mac
* consolidated macro expression to conform to Pascal
* macro true is defined as <> 0

olle 21 ani în urmă
părinte
comite
758c940518
3 a modificat fișierele cu 73 adăugiri și 19 ștergeri
  1. 29 6
      compiler/pdecsub.pas
  2. 31 11
      compiler/scanner.pas
  3. 13 2
      compiler/tokens.pas

+ 29 - 6
compiler/pdecsub.pas

@@ -59,7 +59,7 @@ interface
     function  parse_proc_head(aclass:tobjectdef;potype:tproctypeoption;var pd:tprocdef):boolean;
     function  parse_proc_head(aclass:tobjectdef;potype:tproctypeoption;var pd:tprocdef):boolean;
     function  parse_proc_dec(aclass:tobjectdef):tprocdef;
     function  parse_proc_dec(aclass:tobjectdef):tprocdef;
 
 
-
+    procedure change_forward_to_external(pd:tabstractprocdef);
 
 
 implementation
 implementation
 
 
@@ -390,6 +390,13 @@ implementation
                  consume(_OUT);
                  consume(_OUT);
                  varspez:=vs_out
                  varspez:=vs_out
               end
               end
+          else
+            if (token=_POINTPOINTPOINT) and (m_mac in aktmodeswitches) then
+              begin
+                consume(_POINTPOINTPOINT);
+                include(pd.procoptions,po_varargs);
+                break;
+              end
           else
           else
               varspez:=vs_value;
               varspez:=vs_value;
           defaultvalue:=nil;
           defaultvalue:=nil;
@@ -453,6 +460,8 @@ implementation
                 else
                 else
                  begin
                  begin
                    { everything else }
                    { everything else }
+                   if (m_mac in aktmodeswitches) then
+                     try_to_consume(_UNIV); {currently does nothing}
                    single_type(tt,hs1,false);
                    single_type(tt,hs1,false);
                  end;
                  end;
 
 
@@ -465,11 +474,11 @@ implementation
                         consume(_CSTRING);
                         consume(_CSTRING);
                       end
                       end
                     else
                     else
-		      begin
+                      begin
                         if explicit_paraloc then
                         if explicit_paraloc then
                           Message(parser_e_paraloc_all_paras);
                           Message(parser_e_paraloc_all_paras);
-      			locationstr:='';
-       		      end;
+                        locationstr:='';
+                      end;
                   end
                   end
                 else
                 else
                   locationstr:='';
                   locationstr:='';
@@ -1266,7 +1275,7 @@ type
    end;
    end;
 const
 const
   {Should contain the number of procedure directives we support.}
   {Should contain the number of procedure directives we support.}
-  num_proc_directives=35;
+  num_proc_directives=36;
   proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
   proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
    (
    (
     (
     (
@@ -1305,6 +1314,15 @@ const
       mutexclpocall : [];
       mutexclpocall : [];
       mutexclpotype : [];
       mutexclpotype : [];
       mutexclpo     : [po_external]
       mutexclpo     : [po_external]
+    ),(
+      idtok:_C; {same as cdecl for mode mac}
+      pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
+      handler  : nil;
+      pocall   : pocall_cdecl;
+      pooption : [];
+      mutexclpocall : [];
+      mutexclpotype : [potype_constructor,potype_destructor];
+      mutexclpo     : [po_assembler,po_external]
     ),(
     ),(
       idtok:_CDECL;
       idtok:_CDECL;
       pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
       pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
@@ -2217,7 +2235,12 @@ const
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.171  2004-05-01 22:38:13  florian
+  Revision 1.172  2004-05-03 10:06:38  olle
+    + added language constructs UNIV, C, ... for mode mac
+    * consolidated macro expression to conform to Pascal
+    * macro true is defined as <> 0
+
+  Revision 1.171  2004/05/01 22:38:13  florian
     * fixed MorphOS syscall without parameters
     * fixed MorphOS syscall without parameters
 
 
   Revision 1.170  2004/05/01 22:05:01  florian
   Revision 1.170  2004/05/01 22:05:01  florian

+ 31 - 11
compiler/scanner.pas

@@ -374,6 +374,9 @@ implementation
            mac: tmacro;
            mac: tmacro;
            srsym : tsym;
            srsym : tsym;
            srsymtable : tsymtable;
            srsymtable : tsymtable;
+           l : longint;
+           w : integer;
+
         begin
         begin
            if current_scanner.preproc_token=_ID then
            if current_scanner.preproc_token=_ID then
              begin
              begin
@@ -461,11 +464,12 @@ implementation
                 if preproc_substitutedtoken='NOT' then
                 if preproc_substitutedtoken='NOT' then
                   begin
                   begin
                     preproc_consume(_ID);
                     preproc_consume(_ID);
-                    hs:=read_expr;
-                    if hs='0' then
-                      read_factor:='1'
+                    hs:=read_factor();
+                    valint(hs,l,w);
+                    if l<>0 then
+                      read_factor:='0'
                     else
                     else
-                      read_factor:='0';
+                      read_factor:='1';
                   end
                   end
                 else
                 else
                 if (m_mac in aktmodeswitches) and (preproc_substitutedtoken='TRUE') then
                 if (m_mac in aktmodeswitches) and (preproc_substitutedtoken='TRUE') then
@@ -509,10 +513,10 @@ implementation
             if preproc_substitutedtoken<>'AND' then
             if preproc_substitutedtoken<>'AND' then
               break;
               break;
             preproc_consume(_ID);
             preproc_consume(_ID);
-            hs2:=read_expr;
+            hs2:=read_factor;
             valint(hs1,l1,w);
             valint(hs1,l1,w);
             valint(hs2,l2,w);
             valint(hs2,l2,w);
-            if (l1>0) and (l2>0) then
+            if (l1<>0) and (l2<>0) then
               hs1:='1'
               hs1:='1'
             else
             else
               hs1:='0';
               hs1:='0';
@@ -534,10 +538,10 @@ implementation
             if preproc_substitutedtoken<>'OR' then
             if preproc_substitutedtoken<>'OR' then
               break;
               break;
             preproc_consume(_ID);
             preproc_consume(_ID);
-            hs2:=read_expr;
+            hs2:=read_term;
             valint(hs1,l1,w);
             valint(hs1,l1,w);
             valint(hs2,l2,w);
             valint(hs2,l2,w);
-            if (l1>0) or (l2>0) then
+            if (l1<>0) or (l2<>0) then
               hs1:='1'
               hs1:='1'
             else
             else
               hs1:='0';
               hs1:='0';
@@ -2521,8 +2525,19 @@ implementation
                    '.' :
                    '.' :
                      begin
                      begin
                        readchar;
                        readchar;
-                       token:=_POINTPOINT;
-                       goto exit_label;
+                       case c of
+                         '.' :
+                         begin
+                           readchar;
+                           token:=_POINTPOINTPOINT;
+                           goto exit_label;
+                         end;
+                       else
+                         begin
+                           token:=_POINTPOINT;
+                           goto exit_label;
+                         end;
+                       end;
                      end;
                      end;
                    ')' :
                    ')' :
                      begin
                      begin
@@ -3028,7 +3043,12 @@ exit_label:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.75  2004-03-04 17:23:10  peter
+  Revision 1.76  2004-05-03 10:06:38  olle
+    + added language constructs UNIV, C, ... for mode mac
+    * consolidated macro expression to conform to Pascal
+    * macro true is defined as <> 0
+
+  Revision 1.75  2004/03/04 17:23:10  peter
     * $elseif support
     * $elseif support
     * conditiotnal in // returns warning isntead of error
     * conditiotnal in // returns warning isntead of error
 
 

+ 13 - 2
compiler/tokens.pas

@@ -67,6 +67,7 @@ type
     _SEMICOLON,
     _SEMICOLON,
     _KLAMMERAFFE,
     _KLAMMERAFFE,
     _POINTPOINT,
     _POINTPOINT,
+    _POINTPOINTPOINT,
     _EOF,
     _EOF,
     _ID,
     _ID,
     _NOID,
     _NOID,
@@ -88,6 +89,7 @@ type
     _NOTASN,
     _NOTASN,
     _XORASN,
     _XORASN,
     { Normal words }
     { Normal words }
+    _C,
     _AS,
     _AS,
     _AT,
     _AT,
     _DO,
     _DO,
@@ -129,6 +131,7 @@ type
     _TRUE,
     _TRUE,
     _TYPE,
     _TYPE,
     _UNIT,
     _UNIT,
+    _UNIV,
     _USES,
     _USES,
     _WITH,
     _WITH,
     _ALIAS,
     _ALIAS,
@@ -225,7 +228,7 @@ type
   );
   );
 
 
 const
 const
-  tokenlenmin = 2;
+  tokenlenmin = 1;
   tokenlenmax = 14;
   tokenlenmax = 14;
 
 
   { last operator which can be overloaded, the first_overloaded should
   { last operator which can be overloaded, the first_overloaded should
@@ -291,6 +294,7 @@ const
       (str:';'             ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:';'             ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'@'             ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'@'             ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'..'            ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'..'            ;special:true ;keyword:m_none;op:NOTOKEN),
+      (str:'...'           ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'end of file'   ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'end of file'   ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'identifier'    ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'identifier'    ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:'non identifier';special:true ;keyword:m_none;op:NOTOKEN),
       (str:'non identifier';special:true ;keyword:m_none;op:NOTOKEN),
@@ -312,6 +316,7 @@ const
       (str:''              ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:''              ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:''              ;special:true ;keyword:m_none;op:NOTOKEN),
       (str:''              ;special:true ;keyword:m_none;op:NOTOKEN),
     { Normal words }
     { Normal words }
+      (str:'C'             ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'AS'            ;special:false;keyword:m_class;op:_OP_AS),
       (str:'AS'            ;special:false;keyword:m_class;op:_OP_AS),
       (str:'AT'            ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'AT'            ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'DO'            ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'DO'            ;special:false;keyword:m_all;op:NOTOKEN),
@@ -353,6 +358,7 @@ const
       (str:'TRUE'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'TRUE'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'TYPE'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'TYPE'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'UNIT'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'UNIT'          ;special:false;keyword:m_all;op:NOTOKEN),
+      (str:'UNIV'          ;special:false;keyword:m_mac;op:NOTOKEN),
       (str:'USES'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'USES'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'WITH'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'WITH'          ;special:false;keyword:m_all;op:NOTOKEN),
       (str:'ALIAS'         ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'ALIAS'         ;special:false;keyword:m_none;op:NOTOKEN),
@@ -506,7 +512,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  2004-04-18 15:22:24  florian
+  Revision 1.28  2004-05-03 10:06:38  olle
+    + added language constructs UNIV, C, ... for mode mac
+    * consolidated macro expression to conform to Pascal
+    * macro true is defined as <> 0
+
+  Revision 1.27  2004/04/18 15:22:24  florian
     + location support for arguments, currently PowerPC/MorphOS only
     + location support for arguments, currently PowerPC/MorphOS only
 
 
   Revision 1.26  2004/02/17 17:38:11  daniel
   Revision 1.26  2004/02/17 17:38:11  daniel