* '1.' is now parsed as a real

This commit is contained in:
peter 1999-04-01 22:05:59 +00:00
parent 11fee238d9
commit e0e2e44849

View File

@ -66,9 +66,9 @@ unit scanner;
lastlinepos : longint; lastlinepos : longint;
lasttokenpos : longint; { token } lasttokenpos : longint; { token }
lasttoken : ttoken; lasttoken,
nexttoken : ttoken;
do_special, { 1=point after nr, 2=caret after id }
comment_level, comment_level,
yylexcount : longint; yylexcount : longint;
lastasmgetchar : char; lastasmgetchar : char;
@ -216,13 +216,13 @@ implementation
{ reset scanner } { reset scanner }
preprocstack:=nil; preprocstack:=nil;
comment_level:=0; comment_level:=0;
do_special:=0;
yylexcount:=0; yylexcount:=0;
block_type:=bt_general; block_type:=bt_general;
line_no:=0; line_no:=0;
lastlinepos:=0; lastlinepos:=0;
lasttokenpos:=0; lasttokenpos:=0;
lasttoken:=_END; lasttoken:=NOTOKEN;
nexttoken:=NOTOKEN;
lastasmgetchar:=#0; lastasmgetchar:=#0;
invalid:=false; invalid:=false;
{ load block } { load block }
@ -995,50 +995,32 @@ implementation
end; end;
end; end;
procedure tscannerfile.readtoken; procedure tscannerfile.readtoken;
var var
code : integer; code : integer;
low,high,mid, low,high,mid : longint;
l : {$ifdef TP} word; {$else} longint; {$endif}
m : longint; m : longint;
mac : pmacrosym; mac : pmacrosym;
asciinr : string[3]; asciinr : string[3];
label label
exit_label; exit_label;
begin begin
{ was the last character a point ? } { was there already a token read, then return that token }
{ this code is needed because the scanner if there is a 1. found if } if nexttoken<>NOTOKEN then
{ this is a floating point number or range like 1..3 }
if do_special>0 then
begin begin
gettokenpos; token:=nexttoken;
l:=do_special; nexttoken:=NOTOKEN;
do_special:=0;
case l of
1 : begin { first char was a point }
case c of
'.' : begin
readchar;
token:=POINTPOINT;
goto exit_label; goto exit_label;
end; end;
')' : begin
readchar;
token:=RECKKLAMMER;
goto exit_label;
end;
end;
token:=POINT;
goto exit_label;
end;
end;
end;
{ Skip all spaces and comments } { Skip all spaces and comments }
repeat repeat
case c of case c of
'{' : skipcomment; '{' :
' ',#9..#13 : skipspace; skipcomment;
' ',#9..#13 :
skipspace;
else else
break; break;
end; end;
@ -1105,17 +1087,23 @@ implementation
begin begin
idtoken:=NOID; idtoken:=NOID;
case c of case c of
'$' : begin
'$' :
begin
readnumber; readnumber;
token:=INTCONST; token:=INTCONST;
goto exit_label; goto exit_label;
end; end;
'%' : begin
'%' :
begin
readnumber; readnumber;
token:=INTCONST; token:=INTCONST;
goto exit_label; goto exit_label;
end; end;
'0'..'9' : begin
'0'..'9' :
begin
readnumber; readnumber;
if (c in ['.','e','E']) then if (c in ['.','e','E']) then
begin begin
@ -1123,12 +1111,24 @@ implementation
if c='.' then if c='.' then
begin begin
readchar; readchar;
if not(c in ['0'..'9']) then { is it a .. from a range? }
case c of
'.' :
begin begin
do_special:=1; readchar;
token:=INTCONST; token:=INTCONST;
nexttoken:=POINTPOINT;
goto exit_label; goto exit_label;
end; end;
')' :
begin
readchar;
token:=INTCONST;
nexttoken:=RECKKLAMMER;
goto exit_label;
end;
end;
{ insert the number after the . }
pattern:=pattern+'.'; pattern:=pattern+'.';
while c in ['0'..'9'] do while c in ['0'..'9'] do
begin begin
@ -1160,30 +1160,40 @@ implementation
token:=INTCONST; token:=INTCONST;
goto exit_label; goto exit_label;
end; end;
';' : begin
';' :
begin
readchar; readchar;
token:=SEMICOLON; token:=SEMICOLON;
goto exit_label; goto exit_label;
end; end;
'[' : begin
'[' :
begin
readchar; readchar;
token:=LECKKLAMMER; token:=LECKKLAMMER;
goto exit_label; goto exit_label;
end; end;
']' : begin
']' :
begin
readchar; readchar;
token:=RECKKLAMMER; token:=RECKKLAMMER;
goto exit_label; goto exit_label;
end; end;
'(' : begin
'(' :
begin
readchar; readchar;
case c of case c of
'*' : begin '*' :
begin
skipoldtpcomment; skipoldtpcomment;
readtoken; readtoken;
exit; exit;
end; end;
'.' : begin '.' :
begin
readchar; readchar;
token:=LECKKLAMMER; token:=LECKKLAMMER;
goto exit_label; goto exit_label;
@ -1192,12 +1202,16 @@ implementation
token:=LKLAMMER; token:=LKLAMMER;
goto exit_label; goto exit_label;
end; end;
')' : begin
')' :
begin
readchar; readchar;
token:=RKLAMMER; token:=RKLAMMER;
goto exit_label; goto exit_label;
end; end;
'+' : begin
'+' :
begin
readchar; readchar;
if (c='=') and (cs_support_c_operators in aktmoduleswitches) then if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
begin begin
@ -1208,7 +1222,9 @@ implementation
token:=PLUS; token:=PLUS;
goto exit_label; goto exit_label;
end; end;
'-' : begin
'-' :
begin
readchar; readchar;
if (c='=') and (cs_support_c_operators in aktmoduleswitches) then if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
begin begin
@ -1219,7 +1235,9 @@ implementation
token:=MINUS; token:=MINUS;
goto exit_label; goto exit_label;
end; end;
':' : begin
':' :
begin
readchar; readchar;
if c='=' then if c='=' then
begin begin
@ -1230,7 +1248,9 @@ implementation
token:=COLON; token:=COLON;
goto exit_label; goto exit_label;
end; end;
'*' : begin
'*' :
begin
readchar; readchar;
if (c='=') and (cs_support_c_operators in aktmoduleswitches) then if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
begin begin
@ -1247,10 +1267,13 @@ implementation
token:=STAR; token:=STAR;
goto exit_label; goto exit_label;
end; end;
'/' : begin
'/' :
begin
readchar; readchar;
case c of case c of
'=' : begin '=' :
begin
if (cs_support_c_operators in aktmoduleswitches) then if (cs_support_c_operators in aktmoduleswitches) then
begin begin
readchar; readchar;
@ -1258,12 +1281,14 @@ implementation
goto exit_label; goto exit_label;
end; end;
end; end;
'/' : begin '/' :
begin
skipdelphicomment; skipdelphicomment;
readtoken; readtoken;
exit; exit;
end; end;
'*' : begin '*' :
begin
skipccomment; skipccomment;
readtoken; readtoken;
exit; exit;
@ -1272,20 +1297,26 @@ implementation
token:=SLASH; token:=SLASH;
goto exit_label; goto exit_label;
end; end;
'=' : begin
'=' :
begin
readchar; readchar;
token:=EQUAL; token:=EQUAL;
goto exit_label; goto exit_label;
end; end;
'.' : begin
'.' :
begin
readchar; readchar;
case c of case c of
'.' : begin '.' :
begin
readchar; readchar;
token:=POINTPOINT; token:=POINTPOINT;
goto exit_label; goto exit_label;
end; end;
')' : begin ')' :
begin
readchar; readchar;
token:=RECKKLAMMER; token:=RECKKLAMMER;
goto exit_label; goto exit_label;
@ -1294,7 +1325,9 @@ implementation
token:=POINT; token:=POINT;
goto exit_label; goto exit_label;
end; end;
'@' : begin
'@' :
begin
readchar; readchar;
if c='@' then if c='@' then
begin begin
@ -1305,12 +1338,16 @@ implementation
token:=KLAMMERAFFE; token:=KLAMMERAFFE;
goto exit_label; goto exit_label;
end; end;
',' : begin
',' :
begin
readchar; readchar;
token:=COMMA; token:=COMMA;
goto exit_label; goto exit_label;
end; end;
'''','#','^' : begin
'''','#','^' :
begin
if c='^' then if c='^' then
begin begin
readchar; readchar;
@ -1335,7 +1372,8 @@ implementation
pattern:=''; pattern:='';
repeat repeat
case c of case c of
'#' : begin '#' :
begin
readchar; { read # } readchar; { read # }
if c='$' then if c='$' then
begin begin
@ -1362,13 +1400,17 @@ implementation
Message(scan_e_illegal_char_const); Message(scan_e_illegal_char_const);
pattern:=pattern+chr(m); pattern:=pattern+chr(m);
end; end;
'''' : begin '''' :
begin
repeat repeat
readchar; readchar;
case c of case c of
#26 : Message(scan_f_end_of_file); #26 :
newline : Message(scan_f_string_exceeds_line); Message(scan_f_end_of_file);
'''' : begin newline :
Message(scan_f_string_exceeds_line);
'''' :
begin
readchar; readchar;
if c<>'''' then if c<>'''' then
break; break;
@ -1377,7 +1419,8 @@ implementation
pattern:=pattern+c; pattern:=pattern+c;
until false; until false;
end; end;
'^' : begin '^' :
begin
readchar; readchar;
if c<#64 then if c<#64 then
c:=chr(ord(c)+64) c:=chr(ord(c)+64)
@ -1397,20 +1440,25 @@ implementation
token:=CSTRING; token:=CSTRING;
goto exit_label; goto exit_label;
end; end;
'>' : begin
'>' :
begin
readchar; readchar;
case c of case c of
'=' : begin '=' :
begin
readchar; readchar;
token:=GTE; token:=GTE;
goto exit_label; goto exit_label;
end; end;
'>' : begin '>' :
begin
readchar; readchar;
token:=_SHR; token:=_SHR;
goto exit_label; goto exit_label;
end; end;
'<' : begin { >< is for a symetric diff for sets } '<' :
begin { >< is for a symetric diff for sets }
readchar; readchar;
token:=SYMDIF; token:=SYMDIF;
goto exit_label; goto exit_label;
@ -1419,20 +1467,25 @@ implementation
token:=GT; token:=GT;
goto exit_label; goto exit_label;
end; end;
'<' : begin
'<' :
begin
readchar; readchar;
case c of case c of
'>' : begin '>' :
begin
readchar; readchar;
token:=UNEQUAL; token:=UNEQUAL;
goto exit_label; goto exit_label;
end; end;
'=' : begin '=' :
begin
readchar; readchar;
token:=LTE; token:=LTE;
goto exit_label; goto exit_label;
end; end;
'<' : begin '<' :
begin
readchar; readchar;
token:=_SHL; token:=_SHL;
goto exit_label; goto exit_label;
@ -1441,7 +1494,9 @@ implementation
token:=LT; token:=LT;
goto exit_label; goto exit_label;
end; end;
#26 : begin
#26 :
begin
token:=_EOF; token:=_EOF;
goto exit_label; goto exit_label;
end; end;
@ -1582,7 +1637,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.78 1999-03-26 19:10:06 peter Revision 1.79 1999-04-01 22:05:59 peter
* '1.' is now parsed as a real
Revision 1.78 1999/03/26 19:10:06 peter
* support also ^^ * support also ^^
Revision 1.77 1999/03/26 00:05:45 peter Revision 1.77 1999/03/26 00:05:45 peter