* Helper should not be a token

git-svn-id: trunk@34671 -
This commit is contained in:
michael 2016-10-08 17:10:11 +00:00
parent 295c274940
commit caeaaad986
6 changed files with 40 additions and 8 deletions

View File

@ -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]]);

View File

@ -139,7 +139,6 @@ type
tkfunction,
tkgeneric,
tkgoto,
tkHelper,
tkif,
tkimplementation,
tkin,
@ -501,7 +500,6 @@ const
'function',
'generic',
'goto',
'helper',
'if',
'implementation',
'in',

View File

@ -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;

View File

@ -895,7 +895,7 @@ end;
procedure TTestScanner.TestHelper;
begin
TestToken(tkHelper,'helper');
TestToken(tkIdentifier,'helper');
end;

View File

@ -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');

View File

@ -30,7 +30,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="--suite=TTestTypeParser.TestRangeLowHigh"/>
<CommandLineParams Value="--suite=TTestVarParser.TestSimpleVarHelper"/>
</local>
</RunParams>
<RequiredPackages Count="1">