Skip to content

Commit fdb34eb

Browse files
instarepongeor
instarepo
authored andcommitted
chore: Auto-formatted Pascal files: binaryparsers.pas, codefmtparsers.pas, cppparser.pas, editorconfigparser.pas, Factory.pas, HTMLFormatter.pas, parsers.pas, pascalparser.pas, recognizers.pas, RTFFormatter.pas, tokenizers.pas, tokenparsers.pas, TokenTypes.pas
1 parent 54a4c93 commit fdb34eb

13 files changed

+158
-142
lines changed

Factory.pas

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ implementation
2525

2626
uses
2727
PascalParser, CppParser, EditorConfigParser,
28-
FormatterBase, RTFFormatter, HTMLFormatter, Recognizers, TokenTypes, Parsers, ParseResult, Tokenizers;
28+
FormatterBase, RTFFormatter, HTMLFormatter, Recognizers, TokenTypes,
29+
Parsers, ParseResult, Tokenizers;
2930

3031
function CreateFormatter(FormatterType: TFormatterType;
3132
OutputStream: TStream): TFormatterBase;
@@ -46,7 +47,8 @@ function CreateRecognizers(DocumentType: TDocumentType): TTokenRecognizers;
4647
dtCpp: Result := CppParser.CreateRecognizers;
4748
dtPascal: Result := PascalParser.CreateRecognizers;
4849
dtEditorConfig: Result := EditorConfigParser.CreateRecognizers;
49-
else raise Exception.Create('Not implemented!')
50+
else
51+
raise Exception.Create('Not implemented!')
5052
end;
5153
end;
5254

@@ -56,7 +58,8 @@ function CreateParser(DocumentType: TDocumentType): TParser<TFmt>;
5658
dtCpp: Result := CppParser.CreateParser;
5759
dtPascal: Result := PascalParser.CreateParser;
5860
dtEditorConfig: Result := EditorConfigParser.CreateParser;
59-
else raise Exception.Create('Not implemented!')
61+
else
62+
raise Exception.Create('Not implemented!')
6063
end;
6164
end;
6265

HTMLFormatter.pas

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ THTMLFormatter = class(TFormatterBase)
1414
public
1515
procedure WriteFooter; override;
1616
procedure WriteHeader; override;
17-
procedure WriteToken(const Token: String; const TokenType: THigherTokenType); override;
17+
procedure WriteToken(const Token: String; const TokenType: THigherTokenType);
18+
override;
1819
end;
1920

2021
implementation
2122

22-
procedure THTMLFormatter.WriteToken(const Token: String; const TokenType: THigherTokenType);
23+
procedure THTMLFormatter.WriteToken(const Token: String;
24+
const TokenType: THigherTokenType);
2325
var
2426
escapedToken, FormatToken: String;
2527
begin

RTFFormatter.pas

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ TRTFFormatter = class(TFormatterBase)
1414
public
1515
procedure WriteFooter; override;
1616
procedure WriteHeader; override;
17-
procedure WriteToken(const Token: String; const TokenType: THigherTokenType); override;
17+
procedure WriteToken(const Token: String; const TokenType: THigherTokenType);
18+
override;
1819
end;
1920

2021
implementation
2122

22-
procedure TRTFFormatter.WriteToken(const Token: String; const TokenType: THigherTokenType);
23+
procedure TRTFFormatter.WriteToken(const Token: String;
24+
const TokenType: THigherTokenType);
2325
var
2426
escapedToken, FormatToken: String;
2527
begin

TokenTypes.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface
1919
htString,
2020
htSymbol,
2121
htUnknown
22-
);
22+
);
2323

2424
TFmt = record
2525
Text: String;

binaryparsers.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ function TAbstractAndParser<L, R, T>.Parse(Source: TUndoTokenizer): TParseResult
8282
begin
8383
FLeft.Undo(Source, Left.Data);
8484
Result := FailedParseResult<T>();
85-
end
85+
end;
8686
end
8787
else
88-
Result := FailedParseResult<T>()
88+
Result := FailedParseResult<T>();
8989
end;
9090

9191
(* And *)

codefmtparsers.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ function IdentifierRecognizer: TTokenRecognizer;
3535

3636
(* TListToFmtMapper *)
3737

38-
constructor TListToFmtMapper.Create(Parser: TParser<TTokenLinkedList>; Kind: THigherTokenType);
38+
constructor TListToFmtMapper.Create(Parser: TParser<TTokenLinkedList>;
39+
Kind: THigherTokenType);
3940
begin
4041
inherited Create(Parser);
4142
FKind := Kind;

cppparser.pas

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ implementation
3232
'unsigned', 'virtual', 'void', 'volatile', 'while');
3333

