diff --git a/Demo/uMainForm.pas b/Demo/uMainForm.pas index a4b315d8..e0546199 100644 --- a/Demo/uMainForm.pas +++ b/Demo/uMainForm.pas @@ -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 diff --git a/Source/SimpleParser/SimpleParser.pas b/Source/SimpleParser/SimpleParser.pas index 04642a61..b17b10b6 100644 --- a/Source/SimpleParser/SimpleParser.pas +++ b/Source/SimpleParser/SimpleParser.pas @@ -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; @@ -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 @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -4776,7 +4736,7 @@ procedure TmwSimplePasPar.LabelDeclarationSection; procedure TmwSimplePasPar.ProceduralDirective; begin - case ExID of + case GenID of ptAbstract: begin DirectiveBinding; @@ -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 @@ -5434,7 +5394,7 @@ procedure TmwSimplePasPar.DirectiveDeprecated; procedure TmwSimplePasPar.DirectiveLibrary; begin - ExpectedEx(ptLibrary); + Expected(ptLibrary); end; procedure TmwSimplePasPar.DirectivePlatform; @@ -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; diff --git a/Test/Snippets/DeprecatedOnConst.pas b/Test/Snippets/DeprecatedOnConst.pas new file mode 100644 index 00000000..8d27ffc5 --- /dev/null +++ b/Test/Snippets/DeprecatedOnConst.pas @@ -0,0 +1,11 @@ +unit DeprecatedOnConst; + +interface + +const + MyConst = 'test' deprecated 'Do not use'; + MyConst2 = 'test2' platform; + MyConst3 = 'test4' library; + +implementation +end. diff --git a/Test/uMainForm.dfm b/Test/uMainForm.dfm index 36ad39d2..6198193b 100644 --- a/Test/uMainForm.dfm +++ b/Test/uMainForm.dfm @@ -28,6 +28,7 @@ object Form2: TForm2 Font.Name = 'Lucida Console' Font.Style = [] ParentFont = False + ScrollBars = ssBoth TabOrder = 0 end object btnRun: TButton