+ support for & and % in char constants, resolves #12186

git-svn-id: trunk@11809 -
This commit is contained in:
florian 2008-09-20 19:51:29 +00:00
parent 6b0d250ea6
commit 69159eb9f3
3 changed files with 53 additions and 19 deletions

1
.gitattributes vendored
View File

@ -8556,6 +8556,7 @@ tests/webtbs/tw12050a.pp svneol=native#text/plain
tests/webtbs/tw12050b.pp svneol=native#text/plain
tests/webtbs/tw12051.pp svneol=native#text/plain
tests/webtbs/tw1207.pp svneol=native#text/plain
tests/webtbs/tw12186.pp svneol=native#text/plain
tests/webtbs/tw1222.pp svneol=native#text/plain
tests/webtbs/tw1223.pp svneol=native#text/plain
tests/webtbs/tw1228.pp svneol=native#text/plain

View File

@ -3649,25 +3649,47 @@ In case not, the value returned can be arbitrary.
'#' :
begin
readchar; { read # }
if c='$' then
begin
readchar; { read leading $ }
asciinr:='$';
while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<6) do
begin
asciinr:=asciinr+c;
readchar;
end;
end
else
begin
asciinr:='';
while (c in ['0'..'9']) and (length(asciinr)<6) do
begin
asciinr:=asciinr+c;
readchar;
end;
end;
case c of
'$':
begin
readchar; { read leading $ }
asciinr:='$';
while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<=5) do
begin
asciinr:=asciinr+c;
readchar;
end;
end;
'&':
begin
readchar; { read leading $ }
asciinr:='&';
while (upcase(c) in ['0'..'7']) and (length(asciinr)<=7) do
begin
asciinr:=asciinr+c;
readchar;
end;
end;
'%':
begin
readchar; { read leading $ }
asciinr:='%';
while (upcase(c) in ['0','1']) and (length(asciinr)<=17) do
begin
asciinr:=asciinr+c;
readchar;
end;
end;
else
begin
asciinr:='';
while (c in ['0'..'9']) and (length(asciinr)<=5) do
begin
asciinr:=asciinr+c;
readchar;
end;
end;
end;
val(asciinr,m,code);
if (asciinr='') or (code<>0) then
Message(scan_e_illegal_char_const)

11
tests/webtbs/tw12186.pp Normal file
View File

@ -0,0 +1,11 @@
{$mode objfpc}
begin
writeln(13); // ok
writeln($d); // ok
writeln(&15); // ok
writeln(%1101); // ok
writeln(0000098); // ok
writeln(#$62); // ok
writeln(#&142); // error!
writeln(#%1100010); // error!
end.