Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Demo/uMainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ function TIncludeHandler.GetIncludeFileContent(const FileName: string): string;
begin
FileContent := TStringList.Create;
try
if not FileExists(TPath.Combine(FPath, FileName)) then
begin
Result := '';
Exit;
end;

FileContent.LoadFromFile(TPath.Combine(FPath, FileName));
Result := FileContent.Text;
finally
Expand Down
77 changes: 19 additions & 58 deletions Source/SimpleParser/SimpleParser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1152,13 +1152,7 @@ procedure TmwSimplePasPar.UnitFile;
begin
Expected(ptUnit);
UnitName;
while ExID in [ptDeprecated, ptLibrary, ptPlatform, ptExperimental] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
ptExperimental: NextToken;
end;
TypeDirective;

Semicolon;
InterfaceSection;
Expand Down Expand Up @@ -3090,12 +3084,8 @@ procedure TmwSimplePasPar.VarDeclaration;
VarNameList;
Expected(ptColon);
TypeKind;
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;

case GenID of
ptAbsolute:
begin
Expand All @@ -3106,12 +3096,7 @@ procedure TmwSimplePasPar.VarDeclaration;
VarEqual;
end;
end;
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;
end;

procedure TmwSimplePasPar.VarAbsolute;
Expand Down Expand Up @@ -3232,12 +3217,7 @@ procedure TmwSimplePasPar.FieldDeclaration;
FieldNameList;
Expected(ptColon);
TypeKind;
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;
end;

procedure TmwSimplePasPar.FieldList;
Expand Down Expand Up @@ -3968,12 +3948,7 @@ procedure TmwSimplePasPar.ClassField;
FieldNameList;
Expected(ptColon);
TypeKind;
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;
end;

procedure TmwSimplePasPar.ObjectType;
Expand Down Expand Up @@ -4075,12 +4050,7 @@ procedure TmwSimplePasPar.ObjectField;
IdentifierList;
Expected(ptColon);
TypeKind;
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;
end;

procedure TmwSimplePasPar.ClassReferenceType;
Expand Down Expand Up @@ -4628,12 +4598,7 @@ procedure TmwSimplePasPar.ResourceDeclaration;

ResourceValue;

while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;
end;

procedure TmwSimplePasPar.ResourceValue;
Expand Down Expand Up @@ -4663,12 +4628,7 @@ procedure TmwSimplePasPar.ConstantDeclaration;
SynError(InvalidConstantDeclaration);
end;
end;
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
end;
TypeDirective;
end;

procedure TmwSimplePasPar.ConstantColon;
Expand Down Expand Up @@ -4776,7 +4736,7 @@ procedure TmwSimplePasPar.LabelDeclarationSection;

procedure TmwSimplePasPar.ProceduralDirective;
begin
case ExID of
case GenID of
ptAbstract:
begin
DirectiveBinding;
Expand Down Expand Up @@ -5257,9 +5217,9 @@ procedure TmwSimplePasPar.IdentifierList;

procedure TmwSimplePasPar.CharString;
begin
case TokenID of
case GenID of
ptAsciiChar, ptIdentifier, ptRoundOpen, ptStringConst:
while TokenID in
while GenID in
[ptAsciiChar, ptIdentifier, ptRoundOpen, ptStringConst, ptString] do
begin
case TokenID of
Expand Down Expand Up @@ -5434,7 +5394,7 @@ procedure TmwSimplePasPar.DirectiveDeprecated;

procedure TmwSimplePasPar.DirectiveLibrary;
begin
ExpectedEx(ptLibrary);
Expected(ptLibrary);
end;

procedure TmwSimplePasPar.DirectivePlatform;
Expand Down Expand Up @@ -5613,11 +5573,12 @@ procedure TmwSimplePasPar.ProceduralDirectiveOf;

procedure TmwSimplePasPar.TypeDirective;
begin
while ExID in [ptDeprecated, ptLibrary, ptPlatform] do
case ExID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
while GenID in [ptDeprecated, ptLibrary, ptPlatform, ptExperimental] do
case GenID of
ptDeprecated: DirectiveDeprecated;
ptLibrary: DirectiveLibrary;
ptPlatform: DirectivePlatform;
ptExperimental: NextToken;
end;
end;

Expand Down
11 changes: 11 additions & 0 deletions Test/Snippets/DeprecatedOnConst.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
unit DeprecatedOnConst;

interface

const
MyConst = 'test' deprecated 'Do not use';
MyConst2 = 'test2' platform;
MyConst3 = 'test4' library;

implementation
end.
1 change: 1 addition & 0 deletions Test/uMainForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object Form2: TForm2
Font.Name = 'Lucida Console'
Font.Style = []
ParentFont = False
ScrollBars = ssBoth
TabOrder = 0
end
object btnRun: TButton
Expand Down