* better get_current_col

This commit is contained in:
peter 1998-05-31 14:10:54 +00:00
parent cc476415ee
commit ed10a74289

View File

@ -147,15 +147,15 @@ unit scanner;
orgpattern, orgpattern,
pattern : string; pattern : string;
macrobuffer : ^tmacrobuffer; macrobuffer : ^tmacrobuffer;
inputbuffer : pchar; lastlinepos,
lasttokenpos,
inputbuffer,
inputpointer : pchar; inputpointer : pchar;
{ parse_types, } { true, if type declarations are parsed } { parse_types, } { true, if type declarations are parsed }
s_point : boolean; s_point : boolean;
comment_level, comment_level,
yylexcount, yylexcount,
macropos, macropos : longint;
lastlinepos,
lasttokenpos : longint;
lastasmgetchar : char; lastasmgetchar : char;
preprocstack : ppreprocstack; preprocstack : ppreprocstack;
@ -259,10 +259,14 @@ unit scanner;
function get_current_col : longint; function get_current_col : longint;
begin begin
if lastlinepos<=lasttokenpos then {$ifdef TP}
get_current_col:=lasttokenpos-lastlinepos if lastlinepos<=lasttokenpos then
else get_current_col:=longint(lasttokenpos)-longint(lastlinepos)
get_current_col:=0; else
get_current_col:=longint(lastlinepos)-longint(lasttokenpos);
{$else}
get_current_col:=cardinal(lasttokenpos)-cardinal(lastlinepos);
{$endif}
end; end;
@ -382,7 +386,7 @@ unit scanner;
inc(current_module^.current_inputfile^.line_no); inc(current_module^.current_inputfile^.line_no);
status.currentline:=current_module^.current_inputfile^.line_no; status.currentline:=current_module^.current_inputfile^.line_no;
inc(status.compiledlines); inc(status.compiledlines);
lastlinepos:=longint(inputpointer); lastlinepos:=inputpointer;
end; end;
@ -710,13 +714,13 @@ unit scanner;
until false; until false;
{ Save current token position } { Save current token position }
lasttokenpos:=longint(inputpointer); lasttokenpos:=inputpointer;
tokenpos.line:=current_module^.current_inputfile^.line_no; tokenpos.line:=current_module^.current_inputfile^.line_no;
tokenpos.column:=get_current_col; tokenpos.column:=get_current_col;
tokenpos.fileindex:=current_module^.current_index; tokenpos.fileindex:=current_module^.current_index;
{ Check first for a identifier/keyword, this is 20+% faster (PFV) }
{ Check first for a identifier/keyword, this is 20+% faster (PFV) }
if c in ['_','A'..'Z','a'..'z'] then if c in ['_','A'..'Z','a'..'z'] then
begin begin
@ -777,7 +781,7 @@ unit scanner;
end; end;
goto exit_label; goto exit_label;
end end
else else
begin begin
case c of case c of
'$' : begin '$' : begin
@ -1167,8 +1171,8 @@ exit_label:
reload; reload;
preprocstack:=nil; preprocstack:=nil;
comment_level:=0; comment_level:=0;
lasttokenpos:=0; lasttokenpos:=inputpointer;
lastlinepos:=0; lastlinepos:=inputpointer;
s_point:=false; s_point:=false;
end; end;
@ -1256,7 +1260,10 @@ exit_label:
end. end.
{ {
$Log$ $Log$
Revision 1.21 1998-05-27 00:20:32 peter Revision 1.22 1998-05-31 14:10:54 peter
* better get_current_col
Revision 1.21 1998/05/27 00:20:32 peter
* some scanner optimizes * some scanner optimizes
* automaticly aout2exe for go32v1 * automaticly aout2exe for go32v1
* fixed dynamiclinker option which was added at the wrong place * fixed dynamiclinker option which was added at the wrong place