diff --git a/Demo/DelphiASTDemo.dproj b/Demo/DelphiASTDemo.dproj index 3d040ab1..978aa9a0 100644 --- a/Demo/DelphiASTDemo.dproj +++ b/Demo/DelphiASTDemo.dproj @@ -1,7 +1,7 @@  {6DAA4B8F-6103-4418-BAA9-E92227FE34C9} - 17.2 + 18.1 VCL DelphiASTDemo.dpr True @@ -49,6 +49,7 @@ false + true Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) true IndyIPClient;FireDACASADriver;FireDACSqliteDriver;bindcompfmx;FireDACDSDriver;DBXSqliteDriver;vcldbx;FireDACPgDriver;FireDACODBCDriver;RESTBackendComponents;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;inetdb;tethering;inetdbbde;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DBXOdbcDriver;vclFireDAC;DataSnapProviderClient;xmlrtl;DataSnapNativeClient;DBXSybaseASEDriver;DbxCommonDriver;svnui;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;DatasnapConnectorsFreePascal;FireDACCommonDriver;MetropolisUILiveTile;bindcompdbx;bindengine;vclactnband;vcldb;soaprtl;vcldsnap;bindcompvcl;vclie;fmxFireDAC;FireDACADSDriver;DBXDb2Driver;vcltouch;DBXOracleDriver;CustomIPTransport;vclribbon;VclSmp;FireDACMSSQLDriver;FireDAC;dsnap;DBXInformixDriver;fmxase;vcl;IndyCore;IndyIPServer;DataSnapServerMidas;DBXMSSQLDriver;IndyIPCommon;VCLRESTComponents;dsnapcon;FireDACIBDriver;DBXFirebirdDriver;inet;CloudService;DataSnapFireDAC;fmxobj;DataSnapConnectors;FireDACDBXDriver;FireDACMySQLDriver;soapmidas;vclx;soapserver;inetdbxpress;CodeSiteExpressPkg;svn;DBXSybaseASADriver;dsnapxml;FireDACOracleDriver;FireDACInfxDriver;FireDACDb2Driver;fmxdae;RESTComponents;bdertl;FireDACMSAccDriver;dbexpress;DataSnapIndy10ServerTransport;adortl;$(DCC_UsePackage) diff --git a/Demo/DelphiASTDemo.res b/Demo/DelphiASTDemo.res index d6cf6329..49961f02 100644 Binary files a/Demo/DelphiASTDemo.res and b/Demo/DelphiASTDemo.res differ diff --git a/Demo/uMainForm.dfm b/Demo/uMainForm.dfm index 7691298a..510fb4bd 100644 --- a/Demo/uMainForm.dfm +++ b/Demo/uMainForm.dfm @@ -18,10 +18,24 @@ object MainForm: TMainForm Left = 0 Top = 0 Width = 666 - Height = 389 + Height = 370 Align = alClient ScrollBars = ssBoth TabOrder = 0 + ExplicitHeight = 389 + end + object StatusBar: TStatusBar + Left = 0 + Top = 370 + Width = 666 + Height = 19 + Panels = < + item + Width = 50 + end> + ExplicitLeft = 344 + ExplicitTop = 216 + ExplicitWidth = 0 end object MainMenu: TMainMenu Left = 224 diff --git a/Demo/uMainForm.pas b/Demo/uMainForm.pas index e0546199..5ac000ae 100644 --- a/Demo/uMainForm.pas +++ b/Demo/uMainForm.pas @@ -6,7 +6,7 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, Menus, StdCtrls, SimpleParser.Lexer.Types; + Dialogs, Menus, StdCtrls, ComCtrls; type TMainForm = class(TForm) @@ -14,28 +14,20 @@ TMainForm = class(TForm) MainMenu: TMainMenu; OpenDelphiUnit1: TMenuItem; OpenDialog: TOpenDialog; + StatusBar: TStatusBar; procedure OpenDelphiUnit1Click(Sender: TObject); - private - function Parse(const FileName: string): string; - public - { Public declarations } - end; - - TIncludeHandler = class(TInterfacedObject, IIncludeHandler) - private - FPath: string; - public - constructor Create(const Path: string); - function GetIncludeFileContent(const FileName: string): string; end; var MainForm: TMainForm; +function Parse(const FileName: string; out StatusText: string): string; + implementation uses - DelphiAST, DelphiAST.Writer, DelphiAST.Classes, IOUtils; + DelphiAST, DelphiAST.Writer, DelphiAST.Classes, + SimpleParser.Lexer.Types, IOUtils, Diagnostics; {$IFNDEF FPC} {$R *.dfm} @@ -43,13 +35,37 @@ implementation {$R *.lfm} {$ENDIF} -function TMainForm.Parse(const FileName: string): string; +type + TIncludeHandler = class(TInterfacedObject, IIncludeHandler) + private + FPath: string; + public + constructor Create(const Path: string); + function GetIncludeFileContent(const FileName: string): string; + end; + +function MemoryUsed: Cardinal; +var + st: TMemoryManagerState; + sb: TSmallBlockTypeState; +begin + GetMemoryManagerState(st); + Result := st.TotalAllocatedMediumBlockSize + st.TotalAllocatedLargeBlockSize; + for sb in st.SmallBlockTypeStates do + Result := Result + sb.UseableBlockSize * sb.AllocatedBlockCount; +end; + +function Parse(const FileName: string; out StatusText: string): string; var SyntaxTree: TSyntaxNode; + memused: Cardinal; + sw: TStopwatch; begin - Result := ''; try + sw := TStopwatch.StartNew; + memused := MemoryUsed; SyntaxTree := TPasSyntaxTreeBuilder.Run(FileName, False, TIncludeHandler.Create(ExtractFilePath(FileName))); + StatusText := Format('Parsed file in %d ms - used memory: %d K', [sw.ElapsedMilliseconds, (MemoryUsed - memused) div 1024]); try Result := TSyntaxTreeWriter.ToXML(SyntaxTree, True); finally @@ -63,9 +79,14 @@ function TMainForm.Parse(const FileName: string): string; end; procedure TMainForm.OpenDelphiUnit1Click(Sender: TObject); +var + StatusText: string; begin if OpenDialog.Execute then - OutputMemo.Lines.Text := Parse(OpenDialog.FileName); + begin + OutputMemo.Lines.Text := Parse(OpenDialog.FileName, StatusText); + StatusBar.Panels[0].Text := StatusText; + end end; { TIncludeHandler } diff --git a/Source/DelphiAST.Classes.pas b/Source/DelphiAST.Classes.pas index fbccda28..3ed0f62c 100644 --- a/Source/DelphiAST.Classes.pas +++ b/Source/DelphiAST.Classes.pas @@ -121,9 +121,6 @@ TOperatorInfo = record TOperators = class strict private - class var FOps: TDictionary; - class constructor Create; - class destructor Destroy; class function GetItem(Typ: TSyntaxNodeType): TOperatorInfo; static; public class function IsOpName(Typ: TSyntaxNodeType): Boolean; @@ -163,29 +160,23 @@ TOperators = class { TOperators } -class constructor TOperators.Create; -var - I: Integer; -begin - FOps := TDictionary.Create; - - for I := Low(OperatorsInfo) to High(OperatorsInfo) do - FOps.Add(OperatorsInfo[I].Typ, OperatorsInfo[I]); -end; - -class destructor TOperators.Destroy; -begin - FOps.Free; -end; - class function TOperators.GetItem(Typ: TSyntaxNodeType): TOperatorInfo; +var + i: Integer; begin - Result := FOps[Typ]; + for i := 0 to High(OperatorsInfo) do + if OperatorsInfo[i].Typ = Typ then + Exit(OperatorsInfo[i]); end; class function TOperators.IsOpName(Typ: TSyntaxNodeType): Boolean; +var + i: Integer; begin - Result := FOps.ContainsKey(Typ); + for i := 0 to High(OperatorsInfo) do + if OperatorsInfo[i].Typ = Typ then + Exit(True); + Result := False; end; function IsRoundClose(Typ: TSyntaxNodeType): Boolean; inline; @@ -362,31 +353,30 @@ class procedure TExpressionTools.RawNodeListToTree(RawParentNode: TSyntaxNode; R procedure TSyntaxNode.SetAttribute(const Key: TAttributeName; const Value: string); var AttributeEntry: PAttributeEntry; - NewAttributeEntry: TAttributeEntry; + len: Integer; begin - if TryGetAttributeEntry(Key, AttributeEntry) then - AttributeEntry^.Value := Value - else + if not TryGetAttributeEntry(Key, AttributeEntry) then begin - NewAttributeEntry.Key := Key; - NewAttributeEntry.Value := Value; - SetLength(FAttributes, Length(FAttributes) + 1); - FAttributes[Length(FAttributes) - 1] := NewAttributeEntry; + len := Length(FAttributes); + SetLength(FAttributes, len + 1); + AttributeEntry := @FAttributes[len]; + AttributeEntry^.Key := Key; end; + AttributeEntry^.Value := Value; end; function TSyntaxNode.TryGetAttributeEntry(const Key: TAttributeName; var AttributeEntry: PAttributeEntry): boolean; var i: integer; begin - for i := 0 to Length(FAttributes) - 1 do + for i := 0 to High(FAttributes) do if FAttributes[i].Key = Key then begin AttributeEntry := @FAttributes[i]; - Exit(true); + Exit(True); end; - Exit(false); + Result := False; end; function TSyntaxNode.AddChild(Node: TSyntaxNode): TSyntaxNode; @@ -408,16 +398,18 @@ function TSyntaxNode.AddChild(Typ: TSyntaxNodeType): TSyntaxNode; function TSyntaxNode.Clone: TSyntaxNode; var - ChildNode: TSyntaxNode; - Attr: TPair; + i: Integer; begin Result := TSyntaxNodeClass(Self.ClassType).Create(FTyp); - for ChildNode in FChildNodes do - Result.AddChild(ChildNode.Clone); + SetLength(Result.FChildNodes, Length(FChildNodes)); + for i := 0 to High(FChildNodes) do + begin + Result.FChildNodes[i] := FChildNodes[i].Clone; + Result.FChildNodes[i].FParentNode := Result; + end; - for Attr in FAttributes do - Result.SetAttribute(Attr.Key, Attr.Value); + Result.FAttributes := Copy(FAttributes); Result.Col := Self.Col; Result.Line := Self.Line; @@ -428,29 +420,20 @@ constructor TSyntaxNode.Create(Typ: TSyntaxNodeType); begin inherited Create; FTyp := Typ; - SetLength(FAttributes, 0); - SetLength(FChildNodes, 0); - FParentNode := nil; end; procedure TSyntaxNode.ExtractChild(Node: TSyntaxNode); var - NodeIndex, i: integer; + i: integer; begin - NodeIndex := -1; - for i := 0 to Length(FChildNodes) - 1 do + for i := 0 to High(FChildNodes) do if FChildNodes[i] = Node then begin - NodeIndex := i; - break; + if i < High(FChildNodes) then + Move(FChildNodes[i + 1], FChildNodes[i], SizeOf(TSyntaxNode) * (Length(FChildNodes) - i - 1)); + SetLength(FChildNodes, High(FChildNodes)); + Break; end; - - if NodeIndex >= 0 then - begin - if NodeIndex < High(FChildNodes) then - Move(FChildNodes[NodeIndex + 1], FChildNodes[NodeIndex], SizeOf(FChildNodes[0]) * (Length(FChildNodes) - NodeIndex - 1)); - SetLength(FChildNodes, Length(FChildNodes) - 1); - end; end; procedure TSyntaxNode.DeleteChild(Node: TSyntaxNode); @@ -463,25 +446,19 @@ destructor TSyntaxNode.Destroy; var i: integer; begin - for i := 0 to Length(FChildNodes) - 1 do - FChildNodes[i].Free; - SetLength(FChildNodes, 0); - - SetLength(FAttributes, 0); + for i := 0 to High(FChildNodes) do + FreeAndNil(FChildNodes[i]); inherited; end; function TSyntaxNode.FindNode(Typ: TSyntaxNodeType): TSyntaxNode; var - Node: TSyntaxNode; + i: Integer; begin + for i := 0 to High(FChildNodes) do + if FChildNodes[i].Typ = Typ then + Exit(FChildNodes[i]); Result := nil; - for Node in FChildNodes do - if Node.Typ = Typ then - begin - Result := Node; - Break; - end; end; function TSyntaxNode.GetAttribute(const Key: TAttributeName): string; diff --git a/Source/DelphiAST.Consts.pas b/Source/DelphiAST.Consts.pas index 51161750..863f968e 100644 --- a/Source/DelphiAST.Consts.pas +++ b/Source/DelphiAST.Consts.pas @@ -289,17 +289,7 @@ interface 'slashescomment' ); -const - sENUM = 'enum'; - sSUBRANGE = 'subrange'; - - function AttributeNameToStr(const AttributeName : TAttributeName) : string; - -implementation - -function AttributeNameToStr(const AttributeName : TAttributeName) : string; -const - AttributeNameStrings : array[TAttributeName] of string = ( + AttributeNameStrings: array[TAttributeName] of string = ( 'type', 'class', 'forwarded', @@ -313,8 +303,7 @@ function AttributeNameToStr(const AttributeName : TAttributeName) : string; 'overload', 'abstract' ); -begin - Exit(AttributeNameStrings[AttributeName]); -end; + +implementation end. diff --git a/Source/DelphiAST.Writer.pas b/Source/DelphiAST.Writer.pas index 144fdc18..78041e75 100644 --- a/Source/DelphiAST.Writer.pas +++ b/Source/DelphiAST.Writer.pas @@ -94,7 +94,7 @@ class procedure TSyntaxTreeWriter.NodeToXML(const Builder: TStringBuilder; Builder.Append(' value="' + XMLEncode(TValuedSyntaxNode(Node).Value) + '"'); for Attr in Node.Attributes do - Builder.Append(' ' + AttributeNameToStr(Attr.Key) + '="' + XMLEncode(Attr.Value) + '"'); + Builder.Append(' ' + AttributeNameStrings[Attr.Key] + '="' + XMLEncode(Attr.Value) + '"'); if HasChildren then Builder.Append('>') else diff --git a/Source/DelphiAST.pas b/Source/DelphiAST.pas index 79071c66..31dc1afc 100644 --- a/Source/DelphiAST.pas +++ b/Source/DelphiAST.pas @@ -1,11 +1,11 @@ unit DelphiAST; -{$IFDEF FPC}{$MODE DELPHI}{$ENDIF} +{$IFDEF FPC}{$MODE DELPHI}{$ENDIF} interface uses - SysUtils, Classes, Generics.Collections, SimpleParser, + SysUtils, Classes, Generics.Collections, SimpleParser, SimpleParser.Lexer, SimpleParser.Lexer.Types, DelphiAST.Classes, DelphiAST.Consts; type @@ -21,12 +21,12 @@ ESyntaxTreeException = class(EParserException) TNodeStack = class strict private - FParser: TmwSimplePasPar; + FLexer: TmwPasLex; FStack: TStack; function GetCount: Integer; public - constructor Create(Parser: TmwSimplePasPar); + constructor Create(Lexer: TmwPasLex); destructor Destroy; override; function AddChild(Typ: TSyntaxNodeType): TSyntaxNode; overload; @@ -242,6 +242,9 @@ TPasSyntaxTreeBuilder = class(TmwSimplePasPar) implementation +uses + TypInfo; + {$IFDEF FPC} type @@ -272,6 +275,109 @@ TStringStreamHelper = class helper for TStringStream {$ENDIF} +// do not use const strings here to prevent allocating new strings every time + +type + TAttributeValue = (atAsm, atTrue, atFunction, atProcedure, atClassOf, atClass, + atConst, atConstructor, atDestructor, atEnum, atInterface, atNil, atNumeric, + atOut, atPointer, atName, atString, atSubRange, atVar); + +var + AttributeValues: array[TAttributeValue] of string; + +procedure InitAttributeValues; +var + value: TAttributeValue; +begin + for value := Low(TAttributeValue) to High(TAttributeValue) do + AttributeValues[value] := Copy(LowerCase(GetEnumName(TypeInfo(TAttributeValue), Ord(value))), 3); +end; + +{ TNodeStack } + +function TNodeStack.AddChild(Typ: TSyntaxNodeType): TSyntaxNode; +begin + Result := FStack.Peek.AddChild(TSyntaxNode.Create(Typ)); + Result.Col := FLexer.PosXY.X; + Result.Line := FLexer.PosXY.Y; + Result.FileName := FLexer.FileName; +end; + +function TNodeStack.AddChild(Node: TSyntaxNode): TSyntaxNode; +begin + Result := FStack.Peek.AddChild(Node); +end; + +function TNodeStack.AddValuedChild(Typ: TSyntaxNodeType; + const Value: string): TSyntaxNode; +begin + Result := FStack.Peek.AddChild(TValuedSyntaxNode.Create(Typ)); + Result.Col := FLexer.PosXY.X; + Result.Line := FLexer.PosXY.Y; + Result.FileName := FLexer.FileName; + + TValuedSyntaxNode(Result).Value := Value; +end; + +procedure TNodeStack.Clear; +begin + FStack.Clear; +end; + +constructor TNodeStack.Create(Lexer: TmwPasLex); +begin + FLexer := Lexer; + FStack := TStack.Create; +end; + +destructor TNodeStack.Destroy; +begin + FStack.Free; + inherited; +end; + +function TNodeStack.GetCount: Integer; +begin + Result := FStack.Count; +end; + +function TNodeStack.Peek: TSyntaxNode; +begin + Result := FStack.Peek; +end; + +function TNodeStack.Pop: TSyntaxNode; +begin + Result := FStack.Pop; +end; + +function TNodeStack.Push(Node: TSyntaxNode): TSyntaxNode; +begin + FStack.Push(Node); + Result := Node; + Result.Col := FLexer.PosXY.X; + Result.Line := FLexer.PosXY.Y; + Result.FileName := FLexer.FileName; +end; + +function TNodeStack.PushCompoundSyntaxNode(Typ: TSyntaxNodeType): TSyntaxNode; +begin + Result := Push(Peek.AddChild(TCompoundSyntaxNode.Create(Typ))); +end; + +function TNodeStack.PushValuedNode(Typ: TSyntaxNodeType; + const Value: string): TSyntaxNode; +begin + Result := Push(Peek.AddChild(TValuedSyntaxNode.Create(Typ))); + TValuedSyntaxNode(Result).Value := Value; +end; + +function TNodeStack.Push(Typ: TSyntaxNodeType): TSyntaxNode; +begin + Result := FStack.Peek.AddChild(TSyntaxNode.Create(Typ)); + Push(Result); +end; + { TPasSyntaxTreeBuilder } procedure TPasSyntaxTreeBuilder.AccessSpecifier; @@ -365,7 +471,7 @@ procedure TPasSyntaxTreeBuilder.ArrayDimension; procedure TPasSyntaxTreeBuilder.AsmStatement; begin - FStack.PushCompoundSyntaxNode(ntStatements).SetAttribute(anType, 'asm'); + FStack.PushCompoundSyntaxNode(ntStatements).SetAttribute(anType, AttributeValues[atAsm]); try inherited; SetCurrentCompoundNodesEndPosition; @@ -549,7 +655,7 @@ procedure TPasSyntaxTreeBuilder.CaseStatement; procedure TPasSyntaxTreeBuilder.ClassClass; begin - FStack.Peek.SetAttribute(anClass, 'true'); + FStack.Peek.SetAttribute(anClass, AttributeValues[atTrue]); inherited; end; @@ -595,13 +701,13 @@ procedure TPasSyntaxTreeBuilder.ClassField; procedure TPasSyntaxTreeBuilder.ClassForward; begin - FStack.Peek.SetAttribute(anForwarded, 'true'); + FStack.Peek.SetAttribute(anForwarded, AttributeValues[atTrue]); inherited ClassForward; end; procedure TPasSyntaxTreeBuilder.ClassFunctionHeading; begin - FStack.Peek.SetAttribute(anKind, 'function'); + FStack.Peek.SetAttribute(anKind, AttributeValues[atFunction]); inherited; end; @@ -617,7 +723,7 @@ procedure TPasSyntaxTreeBuilder.ClassHelper; procedure TPasSyntaxTreeBuilder.ClassMethod; begin - FStack.Peek.SetAttribute(anClass, 'true'); + FStack.Peek.SetAttribute(anClass, AttributeValues[atTrue]); inherited; end; @@ -634,7 +740,7 @@ procedure TPasSyntaxTreeBuilder.ClassMethodHeading; procedure TPasSyntaxTreeBuilder.ClassProcedureHeading; begin - FStack.Peek.SetAttribute(anKind, 'procedure'); + FStack.Peek.SetAttribute(anKind, AttributeValues[atProcedure]); inherited; end; @@ -650,7 +756,7 @@ procedure TPasSyntaxTreeBuilder.ClassProperty; procedure TPasSyntaxTreeBuilder.ClassReferenceType; begin - FStack.Push(ntType).SetAttribute(anType, 'classof'); + FStack.Push(ntType).SetAttribute(anType, AttributeValues[atClassof]); try inherited; finally @@ -664,7 +770,7 @@ procedure TPasSyntaxTreeBuilder.ClassType; i: Integer; extracted: Boolean; begin - FStack.Push(ntType).SetAttribute(anType, 'class'); + FStack.Push(ntType).SetAttribute(anType, AttributeValues[atClass]); try inherited; finally @@ -691,7 +797,7 @@ child := classDef.ChildNodes[i]; procedure TPasSyntaxTreeBuilder.ConstParameter; begin - FStack.Push(ntParameters).SetAttribute(anKind, 'const'); + FStack.Push(ntParameters).SetAttribute(anKind, AttributeValues[atConst]); try inherited; finally @@ -704,7 +810,7 @@ procedure TPasSyntaxTreeBuilder.ConstructorName; Temp: TSyntaxNode; begin Temp := FStack.Peek; - Temp.SetAttribute(anKind, 'constructor'); + Temp.SetAttribute(anKind, AttributeValues[atConstructor]); Temp.SetAttribute(anName, Lexer.Token); inherited; end; @@ -867,7 +973,7 @@ procedure TPasSyntaxTreeBuilder.ContainsClause; constructor TPasSyntaxTreeBuilder.Create; begin inherited; - FStack := TNodeStack.Create(Self); + FStack := TNodeStack.Create(Lexer); FComments := TObjectList.Create(True); OnComment := DoOnComment; @@ -885,25 +991,28 @@ procedure TPasSyntaxTreeBuilder.DestructorName; Temp: TSyntaxNode; begin Temp := FStack.Peek; - Temp.SetAttribute(anKind, 'destructor'); + Temp.SetAttribute(anKind, AttributeValues[atDestructor]); Temp.SetAttribute(anName, Lexer.Token); inherited; end; procedure TPasSyntaxTreeBuilder.DirectiveBinding; +var + token: string; begin + token := Lexer.Token; // Method bindings: - if SameText(Lexer.Token, 'override') or SameText(Lexer.Token, 'virtual') - or SameText(Lexer.Token, 'dynamic') + if SameText(token, 'override') or SameText(token, 'virtual') + or SameText(token, 'dynamic') then - FStack.Peek.SetAttribute(anMethodBinding, Lexer.Token) + FStack.Peek.SetAttribute(anMethodBinding, token) // Other directives - else if SameText(Lexer.Token, 'reintroduce') then - FStack.Peek.SetAttribute(anReintroduce, 'true') - else if SameText(Lexer.Token, 'overload') then - FStack.Peek.SetAttribute(anOverload, 'true') - else if SameText(Lexer.Token, 'abstract') then - FStack.Peek.SetAttribute(anAbstract, 'true'); + else if SameText(token, 'reintroduce') then + FStack.Peek.SetAttribute(anReintroduce, AttributeValues[atTrue]) + else if SameText(token, 'overload') then + FStack.Peek.SetAttribute(anOverload, AttributeValues[atTrue]) + else if SameText(token, 'abstract') then + FStack.Peek.SetAttribute(anAbstract, AttributeValues[atTrue]); inherited; end; @@ -926,7 +1035,7 @@ procedure TPasSyntaxTreeBuilder.DirectiveCalling; procedure TPasSyntaxTreeBuilder.DispInterfaceForward; begin - FStack.Peek.SetAttribute(anForwarded, 'true'); + FStack.Peek.SetAttribute(anForwarded, AttributeValues[atTrue]); inherited; end; @@ -958,7 +1067,7 @@ procedure TPasSyntaxTreeBuilder.EmptyStatement; procedure TPasSyntaxTreeBuilder.EnumeratedType; begin - FStack.Push(ntType).SetAttribute(anName, sENUM); + FStack.Push(ntType).SetAttribute(anName, AttributeValues[atEnum]); try inherited; finally @@ -1236,7 +1345,7 @@ procedure TPasSyntaxTreeBuilder.ForStatementTo; procedure TPasSyntaxTreeBuilder.FunctionHeading; begin - FStack.Peek.SetAttribute(anKind, 'function'); + FStack.Peek.SetAttribute(anKind, AttributeValues[atFunction]); inherited; end; @@ -1388,7 +1497,7 @@ procedure TPasSyntaxTreeBuilder.InitializationSection; procedure TPasSyntaxTreeBuilder.InterfaceForward; begin - FStack.Peek.SetAttribute(anForwarded, 'true'); + FStack.Peek.SetAttribute(anForwarded, AttributeValues[atTrue]); inherited InterfaceForward; end; @@ -1415,7 +1524,7 @@ procedure TPasSyntaxTreeBuilder.InterfaceSection; procedure TPasSyntaxTreeBuilder.InterfaceType; begin - FStack.Push(ntType).SetAttribute(anType, 'interface'); + FStack.Push(ntType).SetAttribute(anType, AttributeValues[atInterface]); try inherited; finally @@ -1517,7 +1626,7 @@ procedure TPasSyntaxTreeBuilder.NamedArgument; procedure TPasSyntaxTreeBuilder.NilToken; begin - FStack.AddChild(ntLiteral).SetAttribute(anType, 'nil'); + FStack.AddChild(ntLiteral).SetAttribute(anType, AttributeValues[atNil]); inherited; end; @@ -1532,7 +1641,7 @@ procedure TPasSyntaxTreeBuilder.Number; Node: TSyntaxNode; begin Node := FStack.AddValuedChild(ntLiteral, Lexer.Token); - Node.SetAttribute(anType, 'numeric'); + Node.SetAttribute(anType, AttributeValues[atNumeric]); inherited; end; @@ -1571,7 +1680,7 @@ procedure TPasSyntaxTreeBuilder.ParserMessage(Sender: TObject; procedure TPasSyntaxTreeBuilder.OutParameter; begin - FStack.Push(ntParameters).SetAttribute(anKind, 'out'); + FStack.Push(ntParameters).SetAttribute(anKind, AttributeValues[atOut]); try inherited; finally @@ -1603,7 +1712,7 @@ procedure TPasSyntaxTreeBuilder.PointerSymbol; procedure TPasSyntaxTreeBuilder.PointerType; begin - FStack.Push(ntType).SetAttribute(anType, 'pointer'); + FStack.Push(ntType).SetAttribute(anType, AttributeValues[atPointer]); try inherited; finally @@ -1644,7 +1753,7 @@ procedure TPasSyntaxTreeBuilder.ProcedureDeclarationSection; procedure TPasSyntaxTreeBuilder.ProcedureHeading; begin - FStack.Peek.SetAttribute(anKind, 'procedure'); + FStack.Peek.SetAttribute(anKind, AttributeValues[atProcedure]); inherited; end; @@ -1686,7 +1795,7 @@ procedure TPasSyntaxTreeBuilder.RecordFieldConstant; begin Node := FStack.PushValuedNode(ntField, Lexer.Token); try - Node.SetAttribute(anType, 'name'); + Node.SetAttribute(anType, AttributeValues[atName]); inherited; finally FStack.Pop; @@ -2040,7 +2149,7 @@ procedure TPasSyntaxTreeBuilder.StringConst; end; Node := FStack.AddValuedChild(ntLiteral, Str); - Node.SetAttribute(anType, 'string'); + Node.SetAttribute(anType, AttributeValues[atString]); end; procedure TPasSyntaxTreeBuilder.StringConstSimple; @@ -2068,7 +2177,7 @@ procedure TPasSyntaxTreeBuilder.StructuredType; procedure TPasSyntaxTreeBuilder.SubrangeType; begin - FStack.Push(ntType).SetAttribute(anName, sSUBRANGE); + FStack.Push(ntType).SetAttribute(anName, AttributeValues[atSubRange]); try inherited; finally @@ -2335,7 +2444,7 @@ procedure TPasSyntaxTreeBuilder.VarName; procedure TPasSyntaxTreeBuilder.VarParameter; begin - FStack.Push(ntParameters).SetAttribute(anKind, 'var'); + FStack.Push(ntParameters).SetAttribute(anKind, AttributeValues[atVar]); try inherited; finally @@ -2397,7 +2506,7 @@ procedure TPasSyntaxTreeBuilder.VisibilityStrictPrivate; begin Temp := FStack.Push(ntStrictPrivate); try - Temp.SetAttribute(anVisibility, 'true'); + Temp.SetAttribute(anVisibility, AttributeValues[atTrue]); inherited; finally FStack.Pop; @@ -2410,7 +2519,7 @@ procedure TPasSyntaxTreeBuilder.VisibilityPrivate; begin Temp := FStack.Push(ntPrivate); try - Temp.SetAttribute(anVisibility, 'true'); + Temp.SetAttribute(anVisibility, AttributeValues[atTrue]); inherited; finally FStack.Pop; @@ -2423,7 +2532,7 @@ procedure TPasSyntaxTreeBuilder.VisibilityStrictProtected; begin Temp := FStack.Push(ntStrictProtected); try - Temp.SetAttribute(anVisibility, 'true'); + Temp.SetAttribute(anVisibility, AttributeValues[atTrue]); inherited; finally FStack.Pop; @@ -2436,7 +2545,7 @@ procedure TPasSyntaxTreeBuilder.VisibilityProtected; begin Temp := FStack.Push(ntProtected); try - Temp.SetAttribute(anVisibility, 'true'); + Temp.SetAttribute(anVisibility, AttributeValues[atTrue]); inherited; finally FStack.Pop; @@ -2449,7 +2558,7 @@ procedure TPasSyntaxTreeBuilder.VisibilityPublic; begin Temp := FStack.Push(ntPublic); try - Temp.SetAttribute(anVisibility, 'true'); + Temp.SetAttribute(anVisibility, AttributeValues[atTrue]); inherited; finally FStack.Pop; @@ -2462,7 +2571,7 @@ procedure TPasSyntaxTreeBuilder.VisibilityPublished; begin Temp := FStack.Push(ntPublished); try - Temp.SetAttribute(anVisibility, 'true'); + Temp.SetAttribute(anVisibility, AttributeValues[atTrue]); inherited; finally FStack.Pop; @@ -2499,91 +2608,6 @@ procedure TPasSyntaxTreeBuilder.WithStatement; end; end; -{ TNodeStack } - -function TNodeStack.AddChild(Typ: TSyntaxNodeType): TSyntaxNode; -begin - Result := FStack.Peek.AddChild(TSyntaxNode.Create(Typ)); - Result.Col := FParser.Lexer.PosXY.X; - Result.Line := FParser.Lexer.PosXY.Y; - Result.FileName := FParser.Lexer.FileName; -end; - -function TNodeStack.AddChild(Node: TSyntaxNode): TSyntaxNode; -begin - Result := FStack.Peek.AddChild(Node); -end; - -function TNodeStack.AddValuedChild(Typ: TSyntaxNodeType; - const Value: string): TSyntaxNode; -begin - Result := FStack.Peek.AddChild(TValuedSyntaxNode.Create(Typ)); - Result.Col := FParser.Lexer.PosXY.X; - Result.Line := FParser.Lexer.PosXY.Y; - Result.FileName := FParser.Lexer.FileName; - - TValuedSyntaxNode(Result).Value := Value; -end; - -procedure TNodeStack.Clear; -begin - FStack.Clear; -end; - -constructor TNodeStack.Create(Parser: TmwSimplePasPar); -begin - FParser := Parser; - FStack := TStack.Create; -end; - -destructor TNodeStack.Destroy; -begin - FStack.Free; - inherited; -end; - -function TNodeStack.GetCount: Integer; -begin - Result := FStack.Count; -end; - -function TNodeStack.Peek: TSyntaxNode; -begin - Result := FStack.Peek; -end; - -function TNodeStack.Pop: TSyntaxNode; -begin - Result := FStack.Pop; -end; - -function TNodeStack.Push(Node: TSyntaxNode): TSyntaxNode; -begin - FStack.Push(Node); - Result := Node; - Result.Col := FParser.Lexer.PosXY.X; - Result.Line := FParser.Lexer.PosXY.Y; - Result.FileName := FParser.Lexer.FileName; -end; - -function TNodeStack.PushCompoundSyntaxNode(Typ: TSyntaxNodeType): TSyntaxNode; -begin - Result := Push(Peek.AddChild(TCompoundSyntaxNode.Create(Typ))); -end; - -function TNodeStack.PushValuedNode(Typ: TSyntaxNodeType; - const Value: string): TSyntaxNode; -begin - Result := Push(Peek.AddChild(TValuedSyntaxNode.Create(Typ))); - TValuedSyntaxNode(Result).Value := Value; -end; - -function TNodeStack.Push(Typ: TSyntaxNodeType): TSyntaxNode; -begin - Result := FStack.Peek.AddChild(TSyntaxNode.Create(Typ)); - Push(Result); -end; - { ESyntaxTreeException } constructor ESyntaxTreeException.Create(Line, Col: Integer; const FileName, Msg: string; @@ -2599,4 +2623,7 @@ destructor ESyntaxTreeException.Destroy; inherited; end; +initialization + InitAttributeValues; + end. diff --git a/Source/SimpleParser/SimpleParser.Lexer.pas b/Source/SimpleParser/SimpleParser.Lexer.pas index 5c1d6242..134da928 100644 --- a/Source/SimpleParser/SimpleParser.Lexer.pas +++ b/Source/SimpleParser/SimpleParser.Lexer.pas @@ -111,7 +111,7 @@ TmwBasePasLex = class(TObject) FOnUnDefDirect: TDirectiveEvent; FDirectiveParamOrigin: PChar; FAsmCode: Boolean; - FDefines: TStrings; + FDefines: TArray; FDefineStack: Integer; FTopDefineRec: PDefineRec; FUseDefines: Boolean; @@ -252,9 +252,7 @@ TmwBasePasLex = class(TObject) procedure UnknownProc; function GetToken: string; function GetTokenLen: Integer; - function GetCommentState: Pointer; function GetCompilerDirective: string; - procedure SetCommentState(const Value: Pointer); function GetDirectiveKind: TptTokenKind; function GetDirectiveParam: string; function GetStringContent: string; @@ -269,7 +267,7 @@ TmwBasePasLex = class(TObject) function GetIsRelativeOperator: Boolean; function GetIsCompilerDirective: Boolean; function GetIsOrdinalType: Boolean; - function GetGenID: TptTokenKind;procedure SetOnElseIfDirect(const Value: TDirectiveEvent); + function GetGenID: TptTokenKind; procedure EnterDefineBlock(ADefined: Boolean); procedure ExitDefineBlock; @@ -288,18 +286,6 @@ TmwBasePasLex = class(TObject) function GetFileName: string; protected procedure SetOrigin(const NewValue: string); virtual; - procedure SetOnCompDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnDefineDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnElseDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnEndIfDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnIfDefDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnIfNDefDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnIfOptDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnIncludeDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnResourceDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnUnDefDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnIfDirect(const Value: TDirectiveEvent); virtual; - procedure SetOnIfEndDirect(const Value: TDirectiveEvent); virtual; public constructor Create; destructor Destroy; override; @@ -317,7 +303,6 @@ TmwBasePasLex = class(TObject) procedure ClearDefines; procedure InitDefinesDefinedByCompiler; - property CommentState: Pointer read GetCommentState write SetCommentState; property CompilerDirective: string read GetCompilerDirective; property DirectiveParam: string read GetDirectiveParam; property IsJunk: Boolean read GetIsJunk; @@ -343,19 +328,19 @@ TmwBasePasLex = class(TObject) property IsCompilerDirective: Boolean read GetIsCompilerDirective; property OnComment: TCommentEvent read FOnComment write FOnComment; property OnMessage: TMessageEvent read FOnMessage write FOnMessage; - property OnCompDirect: TDirectiveEvent read FOnCompDirect write SetOnCompDirect; - property OnDefineDirect: TDirectiveEvent read FOnDefineDirect write SetOnDefineDirect; - property OnElseDirect: TDirectiveEvent read FOnElseDirect write SetOnElseDirect; - property OnEndIfDirect: TDirectiveEvent read FOnEndIfDirect write SetOnEndIfDirect; - property OnIfDefDirect: TDirectiveEvent read FOnIfDefDirect write SetOnIfDefDirect; - property OnIfNDefDirect: TDirectiveEvent read FOnIfNDefDirect write SetOnIfNDefDirect; - property OnIfOptDirect: TDirectiveEvent read FOnIfOptDirect write SetOnIfOptDirect; - property OnIncludeDirect: TDirectiveEvent read FOnIncludeDirect write SetOnIncludeDirect; - property OnIfDirect: TDirectiveEvent read FOnIfDirect write SetOnIfDirect; - property OnIfEndDirect: TDirectiveEvent read FOnIfEndDirect write SetOnIfEndDirect; - property OnElseIfDirect: TDirectiveEvent read FOnElseIfDirect write SetOnElseIfDirect; - property OnResourceDirect: TDirectiveEvent read FOnResourceDirect write SetOnResourceDirect; - property OnUnDefDirect: TDirectiveEvent read FOnUnDefDirect write SetOnUnDefDirect; + property OnCompDirect: TDirectiveEvent read FOnCompDirect write FOnCompDirect; + property OnDefineDirect: TDirectiveEvent read FOnDefineDirect write FOnDefineDirect; + property OnElseDirect: TDirectiveEvent read FOnElseDirect write FOnElseDirect; + property OnEndIfDirect: TDirectiveEvent read FOnEndIfDirect write FOnEndIfDirect; + property OnIfDefDirect: TDirectiveEvent read FOnIfDefDirect write FOnIfDefDirect; + property OnIfNDefDirect: TDirectiveEvent read FOnIfNDefDirect write FOnIfNDefDirect; + property OnIfOptDirect: TDirectiveEvent read FOnIfOptDirect write FOnIfOptDirect; + property OnIncludeDirect: TDirectiveEvent read FOnIncludeDirect write FOnIncludeDirect; + property OnIfDirect: TDirectiveEvent read FOnIfDirect write FOnIfDirect; + property OnIfEndDirect: TDirectiveEvent read FOnIfEndDirect write FOnIfEndDirect; + property OnElseIfDirect: TDirectiveEvent read FOnElseIfDirect write FOnElseIfDirect; + property OnResourceDirect: TDirectiveEvent read FOnResourceDirect write FOnResourceDirect; + property OnUnDefDirect: TDirectiveEvent read FOnUnDefDirect write FOnUnDefDirect; property AsmCode: Boolean read FAsmCode write FAsmCode; property DirectiveParamOrigin: PChar read FDirectiveParamOrigin; property UseDefines: Boolean read FUseDefines write FUseDefines; @@ -372,16 +357,6 @@ TmwPasLex = class(TmwBasePasLex) function GetAheadTokenID: TptTokenKind; protected procedure SetOrigin(const NewValue: string); override; - procedure SetOnCompDirect(const Value: TDirectiveEvent); override; - procedure SetOnDefineDirect(const Value: TDirectiveEvent); override; - procedure SetOnElseDirect(const Value: TDirectiveEvent); override; - procedure SetOnEndIfDirect(const Value: TDirectiveEvent); override; - procedure SetOnIfDefDirect(const Value: TDirectiveEvent); override; - procedure SetOnIfNDefDirect(const Value: TDirectiveEvent); override; - procedure SetOnIfOptDirect(const Value: TDirectiveEvent); override; - procedure SetOnIncludeDirect(const Value: TDirectiveEvent); override; - procedure SetOnResourceDirect(const Value: TDirectiveEvent); override; - procedure SetOnUnDefDirect(const Value: TDirectiveEvent); override; public constructor Create; destructor Destroy; override; @@ -440,7 +415,7 @@ procedure TmwBasePasLex.ClearDefines; FTopDefineRec := Frame^.Next; Dispose(Frame); end; - FDefines.Clear; + FDefines := nil; FDefineStack := 0; end; @@ -449,7 +424,7 @@ procedure TmwBasePasLex.CloneDefinesFrom(ALexer: TmwBasePasLex); Frame, LastFrame, SourceFrame: PDefineRec; begin ClearDefines; - FDefines.Assign(ALexer.FDefines); + FDefines := Copy(ALexer.FDefines); FDefineStack := ALexer.FDefineStack; Frame := nil; @@ -474,8 +449,8 @@ procedure TmwBasePasLex.CloneDefinesFrom(ALexer: TmwBasePasLex); function TmwBasePasLex.GetPosXY: TTokenPoint; begin - Result.X := FTokenPos - FBuffer.LinePos + 1; Result.Y := FBuffer.LineNumber + 1; + Result.X := FTokenPos - FBuffer.LinePos + 1; end; function TmwBasePasLex.GetRunPos: Integer; @@ -1307,7 +1282,6 @@ constructor TmwBasePasLex.Create; FExID := ptUnKnown; FUseDefines := True; - FDefines := TStringList.Create; FTopDefineRec := nil; ClearDefines; @@ -1323,7 +1297,6 @@ destructor TmwBasePasLex.Destroy; Dispose(FBuffer); ClearDefines; //If we don't do this, we get a memory leak - FDefines.Free; inherited Destroy; end; @@ -1385,8 +1358,12 @@ procedure TmwBasePasLex.SetSharedBuffer(SharedBuffer: PBufferRec); end; procedure TmwBasePasLex.AddDefine(const ADefine: string); +var + len: Integer; begin - FDefines.Add(ADefine); + len := Length(FDefines); + SetLength(FDefines, len + 1); + FDefines[len] := ADefine; end; procedure TmwBasePasLex.AddressOpProc; @@ -1754,6 +1731,7 @@ procedure TmwBasePasLex.ExitDefineBlock; Dispose(StackFrame); end; end; + procedure TmwBasePasLex.GreaterProc; begin case FBuffer.Buf[FBuffer.Run + 1] of @@ -1792,8 +1770,13 @@ procedure TmwBasePasLex.IntegerProc; end; function TmwBasePasLex.IsDefined(const ADefine: string): Boolean; +var + i: Integer; begin - Result := FDefines.IndexOf(ADefine) > -1; + for i := 0 to High(FDefines) do + if FDefines[i] = ADefine then + Exit(True); + Result := False; end; function TmwBasePasLex.IsIdentifiers(AChar: Char): Boolean; @@ -1922,13 +1905,29 @@ procedure TmwBasePasLex.PointProc; end; end; +procedure Delete(var values: TArray; index: Integer); +var + len: Integer; + tailCount: Integer; +begin + len := Length(values); + if len = 0 then + Exit; + values[index] := ''; + tailCount := len - (index + 1); + if tailCount > 0 then + Move(values[index + 1], values[index], SizeOf(string) * tailCount); + Pointer(values[len - 1]) := nil; // do not trigger string refcounting as we moved it + SetLength(values, len - 1); +end; + procedure TmwBasePasLex.RemoveDefine(const ADefine: string); var - I: Integer; + i: Integer; begin - I := FDefines.IndexOf(ADefine); - if I > -1 then - FDefines.Delete(I); + for i := High(FDefines) downto 0 do + if FDefines[i] = ADefine then + Delete(FDefines, i); end; procedure TmwBasePasLex.RoundCloseProc; @@ -2228,7 +2227,7 @@ function TmwBasePasLex.GetIsSpace: Boolean; function TmwBasePasLex.GetToken: string; begin - SetString(Result, (FBuffer.Buf + FTokenPos), GetTokenLen); + SetString(Result, FBuffer.Buf + FTokenPos, TokenLen); end; function TmwBasePasLex.GetTokenLen: Integer; @@ -2271,11 +2270,6 @@ function TmwBasePasLex.FirstInLine: Boolean; end; end; -function TmwBasePasLex.GetCommentState: Pointer; -begin - Result := Pointer(FCommentState); -end; - function TmwBasePasLex.GetCompilerDirective: string; var DirectLen: Integer; @@ -2661,11 +2655,6 @@ procedure TmwBasePasLex.InitDefinesDefinedByCompiler; {$ENDIF} end; -procedure TmwBasePasLex.SetCommentState(const Value: Pointer); -begin - FCommentState := TCommentState(Value); -end; - function TmwBasePasLex.GetStringContent: string; var TempString: string; @@ -2685,10 +2674,11 @@ function TmwBasePasLex.GetStringContent: string; function TmwBasePasLex.GetIsOrdIdent: Boolean; begin - Result := False; if FTokenID = ptIdentifier then Result := FExID in [ptBoolean, ptByte, ptChar, ptDWord, ptInt64, ptInteger, - ptLongInt, ptLongWord, ptPChar, ptShortInt, ptSmallInt, ptWideChar, ptWord]; + ptLongInt, ptLongWord, ptPChar, ptShortInt, ptSmallInt, ptWideChar, ptWord] + else + Result := False; end; function TmwBasePasLex.GetIsOrdinalType: Boolean; @@ -2698,28 +2688,26 @@ function TmwBasePasLex.GetIsOrdinalType: Boolean; function TmwBasePasLex.GetIsRealType: Boolean; begin - Result := False; if FTokenID = ptIdentifier then - Result := FExID in [ptComp, ptCurrency, ptDouble, ptExtended, ptReal, ptReal48, ptSingle]; + Result := FExID in [ptComp, ptCurrency, ptDouble, ptExtended, ptReal, ptReal48, ptSingle] + else + Result := False; end; function TmwBasePasLex.GetIsStringType: Boolean; begin - Result := False; if FTokenID = ptIdentifier then Result := FExID in [ptAnsiString, ptWideString] else - if FTokenID = ptString then - Result := True - else - if FTokenID = ptStringConst then Result := True; + Result := FTokenID in [ptString, ptStringConst]; end; function TmwBasePasLex.GetIsVariantType: Boolean; begin - Result := False; if FTokenID = ptIdentifier then Result := FExID in [ptOleVariant, ptVariant] + else + Result := False; end; function TmwBasePasLex.GetOrigin: string; @@ -2798,7 +2786,7 @@ function TmwPasLex.GetAheadTokenID: TptTokenKind; procedure TmwPasLex.InitAhead; begin - FAheadLex.CommentState := CommentState; + FAheadLex.FCommentState := FCommentState; FAheadLex.CloneDefinesFrom(Self); FAheadLex.SetSharedBuffer(FBuffer); @@ -2807,121 +2795,6 @@ procedure TmwPasLex.InitAhead; FAheadLex.Next; end; -procedure TmwBasePasLex.SetOnCompDirect(const Value: TDirectiveEvent); -begin - FOnCompDirect := Value; -end; - -procedure TmwBasePasLex.SetOnDefineDirect(const Value: TDirectiveEvent); -begin - FOnDefineDirect := Value; -end; - -procedure TmwBasePasLex.SetOnElseDirect(const Value: TDirectiveEvent); -begin - FOnElseDirect := Value; -end; - -procedure TmwBasePasLex.SetOnElseIfDirect(const Value: TDirectiveEvent); -begin - FOnElseIfDirect := Value; -end; - -procedure TmwBasePasLex.SetOnEndIfDirect(const Value: TDirectiveEvent); -begin - FOnEndIfDirect := Value; -end; - -procedure TmwBasePasLex.SetOnIfDefDirect(const Value: TDirectiveEvent); -begin - FOnIfDefDirect := Value; -end; - -procedure TmwBasePasLex.SetOnIfDirect(const Value: TDirectiveEvent); -begin - FOnIfDirect := Value; -end; - -procedure TmwBasePasLex.SetOnIfEndDirect(const Value: TDirectiveEvent); -begin - FOnIfEndDirect := Value; -end; - -procedure TmwBasePasLex.SetOnIfNDefDirect(const Value: TDirectiveEvent); -begin - FOnIfNDefDirect := Value; -end; - -procedure TmwBasePasLex.SetOnIfOptDirect(const Value: TDirectiveEvent); -begin - FOnIfOptDirect := Value; -end; - -procedure TmwBasePasLex.SetOnIncludeDirect(const Value: TDirectiveEvent); -begin - FOnIncludeDirect := Value; -end; - -procedure TmwBasePasLex.SetOnResourceDirect(const Value: TDirectiveEvent); -begin - FOnResourceDirect := Value; -end; - -procedure TmwBasePasLex.SetOnUnDefDirect(const Value: TDirectiveEvent); -begin - FOnUnDefDirect := Value; -end; - -procedure TmwPasLex.SetOnCompDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnDefineDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnElseDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnEndIfDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnIfDefDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnIfNDefDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnIfOptDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnIncludeDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnResourceDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - -procedure TmwPasLex.SetOnUnDefDirect(const Value: TDirectiveEvent); -begin - inherited; -end; - procedure TmwPasLex.SetOrigin(const NewValue: string); begin inherited SetOrigin(NewValue); @@ -2974,4 +2847,3 @@ procedure TmwBasePasLex.AmpersandOpProc; initialization MakeIdentTable; end. -