Skip to content

Commit 08b6053

Browse files
committed
* Change Action blocks to have void return
1 parent 3137372 commit 08b6053

21 files changed

+51
-53
lines changed

include/PEGKit/PKParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
@class PKToken;
2828
@class PKAssembly;
2929

30-
typedef id (^PKSActionBlock) (void);
30+
typedef void (^PKSActionBlock) (void);
3131
typedef void (^PKSSpeculateBlock)(void);
3232
typedef BOOL (^PKSPredicateBlock)(void);
3333
typedef void (^PKSRecoverBlock) (void);
@@ -105,7 +105,7 @@ enum {
105105
- (void)testAndThrow:(PKSPredicateBlock)block;
106106

107107
// actions
108-
- (id)execute:(PKSActionBlock)block;
108+
- (void)execute:(PKSActionBlock)block;
109109

110110
// delegate callbacks
111111
- (void)fireDelegateSelector:(SEL)sel;

res/PGActionTemplate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{%for 1 to depth %} {%/for%}[self execute:(id)^{
1+
{%for 1 to depth %} {%/for%}[self execute:^{
22
{%for 1 to depth %} {%/for%}{{actionBody}}
33
{%for 1 to depth %} {%/for%}}];

src/PKParser.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,11 @@ - (BOOL)speculate:(PKSSpeculateBlock)block {
683683
}
684684

685685

686-
- (id)execute:(PKSActionBlock)block {
686+
- (void)execute:(PKSActionBlock)block {
687687
NSParameterAssert(block);
688-
if (self.isSpeculating || !_enableActions) return nil;
688+
if (self.isSpeculating || !_enableActions) return;
689689

690-
id result = nil;
691-
if (block) result = block();
692-
return result;
690+
if (block) block();
693691
}
694692

695693

test/CSSParser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ - (void)start {
281281

282282
- (void)__stylesheet {
283283

284-
[self execute:(id)^{
284+
[self execute:^{
285285

286286
PKTokenizer *t = self.tokenizer;
287287

test/CreateTableStmtParser.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ - (void)createTableStmt_ {
108108
[self existsOpt_];
109109
[self databaseName_];
110110
[self match:CREATETABLESTMT_TOKEN_KIND_SEMI_COLON discard:YES];
111-
[self execute:(id)^{
111+
[self execute:^{
112112

113113
// NSString *dbName = POP();
114114
// BOOL ifNotExists = POP_BOOL();
@@ -125,7 +125,7 @@ - (void)createTableStmt_ {
125125
- (void)databaseName_ {
126126

127127
[self matchQuotedString:NO];
128-
[self execute:(id)^{
128+
[self execute:^{
129129

130130
// pop the string value of the `PKToken` on the top of the stack
131131
NSString *dbName = POP_STR();
@@ -149,12 +149,12 @@ - (void)tempOpt_ {
149149
} else {
150150
[self raise:@"No viable alternative found in rule 'tempOpt'."];
151151
}
152-
[self execute:(id)^{
152+
[self execute:^{
153153
PUSH(@YES);
154154
}];
155155
} else {
156156
[self matchEmpty:NO];
157-
[self execute:(id)^{
157+
[self execute:^{
158158
PUSH(@NO);
159159
}];
160160
}
@@ -168,12 +168,12 @@ - (void)existsOpt_ {
168168
[self match:CREATETABLESTMT_TOKEN_KIND_IF discard:YES];
169169
[self match:CREATETABLESTMT_TOKEN_KIND_NOT_UPPER discard:YES];
170170
[self match:CREATETABLESTMT_TOKEN_KIND_EXISTS discard:YES];
171-
[self execute:(id)^{
171+
[self execute:^{
172172
PUSH(@YES);
173173
}];
174174
} else {
175175
[self matchEmpty:NO];
176-
[self execute:(id)^{
176+
[self execute:^{
177177
PUSH(@NO);
178178
}];
179179
}

test/CrockfordParser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ - (void)start {
188188

189189
- (void)program_ {
190190

191-
[self execute:(id)^{
191+
[self execute:^{
192192

193193
PKTokenizer *t = self.tokenizer;
194194

test/CurlyActionParser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ - (void)start_ {
8989
do {
9090
[self matchWord:NO];
9191
} while ([self predicts:TOKEN_KIND_BUILTIN_WORD, 0]);
92-
[self execute:(id)^{
92+
[self execute:^{
9393

9494
id word = nil;
9595
while (!EMPTY()) {

test/DelimitedParser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ - (void)start {
9999

100100
- (void)__start {
101101

102-
[self execute:(id)^{
102+
[self execute:^{
103103

104104
PKTokenizer *t = self.tokenizer;
105105

test/ExpressionActionsParser.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ - (void)start {
189189

190190
- (void)__expr {
191191

192-
[self execute:(id)^{
192+
[self execute:^{
193193

194194
PKTokenizer *t = self.tokenizer;
195195
[t.symbolState add:@"!="];
@@ -224,7 +224,7 @@ - (void)__orTerm {
224224

225225
[self match:EXPRESSIONACTIONS_TOKEN_KIND_OR discard:YES];
226226
[self andExpr_];
227-
[self execute:(id)^{
227+
[self execute:^{
228228

229229
BOOL rhs = POP_BOOL();
230230
BOOL lhs = POP_BOOL();
@@ -257,7 +257,7 @@ - (void)__andTerm {
257257

258258
[self match:EXPRESSIONACTIONS_TOKEN_KIND_AND discard:YES];
259259
[self relExpr_];
260-
[self execute:(id)^{
260+
[self execute:^{
261261

262262
BOOL rhs = POP_BOOL();
263263
BOOL lhs = POP_BOOL();
@@ -315,7 +315,7 @@ - (void)__relOpTerm {
315315

316316
[self relOp_];
317317
[self callExpr_];
318-
[self execute:(id)^{
318+
[self execute:^{
319319

320320
NSInteger rhs = POP_INT();
321321
NSString *op = POP_STR();
@@ -448,17 +448,17 @@ - (void)__literal {
448448
if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_NO, EXPRESSIONACTIONS_TOKEN_KIND_NO_UPPER, EXPRESSIONACTIONS_TOKEN_KIND_YES, EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER, 0]) {
449449
[self testAndThrow:(id)^{ return LA(1) != EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER; }];
450450
[self bool_];
451-
[self execute:(id)^{
451+
[self execute:^{
452452
PUSH_BOOL(EQ_IGNORE_CASE(POP_STR(), @"yes"));
453453
}];
454454
} else if ([self predicts:TOKEN_KIND_BUILTIN_NUMBER, 0]) {
455455
[self matchNumber:NO];
456-
[self execute:(id)^{
456+
[self execute:^{
457457
PUSH_DOUBLE(POP_DOUBLE());
458458
}];
459459
} else if ([self predicts:TOKEN_KIND_BUILTIN_QUOTEDSTRING, 0]) {
460460
[self matchQuotedString:NO];
461-
[self execute:(id)^{
461+
[self execute:^{
462462
PUSH(POP_STR());
463463
}];
464464
} else {

test/ExpressionParser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ - (void)start {
237237

238238
- (void)__expr {
239239

240-
[self execute:(id)^{
240+
[self execute:^{
241241

242242
PKTokenizer *t = self.tokenizer;
243243
[t.symbolState add:@"!="];

0 commit comments

Comments
 (0)