Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit b052035

Browse files
committed
applied code cleanup and format preferences
1 parent de387a8 commit b052035

File tree

8 files changed

+388
-388
lines changed

8 files changed

+388
-388
lines changed

SourcepawnCondenser/SourcepawnCondenser/Condenser.cs

+87-87
Original file line numberDiff line numberDiff line change
@@ -38,122 +38,122 @@ public SMDefinition Condense()
3838
switch (ct.Kind)
3939
{
4040
case TokenKind.FunctionIndicator:
41+
{
42+
var newIndex = ConsumeSMFunction();
43+
if (newIndex != -1)
4144
{
42-
var newIndex = ConsumeSMFunction();
43-
if (newIndex != -1)
44-
{
45-
position = newIndex + 1;
46-
continue;
47-
}
48-
49-
break;
45+
position = newIndex + 1;
46+
continue;
5047
}
48+
49+
break;
50+
}
5151
case TokenKind.EnumStruct:
52+
{
53+
var newIndex = ConsumeSMEnumStruct();
54+
if (newIndex != -1)
5255
{
53-
var newIndex = ConsumeSMEnumStruct();
54-
if (newIndex != -1)
55-
{
56-
position = newIndex + 1;
57-
continue;
58-
}
59-
60-
break;
56+
position = newIndex + 1;
57+
continue;
6158
}
59+
60+
break;
61+
}
6262
case TokenKind.Enum:
63+
{
64+
var newIndex = ConsumeSMEnum();
65+
if (newIndex != -1)
6366
{
64-
var newIndex = ConsumeSMEnum();
65-
if (newIndex != -1)
66-
{
67-
position = newIndex + 1;
68-
continue;
69-
}
70-
71-
break;
67+
position = newIndex + 1;
68+
continue;
7269
}
70+
71+
break;
72+
}
7373
case TokenKind.Struct:
74+
{
75+
var newIndex = ConsumeSMStruct();
76+
if (newIndex != -1)
7477
{
75-
var newIndex = ConsumeSMStruct();
76-
if (newIndex != -1)
77-
{
78-
position = newIndex + 1;
79-
continue;
80-
}
81-
82-
break;
78+
position = newIndex + 1;
79+
continue;
8380
}
81+
82+
break;
83+
}
8484
case TokenKind.PreprocessorDirective:
85+
{
86+
var newIndex = ConsumeSMPPDirective();
87+
if (newIndex != -1)
8588
{
86-
var newIndex = ConsumeSMPPDirective();
87-
if (newIndex != -1)
88-
{
89-
position = newIndex + 1;
90-
continue;
91-
}
92-
93-
break;
89+
position = newIndex + 1;
90+
continue;
9491
}
92+
93+
break;
94+
}
9595
case TokenKind.Constant:
96+
{
97+
var newIndex = ConsumeSMConstant();
98+
if (newIndex != -1)
9699
{
97-
var newIndex = ConsumeSMConstant();
98-
if (newIndex != -1)
99-
{
100-
position = newIndex + 1;
101-
continue;
102-
}
103-
104-
break;
100+
position = newIndex + 1;
101+
continue;
105102
}
103+
104+
break;
105+
}
106106
case TokenKind.MethodMap:
107+
{
108+
var newIndex = ConsumeSMMethodmap();
109+
if (newIndex != -1)
107110
{
108-
var newIndex = ConsumeSMMethodmap();
109-
if (newIndex != -1)
110-
{
111-
position = newIndex + 1;
112-
continue;
113-
}
114-
115-
break;
111+
position = newIndex + 1;
112+
continue;
116113
}
114+
115+
break;
116+
}
117117
case TokenKind.TypeSet:
118+
{
119+
var newIndex = ConsumeSMTypeset();
120+
if (newIndex != -1)
118121
{
119-
var newIndex = ConsumeSMTypeset();
120-
if (newIndex != -1)
121-
{
122-
position = newIndex + 1;
123-
continue;
124-
}
125-
126-
break;
122+
position = newIndex + 1;
123+
continue;
127124
}
125+
126+
break;
127+
}
128128
case TokenKind.TypeDef:
129+
{
130+
var newIndex = ConsumeSMTypedef();
131+
if (newIndex != -1)
129132
{
130-
var newIndex = ConsumeSMTypedef();
131-
if (newIndex != -1)
132-
{
133-
position = newIndex + 1;
134-
continue;
135-
}
136-
137-
break;
133+
position = newIndex + 1;
134+
continue;
138135
}
136+
137+
break;
138+
}
139139
case TokenKind.Identifier:
140+
{
141+
var newIndex = ConsumeSMVariable();
142+
if (newIndex != -1)
140143
{
141-
var newIndex = ConsumeSMVariable();
142-
if (newIndex != -1)
143-
{
144-
position = newIndex + 1;
145-
continue;
146-
}
147-
148-
// If Variable is not found try function
149-
newIndex = ConsumeSMFunction();
150-
if (newIndex != -1)
151-
{
152-
position = newIndex + 1;
153-
continue;
154-
}
144+
position = newIndex + 1;
145+
continue;
155146
}
156-
break;
147+
148+
// If Variable is not found try function
149+
newIndex = ConsumeSMFunction();
150+
if (newIndex != -1)
151+
{
152+
position = newIndex + 1;
153+
continue;
154+
}
155+
}
156+
break;
157157
}
158158

