mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 17:50:43 +02:00
* Helper should not be a token
git-svn-id: trunk@34671 -
This commit is contained in:
parent
295c274940
commit
caeaaad986
@ -1249,7 +1249,7 @@ begin
|
||||
tkType:
|
||||
begin
|
||||
NextToken;
|
||||
isHelper:=Curtoken=tkHelper;
|
||||
isHelper:=CurTokenIsIdentifier('helper');
|
||||
UnGetToken;
|
||||
if isHelper then
|
||||
Result:=ParseClassDecl(Parent,NamePos,TypeName,okTypeHelper,PM)
|
||||
@ -1268,7 +1268,7 @@ begin
|
||||
tkRecord:
|
||||
begin
|
||||
NextToken;
|
||||
if (Curtoken=tkHelper) then
|
||||
if CurTokenIsIdentifier('Helper') then
|
||||
begin
|
||||
UnGetToken;
|
||||
Result:=ParseClassDecl(Parent,NamePos,TypeName,okRecordHelper,PM);
|
||||
@ -4676,7 +4676,7 @@ begin
|
||||
break;
|
||||
UngetToken;
|
||||
ExpectToken(tkComma);
|
||||
Element:=ParseType(AType,Scanner.CurSourcePos); // search interface.
|
||||
Element:=ParseType(AType,Scanner.CurSourcePos,'',False); // search interface.
|
||||
if assigned(element) then
|
||||
AType.Interfaces.add(element);
|
||||
end;
|
||||
@ -4727,7 +4727,7 @@ begin
|
||||
TPasClassOfType(Result).DestType := ParseType(Result,Scanner.CurSourcePos);
|
||||
exit;
|
||||
end;
|
||||
if (CurToken = tkHelper) then
|
||||
if (CurTokenIsIdentifier('Helper')) then
|
||||
begin
|
||||
if Not (AObjKind in [okClass,okTypeHelper,okRecordHelper]) then
|
||||
ParseExc(nParserHelperNotAllowed,SParserHelperNotAllowed,[ObjKindNames[AObjKind]]);
|
||||
|
@ -139,7 +139,6 @@ type
|
||||
tkfunction,
|
||||
tkgeneric,
|
||||
tkgoto,
|
||||
tkHelper,
|
||||
tkif,
|
||||
tkimplementation,
|
||||
tkin,
|
||||
@ -501,7 +500,6 @@ const
|
||||
'function',
|
||||
'generic',
|
||||
'goto',
|
||||
'helper',
|
||||
'if',
|
||||
'implementation',
|
||||
'in',
|
||||
|
@ -73,6 +73,7 @@ type
|
||||
Procedure TestOneField;
|
||||
Procedure TestOneFieldComment;
|
||||
procedure TestOneFieldStatic;
|
||||
Procedure TestOneHelperField;
|
||||
Procedure TestOneVarField;
|
||||
Procedure TestOneClassField;
|
||||
Procedure TestOneFieldVisibility;
|
||||
@ -524,6 +525,15 @@ begin
|
||||
AssertTrue('Have static field',vmStatic in TPasVariable(Field1).VarModifiers);
|
||||
end;
|
||||
|
||||
procedure TTestClassType.TestOneHelperField;
|
||||
begin
|
||||
AddMember('helper : integer');
|
||||
ParseClass;
|
||||
AssertNotNull('Have 1 field',Field1);
|
||||
AssertMemberName('helper');
|
||||
AssertVisibility;
|
||||
end;
|
||||
|
||||
procedure TTestClassType.TestOneFieldComment;
|
||||
begin
|
||||
AddComment:=true;
|
||||
|
@ -895,7 +895,7 @@ end;
|
||||
|
||||
procedure TTestScanner.TestHelper;
|
||||
begin
|
||||
TestToken(tkHelper,'helper');
|
||||
TestToken(tkIdentifier,'helper');
|
||||
end;
|
||||
|
||||
|
||||
|
@ -26,6 +26,8 @@ Type
|
||||
Procedure TearDown; override;
|
||||
Published
|
||||
Procedure TestSimpleVar;
|
||||
Procedure TestSimpleVarHelperName;
|
||||
procedure TestSimpleVarHelperType;
|
||||
Procedure TestSimpleVarDeprecated;
|
||||
Procedure TestSimpleVarPlatform;
|
||||
Procedure TestSimpleVarInitialized;
|
||||
@ -120,6 +122,28 @@ begin
|
||||
AssertVariableType('b');
|
||||
end;
|
||||
|
||||
procedure TTestVarParser.TestSimpleVarHelperName;
|
||||
|
||||
Var
|
||||
R : TPasVariable;
|
||||
|
||||
begin
|
||||
Add('Var');
|
||||
Add(' Helper : integer;');
|
||||
// Writeln(source.text);
|
||||
ParseDeclarations;
|
||||
AssertEquals('One variable definition',1,Declarations.Variables.Count);
|
||||
AssertEquals('First declaration is type definition.',TPasVariable,TObject(Declarations.Variables[0]).ClassType);
|
||||
R:=TPasVariable(Declarations.Variables[0]);
|
||||
AssertEquals('First declaration has correct name.','Helper',R.Name);
|
||||
end;
|
||||
|
||||
procedure TTestVarParser.TestSimpleVarHelperType;
|
||||
begin
|
||||
ParseVar('helper','');
|
||||
AssertVariableType('helper');
|
||||
end;
|
||||
|
||||
procedure TTestVarParser.TestSimpleVarDeprecated;
|
||||
begin
|
||||
ParseVar('b','deprecated');
|
||||
|
@ -30,7 +30,7 @@
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<CommandLineParams Value="--suite=TTestTypeParser.TestRangeLowHigh"/>
|
||||
<CommandLineParams Value="--suite=TTestVarParser.TestSimpleVarHelper"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
|
Loading…
Reference in New Issue
Block a user