3434
type
35-
TTokenType = (ttEol, ttWhiteSpace, ttDigits, ttPound, ttDoubleQuote, ttDoubleSlash, ttKeyword, ttIdentifier, ttUnknown);
35+
TTokenType = (ttEol, ttWhiteSpace, ttDigits, ttPound, ttDoubleQuote,
36+
ttDoubleSlash, ttKeyword, ttIdentifier, ttUnknown);
3637
TTokenTypeSet = set of TTokenType;
38+
3739
const
3840
AllTokenTypes: TTokenTypeSet = [ttEol..ttUnknown];
3941

@@ -49,7 +51,8 @@ function CreateRecognizer(TokenType: TTokenType): TTokenRecognizer;
4951
ttKeyword: Result := TKeywordRecognizer.Create(CppKeyWords, csSensitive);
5052
ttIdentifier: Result := IdentifierRecognizer;
5153
ttUnknown: Result := TAnyRecognizer.Create;
52-
else raise Exception.Create('Unknown token type')
54+
else
55+
raise Exception.Create('Unknown token type')
5356
end;
5457
end;
5558

@@ -88,15 +91,19 @@ function FilterTokens(TokenTypes: TTokenTypeSet): TParser<TToken>;
8891

8992
(* Simple Parser maps tokens almost as-is from one enum to another *)
9093

91-
function SimpleParser(TokenType: TTokenType; HigherTokenType: THigherTokenType): TParser<TFmt>; overload;
94+
function SimpleParser(TokenType: TTokenType;
95+
HigherTokenType: THigherTokenType): TParser<TFmt>; overload;
9296
begin
93-
Result := TListToFmtMapper.Create(MapTokenToList(FilterToken(TokenType)), HigherTokenType);
97+
Result := TListToFmtMapper.Create(MapTokenToList(FilterToken(TokenType)),
98+
HigherTokenType);
9499
end;
95100

96101
function SimpleParser: TParser<TFmt>; overload;
97102
var
98-
SourceTokens: array of TTokenType = [ttEol, ttWhiteSpace, ttDigits, ttKeyword, ttIdentifier, ttUnknown];
99-
DestTokens: array of THigherTokenType = [htCRLF, htSpace, htNumber, htKeyword, htIdentifier, htUnknown];
103+
SourceTokens: array of TTokenType = [ttEol, ttWhiteSpace, ttDigits,
104+
ttKeyword, ttIdentifier, ttUnknown];
105+
DestTokens: array of THigherTokenType = [htCRLF, htSpace, htNumber,
106+
htKeyword, htIdentifier, htUnknown];
100107
i: Integer;
101108
begin
102109
Result := nil;
@@ -122,17 +129,17 @@ function SlashComments: TParser<TTokenLinkedList>;
122129

123130
function StringParser: TParser<TTokenLinkedList>;
124131
begin
125-
Result := Seq(
126-
Seq(FilterToken(ttDoubleQuote), ManyTokens(FilterTokens(AllTokenTypes - [ttEol, ttDoubleQuote]))),
127-
FilterToken(ttDoubleQuote)
128-
);
132+
Result := Seq(Seq(FilterToken(ttDoubleQuote),
133+
ManyTokens(FilterTokens(AllTokenTypes - [ttEol, ttDoubleQuote]))),
134+
FilterToken(ttDoubleQuote));
129135
end;
130136

131137
// Pre-processor directive
132138

133139
function PreProcessorDirective: TParser<TTokenLinkedList>;
134140
begin
135-
Result := Seq(FilterToken(ttPound), ManyTokens(FilterTokens([ttIdentifier, ttKeyword])));
141+
Result := Seq(FilterToken(ttPound),
142+
ManyTokens(FilterTokens([ttIdentifier, ttKeyword])));
136143
end;
137144

138145
function CreateParser: TParser<TFmt>;

editorconfigparser.pas

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ implementation
1717
(* Recognizers *)
1818

1919
type
20-
TTokenType = (ttEol, ttWhiteSpace, ttDigits, ttPound, ttLeftBracket, ttRightBracket, ttIdentifier, ttUnknown);
20+
TTokenType = (ttEol, ttWhiteSpace, ttDigits, ttPound, ttLeftBracket,
21+
ttRightBracket, ttIdentifier, ttUnknown);
2122
TTokenTypeSet = set of TTokenType;
23+
2224
const
2325
AllTokenTypes: TTokenTypeSet = [ttEol..ttUnknown];
2426

@@ -33,7 +35,8 @@ function CreateRecognizer(TokenType: TTokenType): TTokenRecognizer;
3335
ttRightBracket: Result := TSingleCharRecognizer.Create(']');
3436
ttIdentifier: Result := IdentifierRecognizer;
3537
ttUnknown: Result := TAnyRecognizer.Create;
36-
else raise Exception.Create('Unknown token type')
38+
else
39+
raise Exception.Create('Unknown token type')
3740
end;
3841
end;
3942

