+ constant postfixoperator_tokens

+ check for postfix operators after string contants, resolves #23136

git-svn-id: trunk@22929 -
This commit is contained in:
florian 2012-11-04 19:21:19 +00:00
parent 2038a607ac
commit bc4a8ac63e
4 changed files with 32 additions and 5 deletions

1
.gitattributes vendored
View File

@ -12967,6 +12967,7 @@ tests/webtbs/tw2305.pp svneol=native#text/plain
tests/webtbs/tw2306.pp svneol=native#text/plain
tests/webtbs/tw2307.pp svneol=native#text/plain
tests/webtbs/tw2311.pp svneol=native#text/plain
tests/webtbs/tw23136.pp svneol=native#text/pascal
tests/webtbs/tw2317.pp svneol=native#text/plain
tests/webtbs/tw2318.pp svneol=native#text/plain
tests/webtbs/tw23185.pp svneol=native#text/pascal

View File

@ -2814,6 +2814,11 @@ implementation
begin
p1:=cstringconstnode.createpchar(ansistring2pchar(cstringpattern),length(cstringpattern));
consume(_CSTRING);
if token in postfixoperator_tokens then
begin
again:=true;
postfixoperators(p1,again,getaddr);
end;
end;
_CCHAR :
@ -2826,6 +2831,11 @@ implementation
begin
p1:=cstringconstnode.createunistr(patternw);
consume(_CWSTRING);
if token in postfixoperator_tokens then
begin
again:=true;
postfixoperators(p1,again,getaddr);
end;
end;
_CWCHAR:
@ -2842,7 +2852,7 @@ implementation
if try_to_consume(_LKLAMMER) then
begin
p1:=factor(true,false);
if token in [_CARET,_POINT,_LECKKLAMMER] then
if token in postfixoperator_tokens then
begin
again:=true;
postfixoperators(p1,again,getaddr);
@ -2852,7 +2862,7 @@ implementation
end
else
p1:=factor(true,false);
if token in [_CARET,_POINT,_LECKKLAMMER] then
if token in postfixoperator_tokens then
begin
again:=true;
postfixoperators(p1,again,getaddr);
@ -2875,9 +2885,9 @@ implementation
consume(_LKLAMMER);
p1:=comp_expr(true,false);
consume(_RKLAMMER);
{ it's not a good solution }
{ but (a+b)^ makes some problems }
if token in [_CARET,_POINT,_LECKKLAMMER] then
{ it's not a good solution
but (a+b)^ makes some problems }
if token in postfixoperator_tokens then
begin
again:=true;
postfixoperators(p1,again,getaddr);

View File

@ -299,6 +299,8 @@ const
tokenlenmin = 1;
tokenlenmax = 18;
postfixoperator_tokens = [_CARET,_POINT,_LECKKLAMMER];
{ last operator which can be overloaded, the first_overloaded should
be declared directly after NOTOKEN }
first_overloaded = succ(NOTOKEN);

14
tests/webtbs/tw23136.pp Normal file
View File

@ -0,0 +1,14 @@
var
ws:widestring;
s:string;
begin
s:='Aajsljaklsja'[1];
if s<>'A' then
halt(1);
ws:=#1234#134#312[1];
if ws<>#1234 then
halt(1);
writeln('ok');
end.