159159
++position;

SourcepawnCondenser/SourcepawnCondenser/CondenserFunctions/SMFunctionConsumer.cs

+42-42
Original file line numberDiff line numberDiff line change
@@ -20,66 +20,66 @@ private int ConsumeSMFunction()
2020
switch (t[startPosition].Value)
2121
{
2222
case "stock":
23+
{
24+
if (startPosition + 1 < length)
2325
{
24-
if (startPosition + 1 < length)
26+
if (t[startPosition + 1].Kind == TokenKind.FunctionIndicator)
2527
{
26-
if (t[startPosition + 1].Kind == TokenKind.FunctionIndicator)
28+
if (t[startPosition + 1].Value == "static")
2729
{
28-
if (t[startPosition + 1].Value == "static")
29-
{
30-
kind = SMFunctionKind.StockStatic;
31-
++iteratePosition;
32-
break;
33-
}
30+
kind = SMFunctionKind.StockStatic;
31+
++iteratePosition;
32+
break;
3433
}
3534
}
36-
37-
kind = SMFunctionKind.Stock;
38-
break;
3935
}
36+
37+
kind = SMFunctionKind.Stock;
38+
break;
39+
}
4040
case "native":
41-
{
42-
kind = SMFunctionKind.Native;
43-
break;
44-
}
41+
{
42+
kind = SMFunctionKind.Native;
43+
break;
44+
}
4545
case "forward":
46-
{
47-
kind = SMFunctionKind.Forward;
48-
break;
49-
}
46+
{
47+
kind = SMFunctionKind.Forward;
48+
break;
49+
}
5050
case "public":
51+
{
52+
if (startPosition + 1 < length)
5153
{
52-
if (startPosition + 1 < length)
54+
if (t[startPosition + 1].Kind == TokenKind.FunctionIndicator)
5355
{
54-
if (t[startPosition + 1].Kind == TokenKind.FunctionIndicator)
56+
if (t[startPosition + 1].Value == "native")
5557
{
56-
if (t[startPosition + 1].Value == "native")
57-
{
58-
kind = SMFunctionKind.PublicNative;
59-
++iteratePosition;
60-
break;
61-
}
58+
kind = SMFunctionKind.PublicNative;
59+
++iteratePosition;
60+
break;
6261
}
6362
}
64-
65-
kind = SMFunctionKind.Public;
66-
break;
6763
}
64+
65+
kind = SMFunctionKind.Public;
66+
break;
67+
}
6868
case "static":
69-
{
70-
kind = SMFunctionKind.Static;
71-
break;
72-
}
69+
{
70+
kind = SMFunctionKind.Static;
71+
break;
72+
}
7373
case "normal":
74-
{
75-
kind = SMFunctionKind.Normal;
76-
break;
77-
}
74+
{
75+
kind = SMFunctionKind.Normal;
76+
break;
77+
}
7878
default:
79-
{
80-
functionReturnType = t[startPosition].Value;
81-
break;
82-
}
79+
{
80+
functionReturnType = t[startPosition].Value;
81+
break;
82+
}
8383
}
8484

8585
var functionCommentString = string.Empty;

0 commit comments

Comments
 (0)