* line numbering is now only done when #10, #10#13 is really parsed

instead of when it is the next character
This commit is contained in:
peter 2003-11-10 19:08:32 +00:00
parent f44380e4a9
commit 517c5de6aa
4 changed files with 253 additions and 248 deletions

View File

@ -1889,7 +1889,7 @@ Begin
{ setup label linked list }
LocalLabelList:=TLocalLabelList.Create;
{ start tokenizer }
c:=current_scanner.asmgetchar;
c:=current_scanner.asmgetcharstart;
gettoken;
{ main loop }
repeat
@ -2119,7 +2119,11 @@ finalization
end.
{
$Log$
Revision 1.56 2003-10-29 16:47:18 peter
Revision 1.57 2003-11-10 19:08:32 peter
* line numbering is now only done when #10, #10#13 is really parsed
instead of when it is the next character
Revision 1.56 2003/10/29 16:47:18 peter
* fix field offset in reference
Revision 1.55 2003/10/26 13:37:22 florian

View File

@ -1866,7 +1866,7 @@ Begin
{ setup label linked list }
LocalLabelList:=TLocalLabelList.Create;
{ start tokenizer }
c:=current_scanner.asmgetchar;
c:=current_scanner.asmgetcharstart;
gettoken;
{ main loop }
repeat
@ -1971,7 +1971,11 @@ finalization
end.
{
$Log$
Revision 1.63 2003-10-30 19:59:00 peter
Revision 1.64 2003-11-10 19:08:32 peter
* line numbering is now only done when #10, #10#13 is really parsed
instead of when it is the next character
Revision 1.63 2003/10/30 19:59:00 peter
* support scalefactor for opr_local
* support reference with opr_local set, fixes tw2631

View File

@ -38,7 +38,6 @@ interface
max_macro_nesting=16;
maxmacrolen=16*1024;
preprocbufsize=32*1024;
Newline = #10;
type
@ -151,6 +150,7 @@ interface
procedure skipoldtpcomment;
procedure readtoken;
function readpreproc:ttoken;
function asmgetcharstart : char;
function asmgetchar:char;
end;
@ -603,6 +603,8 @@ implementation
dec(bracketcount);
'{' :
inc(bracketcount);
#10,#13 :
current_scanner.linebreak;
#26 :
current_scanner.end_of_file;
end;
@ -838,10 +840,8 @@ implementation
if current_scanner.inputfilecount<max_include_nesting then
begin
inc(current_scanner.inputfilecount);
{ save old postion and decrease linebreak }
if c=newline then
dec(current_scanner.line_no);
dec(longint(current_scanner.inputpointer));
{ we need to reread the current char }
dec(current_scanner.inputpointer);
{ shutdown current file }
current_scanner.tempcloseinputfile;
{ load new file }
@ -852,12 +852,6 @@ implementation
Message1(scan_f_cannot_open_includefile,hs);
Message1(scan_t_start_include_file,current_scanner.inputfile.path^+current_scanner.inputfile.name^);
current_scanner.reload;
{ process first read char }
case c of
#26 : current_scanner.reload;
#10,
#13 : current_scanner.linebreak;
end;
end
else
Message(scan_f_include_deep_ten);
@ -1009,12 +1003,6 @@ implementation
if not openinputfile then
Message1(scan_f_cannot_open_input,inputfile.name^);
reload;
{ process first read char }
case c of
#26 : reload;
#10,
#13 : linebreak;
end;
end;
@ -1197,7 +1185,7 @@ implementation
(inputpointer-inputbuffer<bufsize) then
begin
c:=' ';
inc(longint(inputpointer));
inc(inputpointer);
exit;
end;
{ can we read more from this file ? }
@ -1235,7 +1223,7 @@ implementation
end;
{ load next char }
c:=inputpointer^;
inc(longint(inputpointer));
inc(inputpointer);
until c<>#0; { if also end, then reload again }
end;
end;
@ -1245,10 +1233,8 @@ implementation
var
hp : tinputfile;
begin
{ save old postion and decrease linebreak }
if c=newline then
dec(line_no);
dec(longint(inputpointer));
{ save old postion }
dec(inputpointer);
tempcloseinputfile;
{ create macro 'file' }
{ use special name to dispose after !! }
@ -1269,7 +1255,7 @@ implementation
lasttokenpos:=0;
{ load new c }
c:=inputpointer^;
inc(longint(inputpointer));
inc(inputpointer);
end;
@ -1324,15 +1310,16 @@ implementation
cur:=c;
reload;
if byte(cur)+byte(c)<>23 then
dec(longint(inputpointer));
dec(inputpointer);
end
else
begin
{ Fix linebreak to be only newline (=#10) for all types of linebreaks }
{ Support all combination of #10 and #13 as line break }
if (byte(inputpointer^)+byte(c)=23) then
inc(longint(inputpointer));
inc(inputpointer);
end;
c:=newline;
{ Always return #10 as line break }
c:=#10;
{ increase line counters }
lastlinepos:=bufstart+(inputpointer-inputbuffer);
inc(line_no);
@ -1560,12 +1547,7 @@ implementation
if c=#0 then
reload
else
inc(longint(inputpointer));
case c of
#26 : reload;
#10,
#13 : linebreak;
end;
inc(inputpointer);
end;
@ -1578,7 +1560,8 @@ implementation
case c of
'_',
'0'..'9',
'A'..'Z' : begin
'A'..'Z' :
begin
if i<255 then
begin
inc(i);
@ -1586,9 +1569,10 @@ implementation
pattern[i]:=c;
end;
c:=inputpointer^;
inc(longint(inputpointer));
inc(inputpointer);
end;
'a'..'z' : begin
'a'..'z' :
begin
if i<255 then
begin
inc(i);
@ -1596,18 +1580,10 @@ implementation
pattern[i]:=chr(ord(c)-32)
end;
c:=inputpointer^;
inc(longint(inputpointer));
inc(inputpointer);
end;
#0 : reload;
#26 : begin
#0 :
reload;
if c=#26 then
break;
end;
#13,#10 : begin
linebreak;
break;
end;
else
break;
end;
@ -1623,19 +1599,22 @@ implementation
i : longint;
begin
case c of
'%' : begin
'%' :
begin
readchar;
base:=2;
pattern[1]:='%';
i:=1;
end;
'&' : begin
'&' :
begin
readchar;
base:=8;
pattern[1]:='&';
i:=1;
end;
'$' : begin
'$' :
begin
readchar;
base:=16;
pattern[1]:='$';
@ -1657,18 +1636,7 @@ implementation
inc(i);
pattern[i]:=c;
end;
{ get next char }
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
end;
{ was the next char a linebreak ? }
case c of
#26 : reload;
#10,
#13 : linebreak;
readchar;
end;
pattern[0]:=chr(i);
end;
@ -1700,9 +1668,12 @@ implementation
repeat
case c of
'{' :
begin
if aktcommentstyle=comment_tp then
inc_comment_level;
end;
'}' :
begin
if aktcommentstyle=comment_tp then
begin
readchar;
@ -1712,7 +1683,9 @@ implementation
else
continue;
end;
end;
'*' :
begin
if aktcommentstyle=comment_oldtp then
begin
readchar;
@ -1744,6 +1717,9 @@ implementation
readcomment[i]:='*';
end;
end;
end;
#10,#13 :
linebreak;
#26 :
end_of_file;
else
@ -1755,13 +1731,7 @@ implementation
end;
end;
end;
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
if c in [#10,#13] then
linebreak;
readchar;
until false;
readcomment[0]:=chr(i);
end;
@ -1792,21 +1762,25 @@ implementation
procedure tscannerfile.skipspace;
begin
while c in [' ',#9..#13] do
begin
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
repeat
case c of
#26 :
begin
reload;
if (c=#26) and not assigned(inputfile.next) then
break;
continue;
end;
#10,
#13 :
linebreak;
#9,#11,#12,' ' :
;
else
break;
end;
end;
readchar;
until false;
end;
@ -1823,8 +1797,16 @@ implementation
oldcommentstyle:=aktcommentstyle;
repeat
case c of
#10,
#13 :
linebreak;
#26 :
begin
reload;
if (c=#26) and not assigned(inputfile.next) then
end_of_file;
continue;
end;
'{' :
begin
if not(m_nested_comment in aktmodeswitches) or
@ -1872,7 +1854,7 @@ implementation
case c of
#26 :
end_of_file;
newline :
#10,#13 :
break;
'''' :
begin
@ -1905,8 +1887,7 @@ implementation
skipoldtpcomment;
aktcommentstyle:=oldcommentstyle;
end;
end
else
end;
next_char_loaded:=true;
end
else
@ -1921,8 +1902,7 @@ implementation
begin
skipdelphicomment;
aktcommentstyle:=oldcommentstyle;
end
else
end;
next_char_loaded:=true;
end
else
@ -1934,18 +1914,7 @@ implementation
if next_char_loaded then
next_char_loaded:=false
else
begin
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
case c of
#26 : reload;
#10,
#13 : linebreak;
end;
end;
readchar;
until (found=2);
end;
@ -1966,20 +1935,21 @@ implementation
while (comment_level>0) do
begin
case c of
'{' : inc_comment_level;
'}' : dec_comment_level;
#26 : end_of_file;
'{' :
inc_comment_level;
'}' :
dec_comment_level;
#10,#13 :
linebreak;
#26 :
begin
reload;
if (c=#26) and not assigned(inputfile.next) then
end_of_file;
continue;
end;
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
case c of
#26 : reload;
#10,
#13 : linebreak;
end;
readchar;
end;
aktcommentstyle:=comment_none;
end;
@ -1994,7 +1964,7 @@ implementation
if c='$' then
Message(scan_e_wrong_styled_switch);
{ skip comment }
while not (c in [newline,#26]) do
while not (c in [#10,#13,#26]) do
readchar;
dec_comment_level;
aktcommentstyle:=comment_none;
@ -2021,7 +1991,14 @@ implementation
repeat
case c of
#26 :
begin
reload;
if (c=#26) and not assigned(inputfile.next) then
end_of_file;
continue;
end;
#10,#13 :
linebreak;
'*' :
begin
if found=3 then
@ -2053,16 +2030,7 @@ implementation
found:=0;
end;
end;
c:=inputpointer^;
if c=#0 then
reload
else
inc(longint(inputpointer));
case c of
#26 : reload;
#10,
#13 : linebreak;
end;
readchar;
until (found=2);
end;
aktcommentstyle:=comment_none;
@ -2105,6 +2073,12 @@ implementation
case c of
'{' :
skipcomment;
#26 :
begin
reload;
if (c=#26) and not assigned(inputfile.next) then
break;
end;
' ',#9..#13 :
begin
{$ifdef PREPROCWRITE}
@ -2173,14 +2147,7 @@ implementation
mac.fileinfo.line,mac.fileinfo.fileindex);
{ handle empty macros }
if c=#0 then
begin
reload;
case c of
#26 : reload;
#10,
#13 : linebreak;
end;
end;
readtoken;
{ that's all folks }
dec(yylexcount);
@ -2558,7 +2525,7 @@ implementation
case c of
#26 :
end_of_file;
newline :
#10,#13 :
Message(scan_f_string_exceeds_line);
'''' :
begin
@ -2785,6 +2752,15 @@ exit_label:
end;
function tscannerfile.asmgetcharstart : char;
begin
{ return first the character already
available in c }
lastasmgetchar:=c;
result:=asmgetchar;
end;
function tscannerfile.asmgetchar : char;
begin
if lastasmgetchar<>#0 then
@ -2807,6 +2783,19 @@ exit_label:
'{' :
skipcomment;
{$endif arm}
#10,#13 :
begin
linebreak;
asmgetchar:=c;
exit;
end;
#26 :
begin
reload;
if (c=#26) and not assigned(inputfile.next) then
end_of_file;
continue;
end;
'/' :
begin
readchar;
@ -2906,7 +2895,11 @@ exit_label:
end.
{
$Log$
Revision 1.63 2003-10-29 21:02:51 peter
Revision 1.64 2003-11-10 19:08:32 peter
* line numbering is now only done when #10, #10#13 is really parsed
instead of when it is the next character
Revision 1.63 2003/10/29 21:02:51 peter
* set ms_compiled after the program/unit is parsed
* check for ms_compiled before checking preproc matches

View File

@ -86,7 +86,7 @@ interface
if assigned(current_procinfo.procdef.funcretsym) and
is_fpu(current_procinfo.procdef.rettype.def) then
tvarsym(current_procinfo.procdef.funcretsym).varstate:=vs_assigned;
c:=current_scanner.asmgetchar;
c:=current_scanner.asmgetcharstart;
code:=TAAsmoutput.Create;
while not(ende) do
begin
@ -343,7 +343,11 @@ initialization
end.
{
$Log$
Revision 1.10 2003-10-01 20:34:51 peter
Revision 1.11 2003-11-10 19:08:32 peter
* line numbering is now only done when #10, #10#13 is really parsed
instead of when it is the next character
Revision 1.10 2003/10/01 20:34:51 peter
* procinfo unit contains tprocinfo
* cginfo renamed to cgbase
* moved cgmessage to verbose