@@ -72,15 +75,19 @@ function FilterTokens(TokenTypes: TTokenTypeSet): TParser<TToken>;
7275

7376
(* Simple Parser maps tokens almost as-is from one enum to another *)
7477

75-
function SimpleParser(TokenType: TTokenType; HigherTokenType: THigherTokenType): TParser<TFmt>; overload;
78+
function SimpleParser(TokenType: TTokenType;
79+
HigherTokenType: THigherTokenType): TParser<TFmt>; overload;
7680
begin
77-
Result := TListToFmtMapper.Create(MapTokenToList(FilterToken(TokenType)), HigherTokenType);
81+
Result := TListToFmtMapper.Create(MapTokenToList(FilterToken(TokenType)),
82+
HigherTokenType);
7883
end;
7984

8085
function SimpleParser: TParser<TFmt>; overload;
8186
var
82-
SourceTokens: array of TTokenType = [ttEol, ttWhiteSpace, ttDigits, ttIdentifier, ttUnknown];
83-
DestTokens: array of THigherTokenType = [htCRLF, htSpace, htNumber, htIdentifier, htUnknown];
87+
SourceTokens: array of TTokenType = [ttEol, ttWhiteSpace, ttDigits,
88+
ttIdentifier, ttUnknown];
89+
DestTokens: array of THigherTokenType = [htCRLF, htSpace, htNumber,
90+
htIdentifier, htUnknown];
8491
i: Integer;
8592
begin
8693
Result := nil;
@@ -93,15 +100,10 @@ function SimpleParser: TParser<TFmt>; overload;
93100
function SectionParser: TParser<TFmt>;
94101
begin
95102
Result := TListToFmtMapper.Create(
96-
Seq(
97-
Seq(
98-
FilterToken(ttLeftBracket),
99-
ManyTokens(FilterTokens([ttWhiteSpace, ttDigits, ttIdentifier, ttUnknown]))
100-
),
101-
FilterToken(ttRightBracket)
102-
),
103-
htDirective
104-
);
103+
Seq(Seq(FilterToken(ttLeftBracket),
104+
ManyTokens(FilterTokens([ttWhiteSpace, ttDigits, ttIdentifier,
105+
ttUnknown]))),
106+
FilterToken(ttRightBracket)), htDirective);
105107
end;
106108

107109
function NoEol: TParser<TTokenLinkedList>;
@@ -111,10 +113,8 @@ function NoEol: TParser<TTokenLinkedList>;
111113

112114
function CommentParser: TParser<TFmt>;
113115
begin
114-
Result := TListToFmtMapper.Create(
115-
Seq(FilterToken(ttPound), NoEol),
116-
htComment
117-
);
116+
Result := TListToFmtMapper.Create(Seq(FilterToken(ttPound), NoEol),
117+
htComment);
118118
end;
119119

120120
function CreateParser: TParser<TFmt>;

parsers.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function OrElse<T>(Left: TParser<T>; Right: TParser<T>): TParser<T>;
7373
else
7474
Result := Left
7575
else
76-
Result := Right
76+
Result := Right;
7777
end;
7878

7979
(* Filter *)
@@ -102,10 +102,10 @@ function TFilterParser<T>.Parse(Source: TUndoTokenizer): TParseResult<T>;
102102
begin
103103
Undo(Source, Next.Data);
104104
Result := FailedParseResult<T>();
105-
end
105+
end;
106106
end
107107
else
108-
Result := Next
108+
Result := Next;
109109
end;
110110

111111
procedure TFilterParser<T>.Undo(Source: TUndoTokenizer; Data: T);
@@ -161,7 +161,7 @@ function TMapParser<T, U>.Parse(Source: TUndoTokenizer): TParseResult<U>;
161161
if Next.Success then
162162
Result := SuccessParseResult<U>(Map(Next.Data))
163163
else
164-
Result := FailedParseResult<U>()
164+
Result := FailedParseResult<U>();
165165
end;
166166

167167
end.

pascalparser.pas

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ implementation
5151
ttKeyword,
5252
ttIdentifier,
5353
ttUnknown
54-
);
54+
);
5555
TTokenTypeSet = set of TTokenType;
56+
5657
const
5758
AllTokenTypes: TTokenTypeSet = [ttEol..ttUnknown];
5859

