@@ -56,8 +56,7 @@ ETemplate = class(Exception);
56
56
57
57
TStripAction = ( //
58
58
saWhitespace, //
59
- saNL, //
60
- saKeepOneSpace //
59
+ saNL //
61
60
);
62
61
63
62
TStripActionSet = set of TStripAction;
@@ -150,10 +149,8 @@ ETemplate = class(Exception);
150
149
vsBlock, //
151
150
152
151
vsNewLine, //
153
- vsWhiteSpace, //
152
+ vsWhiteSpace //
154
153
155
- vsSingleton, //
156
- vsValidate //
157
154
);
158
155
159
156
TTemplateSymbolSet = set of TTemplateSymbol;
@@ -201,9 +198,13 @@ ETemplate = class(Exception);
201
198
[' {8C539211-ED84-4963-B894-C569C2F7B2FE}' ]
202
199
end ;
203
200
201
+ TParserOption = (poAllowEnd, poAllowElse, poAllowElIf, poHasElse, poInLoop, poStripNL, poStripWS, poStripRecurringNL);
202
+ TParserOptions = set of TParserOption;
203
+
204
204
IStmt = interface (ITemplateVisitorHost)
205
205
[' {6D37028E-A0C0-41F1-8A59-EDC0C9ADD9C7}' ]
206
206
function Flatten : TArray<IStmt>;
207
+ procedure OptimiseTemplate (const AOptions: TParserOptions; const ANewLine: string);
207
208
function GetHasEnd : boolean;
208
209
property HasEnd: boolean read GetHasEnd;
209
210
end ;
@@ -214,22 +215,19 @@ ETemplate = class(Exception);
214
215
property Stmt: IStmt read GetStmt;
215
216
end ;
216
217
217
- TParserOption = (poAllowEnd, poAllowElse, poAllowElIf, poHasElse, poInLoop, poStripNL, poStripWS);
218
- TParserOptions = set of TParserOption;
219
-
220
218
ITemplate = interface (ITemplateVisitorHost)
221
219
[' {93AAB971-5B4B-4959-93F2-6C7DAE15C91B}' ]
222
220
function GetItem (const AOffset: integer): IStmt;
223
221
function GetCount : integer;
224
222
function GetLastItem : IStmt;
225
223
procedure FlattenTemplate ;
226
- procedure OptimiseTemplate (const AOptions: TParserOptions);
224
+ procedure OptimiseTemplate (const AOptions: TParserOptions; const ANewLine: string );
227
225
property Items[const AOffset: integer]: IStmt read GetItem;
228
226
property Count: integer read GetCount;
229
227
property LastItem: IStmt read GetLastItem;
230
228
end ;
231
229
232
- TAddLocation = (alLast, alBeforeNL, alAfterNL );
230
+ TAddLocation = (alLast, alFront );
233
231
234
232
ITemplateAdd = interface (ITemplate)
235
233
[' {64465D68-0E9D-479F-9EF3-A30E75967809}' ]
@@ -260,7 +258,7 @@ ETemplate = class(Exception);
260
258
[' {FB4CC3AB-BFEC-4189-B555-153DDA490D15}' ]
261
259
end ;
262
260
263
- TStripDirection = (sdEnd, sdLeft, sdRight, sdBeforeNewLine, sdAfterNewLine );
261
+ TStripDirection = (sdLeft, sdRight);
264
262
265
263
IStripStmt = interface (IStmt)
266
264
[' {3313745B-D635-4453-9808-660DC462E15C}' ]
@@ -369,6 +367,16 @@ ETemplate = class(Exception);
369
367
property Container: ITemplate read GetContainer;
370
368
end ;
371
369
370
+ IIgnoreNLStmt = interface (IStmt)
371
+ function GetContainer : ITemplate;
372
+ property Container: ITemplate read GetContainer;
373
+ end ;
374
+
375
+ IIgnoreWSStmt = interface (IStmt)
376
+ function GetContainer : ITemplate;
377
+ property Container: ITemplate read GetContainer;
378
+ end ;
379
+
372
380
ILoopStmt = interface (IStmt)
373
381
[' {D6C26A41-3250-4EB9-A776-8952DE3931BD}' ]
374
382
function GetOnBeginContainer : ITemplate;
@@ -580,7 +588,10 @@ ETemplate = class(Exception);
580
588
procedure Visit (const AStmt: IBlockStmt); overload;
581
589
procedure Visit (const AStmt: IExtendsStmt); overload;
582
590
procedure Visit (const AStmt: ICompositeStmt); overload;
591
+ procedure Visit (const AStmt: INoopStmt); overload;
583
592
procedure Visit (const AStmt: IStripStmt); overload;
593
+ procedure Visit (const AStmt: IIgnoreNLStmt); overload;
594
+ procedure Visit (const AStmt: IIgnoreWSStmt); overload;
584
595
end ;
585
596
586
597
IEvaluationTemplateVisitor = interface (ITemplateVisitor)
@@ -614,6 +625,7 @@ TAbstractStmt = class abstract(TAbstractBase, IStmt)
614
625
protected
615
626
function Flatten : TArray<IStmt>; virtual ;
616
627
function GetHasEnd : boolean; virtual ;
628
+ procedure OptimiseTemplate (const AOptions: TParserOptions; const ANewLine: string); virtual ;
617
629
public
618
630
constructor Create(const APosition: IPosition);
619
631
end ;
@@ -632,12 +644,11 @@ TMapExpr = class(TAbstractExpr, IMapExpr)
632
644
633
645
const
634
646
StripDirectionStr: array [TStripDirection] of string = ( //
635
- ' sdEnd' , ' sdLeft' , ' sdRight' , ' sdBeforeNewLine' , ' sdAfterNewLine' );
647
+ ' sdLeft' , ' sdRight' //
648
+ );
636
649
637
650
StripActionStr: array [TStripAction] of string = ( //
638
- ' saWhitespace' , //
639
- ' saNL' , //
640
- ' saKeepOneSpace' //
651
+ ' saWhitespace' , ' saNL' //
641
652
);
642
653
643
654
type
@@ -744,4 +755,9 @@ function TAbstractStmt.GetHasEnd: boolean;
744
755
exit(false);
745
756
end ;
746
757
758
+ procedure TAbstractStmt.OptimiseTemplate (const AOptions: TParserOptions; const ANewLine: string);
759
+ begin
760
+
761
+ end ;
762
+
747
763
end .
0 commit comments