* 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: tkType:
begin begin
NextToken; NextToken;
isHelper:=Curtoken=tkHelper; isHelper:=CurTokenIsIdentifier('helper');
UnGetToken; UnGetToken;
if isHelper then if isHelper then
Result:=ParseClassDecl(Parent,NamePos,TypeName,okTypeHelper,PM) Result:=ParseClassDecl(Parent,NamePos,TypeName,okTypeHelper,PM)
@ -1268,7 +1268,7 @@ begin
tkRecord: tkRecord:
begin begin
NextToken; NextToken;
if (Curtoken=tkHelper) then if CurTokenIsIdentifier('Helper') then
begin begin
UnGetToken; UnGetToken;
Result:=ParseClassDecl(Parent,NamePos,TypeName,okRecordHelper,PM); Result:=ParseClassDecl(Parent,NamePos,TypeName,okRecordHelper,PM);
@ -4676,7 +4676,7 @@ begin
break; break;
UngetToken; UngetToken;
ExpectToken(tkComma); ExpectToken(tkComma);
Element:=ParseType(AType,Scanner.CurSourcePos); // search interface. Element:=ParseType(AType,Scanner.CurSourcePos,'',False); // search interface.
if assigned(element) then if assigned(element) then
AType.Interfaces.add(element); AType.Interfaces.add(element);
end; end;
@ -4727,7 +4727,7 @@ begin
TPasClassOfType(Result).DestType := ParseType(Result,Scanner.CurSourcePos); TPasClassOfType(Result).DestType := ParseType(Result,Scanner.CurSourcePos);
exit; exit;
end; end;
if (CurToken = tkHelper) then if (CurTokenIsIdentifier('Helper')) then
begin begin
if Not (AObjKind in [okClass,okTypeHelper,okRecordHelper]) then if Not (AObjKind in [okClass,okTypeHelper,okRecordHelper]) then
ParseExc(nParserHelperNotAllowed,SParserHelperNotAllowed,[ObjKindNames[AObjKind]]); ParseExc(nParserHelperNotAllowed,SParserHelperNotAllowed,[ObjKindNames[AObjKind]]);

View File

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

View File

@ -73,6 +73,7 @@ type
Procedure TestOneField; Procedure TestOneField;
Procedure TestOneFieldComment; Procedure TestOneFieldComment;
procedure TestOneFieldStatic; procedure TestOneFieldStatic;
Procedure TestOneHelperField;
Procedure TestOneVarField; Procedure TestOneVarField;
Procedure TestOneClassField; Procedure TestOneClassField;
Procedure TestOneFieldVisibility; Procedure TestOneFieldVisibility;
@ -524,6 +525,15 @@ begin
AssertTrue('Have static field',vmStatic in TPasVariable(Field1).VarModifiers); AssertTrue('Have static field',vmStatic in TPasVariable(Field1).VarModifiers);
end; end;
procedure TTestClassType.TestOneHelperField;
begin
AddMember('helper : integer');
ParseClass;
AssertNotNull('Have 1 field',Field1);
AssertMemberName('helper');
AssertVisibility;
end;
procedure TTestClassType.TestOneFieldComment; procedure TTestClassType.TestOneFieldComment;
begin begin
AddComment:=true; AddComment:=true;

View File

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

View File

@ -26,6 +26,8 @@ Type
Procedure TearDown; override; Procedure TearDown; override;
Published Published
Procedure TestSimpleVar; Procedure TestSimpleVar;
Procedure TestSimpleVarHelperName;
procedure TestSimpleVarHelperType;
Procedure TestSimpleVarDeprecated; Procedure TestSimpleVarDeprecated;
Procedure TestSimpleVarPlatform; Procedure TestSimpleVarPlatform;
Procedure TestSimpleVarInitialized; Procedure TestSimpleVarInitialized;
@ -120,6 +122,28 @@ begin
AssertVariableType('b'); AssertVariableType('b');
end; 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; procedure TTestVarParser.TestSimpleVarDeprecated;
begin begin
ParseVar('b','deprecated'); ParseVar('b','deprecated');

View File

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