@@ -84,12 +85,14 @@ function CreateRecognizer(TokenType: TTokenType): TTokenRecognizer;
8485
ttAnsiCommentEnd: Result := TStringRecognizer.Create('*)');
8586
ttBraceOpen: Result := TSingleCharRecognizer.Create('{');
8687
ttBraceClose: Result := TSingleCharRecognizer.Create('}');
87-
ttHexNumber: Result := TLeadingPredicateRecognizer.Create(IsDollarSign, IsHexDigit, 1);
88+
ttHexNumber: Result := TLeadingPredicateRecognizer.Create(IsDollarSign,
89+
IsHexDigit, 1);
8890
ttChar: Result := TLeadingPredicateRecognizer.Create(IsPound, IsDigit);
8991
ttKeyword: Result := TKeywordRecognizer.Create(PasKeyWords, csInsensitive);
9092
ttIdentifier: Result := IdentifierRecognizer;
9193
ttUnknown: Result := TAnyRecognizer.Create;
92-
else raise Exception.Create('Unknown token type')
94+
else
95+
raise Exception.Create('Unknown token type')
9396
end;
9497
end;
9598

@@ -128,33 +131,19 @@ function FilterTokens(TokenTypes: TTokenTypeSet): TParser<TToken>;
128131

129132
(* Simple Parser maps tokens almost as-is from one enum to another *)
130133

131-
function SimpleParser(TokenType: TTokenType; HigherTokenType: THigherTokenType): TParser<TFmt>; overload;
134+
function SimpleParser(TokenType: TTokenType;
135+
HigherTokenType: THigherTokenType): TParser<TFmt>; overload;
132136
begin
133-
Result := TListToFmtMapper.Create(MapTokenToList(FilterToken(TokenType)), HigherTokenType);
137+
Result := TListToFmtMapper.Create(MapTokenToList(FilterToken(TokenType)),
138+
HigherTokenType);
134139
end;
135140

136141
function SimpleParser: TParser<TFmt>; overload;
137142
var
138-
SourceTokens: array of TTokenType = [
139-
ttEol,
140-
ttWhiteSpace,
141-
ttDigits,
142-
ttHexNumber,
143-
ttChar,
144-
ttKeyword,
145-
ttIdentifier,
146-
ttUnknown
147-
];
148-
DestTokens: array of THigherTokenType = [
149-
htCRLF,
150-
htSpace,
151-
htNumber,
152-
htNumber,
153-
htString,
154-
htKeyword,
155-
htIdentifier,
156-
htUnknown
157-
];
143+
SourceTokens: array of TTokenType = [ttEol, ttWhiteSpace,
144+
ttDigits, ttHexNumber, ttChar, ttKeyword, ttIdentifier, ttUnknown];
145+
DestTokens: array of THigherTokenType = [htCRLF, htSpace,
146+
htNumber, htNumber, htString, htKeyword, htIdentifier, htUnknown];
158147
i: Integer;
159148
begin
160149
Result := nil;
@@ -180,36 +169,27 @@ function SlashComments: TParser<TTokenLinkedList>;
180169

181170
function StringParser: TParser<TTokenLinkedList>;
182171
begin
183-
Result := Seq(
184-
Seq(FilterToken(ttSingleQuote), ManyTokens(FilterTokens(AllTokenTypes - [ttEol, ttSingleQuote]))),
185-
FilterToken(ttSingleQuote)
186-
);
172+
Result := Seq(Seq(FilterToken(ttSingleQuote),
173+
ManyTokens(FilterTokens(AllTokenTypes - [ttEol, ttSingleQuote]))),
174+
FilterToken(ttSingleQuote));
187175
end;
188176

189177
// Ansi Comments
190178

191179
function AnsiCommentsParser: TParser<TTokenLinkedList>;
192180
begin
193-
Result := Seq(
194-
Seq(
195-
FilterToken(ttAnsiCommentBegin),
196-
ManyTokens(FilterTokens(AllTokenTypes - [ttAnsiCommentEnd]))
197-
),
198-
FilterToken(ttAnsiCommentEnd)
199-
);
181+
Result := Seq(Seq(FilterToken(ttAnsiCommentBegin),
182+
ManyTokens(FilterTokens(AllTokenTypes - [ttAnsiCommentEnd]))),
183+
FilterToken(ttAnsiCommentEnd));
200184
end;
201185

202186
// Borland Comments
203187

204188
function BorlandCommentsParser: TParser<TTokenLinkedList>;
205189
begin
206-
Result := Seq(
207-
Seq(
208-
FilterToken(ttBraceOpen),
209-
ManyTokens(FilterTokens(AllTokenTypes - [ttBraceClose]))
210-
),
211-
FilterToken(ttBraceClose)
212-
);
190+
Result := Seq(Seq(FilterToken(ttBraceOpen),
191+
ManyTokens(FilterTokens(AllTokenTypes - [ttBraceClose]))),
192+
FilterToken(ttBraceClose));
213193
end;
214194

215195
function CreateParser: TParser<TFmt>;

0 commit comments

Comments
 (0)