Преглед изворни кода

* hex constants in numeric char (#$54#$43 ...) are now allowed
* there was a bug in record_var_dec which prevents the used
of nested variant records (for example drivers.tevent of tv)

florian пре 27 година
родитељ
комит
e770d0b0d2
3 измењених фајлова са 60 додато и 17 уклоњено
  1. 15 8
      compiler/pdecl.pas
  2. 20 2
      compiler/ptconst.pas
  3. 25 7
      compiler/scanner.pas

+ 15 - 8
compiler/pdecl.pas

@@ -299,13 +299,13 @@ unit pdecl;
                  Message(parser_e_absolute_only_to_var_or_const);
                 symdone:=true;
               end;
-           { for a record there doesn't need to be a ; before the END or ) }
+             { for a record there doesn't need to be a ; before the END or ) }
              if not((is_record or is_object) and (token in [_END,RKLAMMER])) then
-              consume(SEMICOLON);
-           { Check for variable directives }
+               consume(SEMICOLON);
+             { Check for variable directives }
              if (token=ID) then
               begin
-              { Check for C Variable declarations }
+                { Check for C Variable declarations }
                 if support_c_var and
                    not(is_record or is_object) and
                    ((pattern='EXPORT') or
@@ -429,9 +429,11 @@ unit pdecl;
                 maxsize:=max(maxsize,symtablestack^.datasize);
               { the items of the next variant are overlayed }
                 symtablestack^.datasize:=startvarrec;
-                if token<>_END then
-                  consume(SEMICOLON);
-              until token=_END;
+                if (token<>_END) and (token<>RKLAMMER) then
+                  consume(SEMICOLON)
+                else
+                  break;
+              until (token=_END) or (token=RKLAMMER);
             { at last set the record size to that of the biggest variant }
               symtablestack^.datasize:=maxsize;
            end;
@@ -1873,7 +1875,12 @@ unit pdecl;
 end.
 {
   $Log$
-  Revision 1.33  1998-07-18 17:11:11  florian
+  Revision 1.34  1998-07-20 22:17:15  florian
+    * hex constants in numeric char (#$54#$43 ...) are now allowed
+    * there was a bug in record_var_dec which prevents the used
+      of nested variant records (for example drivers.tevent of tv)
+
+  Revision 1.33  1998/07/18 17:11:11  florian
     + ansi string constants fixed
     + switch $H partial implemented
 

+ 20 - 2
compiler/ptconst.pas

@@ -294,7 +294,20 @@ unit ptconst;
                    begin
                      { first write the maximum size }
                      datasegment^.concat(new(pai_const,init_32bit(p^.length)))));
-                     writestringdata(datasegment);
+                     { fill byte }
+                     datasegment^.concat(new(pai_const,init_8bit(0)));
+                     if p^.treetype=stringconstn then
+                       begin
+                          { this can also handle longer strings }
+                          generate_pascii(consts,p^.values,p^.length);
+                       end
+                     else if is_constcharnode(p) then
+                       begin
+                          consts^.concat(new(pai_const,init_8bit(p^.value)));
+                          strlength:=1;
+                       end
+                     else Message(cg_e_illegal_expression);
+                     datasegment^.concat(new(pai_const,init_8bit(0)));
                    end;
 {$endif UseLongString}
 {$ifdef UseAnsiString}
@@ -479,7 +492,12 @@ unit ptconst;
 end.
 {
   $Log$
-  Revision 1.8  1998-07-20 18:40:15  florian
+  Revision 1.9  1998-07-20 22:17:16  florian
+    * hex constants in numeric char (#$54#$43 ...) are now allowed
+    * there was a bug in record_var_dec which prevents the used
+      of nested variant records (for example drivers.tevent of tv)
+
+  Revision 1.8  1998/07/20 18:40:15  florian
     * handling of ansi string constants should now work
 
   Revision 1.7  1998/07/18 22:54:29  florian

+ 25 - 7
compiler/scanner.pas

@@ -1309,12 +1309,25 @@ implementation
                           case c of
                            '#' : begin
                                    readchar; { read # }
-                                   asciinr:='';
-                                   while (c in ['0'..'9']) and (length(asciinr)<3) do
-                                    begin
-                                      asciinr:=asciinr+c;
-                                      readchar;
-                                    end;
+                                   if c='$' then
+                                     begin
+                                        readchar; { read leading $ }
+                                        asciinr:='$';
+                                        while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<3) do
+                                         begin
+                                           asciinr:=asciinr+c;
+                                           readchar;
+                                         end;
+                                     end
+                                   else
+                                     begin
+                                        asciinr:='';
+                                        while (c in ['0'..'9']) and (length(asciinr)<3) do
+                                         begin
+                                           asciinr:=asciinr+c;
+                                           readchar;
+                                         end;
+                                     end;
                                    valint(asciinr,l,code);
                                    if (asciinr='') or (code<>0) or
                                       (l<0) or (l>255) then
@@ -1535,7 +1548,12 @@ exit_label:
 end.
 {
   $Log$
-  Revision 1.35  1998-07-14 21:38:13  peter
+  Revision 1.36  1998-07-20 22:17:17  florian
+    * hex constants in numeric char (#$54#$43 ...) are now allowed
+    * there was a bug in record_var_dec which prevents the used
+      of nested variant records (for example drivers.tevent of tv)
+
+  Revision 1.35  1998/07/14 21:38:13  peter
     + support for with p^do constructs
 
   Revision 1.34  1998/07/14 14:47:04  peter