obj.grammar doesn't render with the ParserGenApp
2013-11-09 02:26:41.185 ParserGenApp[82193:5f0b] missing rule named: `functionDef`
2013-11-09 02:26:41.185 ParserGenApp[82193:5f0b] *** Assertion failure in -[PKSParserGenVisitor lookaheadSetForNode:], /Users/fbarthelemy/Code/parsekit/src/PKSParserGenVisitor.m:163
[snipped]
- Run the ParserGenApp using the obj.grammar file.
- Notice how it crashes with error missing rule named 'functionDef' Expected behavior: a parser would be generated.
Diff to Repro:
diff --git a/ParseKit.xcodeproj/project.pbxproj b/ParseKit.xcodeproj/project.pbxproj
index ce77a6e..4442ae0 100644
--- a/ParseKit.xcodeproj/project.pbxproj
+++ b/ParseKit.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 2E3956D0182E4518003E769B /* objc.grammar in Resources */ = {isa = PBXBuildFile; fileRef = D353899D0FEAC96B00926552 /* objc.grammar */; };
D302C69D0EF044810090E714 /* TDPlistParser.m in Sources */ = {isa = PBXBuildFile; fileRef = D36568A60EEF9FE900226554 /* TDPlistParser.m */; };
D30805BA155ECB1F0000BC60 /* PKPattern.m in Sources */ = {isa = PBXBuildFile; fileRef = D34BAF380FF9E18300D7773A /* PKPattern.m */; };
D30805BB155ECB220000BC60 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = D36C55FD0FD3617B00141CB7 /* RegexKitLite.m */; };
@@ -3705,6 +3706,7 @@
D33830A0171CA3BB00CCE513 /* PKSPredictElseIfTemplate.txt in Resources */,
D33830A1171CA3BB00CCE513 /* PKSSpeculateElseIfTemplate.txt in Resources */,
D33830A2171CA3BB00CCE513 /* PKSPredictElseTemplate.txt in Resources */,
+ 2E3956D0182E4518003E769B /* objc.grammar in Resources */,
D33830A3171CA3BB00CCE513 /* PKSPredictEndIfTemplate.txt in Resources */,
D33830A4171CA3BB00CCE513 /* PKSOptionalSpeculateTemplate.txt in Resources */,
D33830A5171CA3BB00CCE513 /* PKSOptionalPredictTemplate.txt in Resources */,
diff --git a/ParserGenApp/PGDocument.m b/ParserGenApp/PGDocument.m
index 2f9f99b..67fbe10 100644
--- a/ParserGenApp/PGDocument.m
+++ b/ParserGenApp/PGDocument.m
@@ -35,7 +35,7 @@
self.preassemblerSettingBehavior = PKParserFactoryAssemblerSettingBehaviorNone;
self.assemblerSettingBehavior = PKParserFactoryAssemblerSettingBehaviorAll;
- NSString *path = [[NSBundle mainBundle] pathForResource:@"expression" ofType:@"grammar"];
+ NSString *path = [[NSBundle mainBundle] pathForResource:@"objc" ofType:@"grammar"];
self.grammar = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
}
return self;
I think you meant the "objc.grammar"? If so, yeah... I don't think the ObjC grammar is correct or complete. It was just a half-hearted attempt that I never completed. I'd love to have an ObjC grammar for ParseKit, but I don't think one exists.
I totally did mean the ObjC grammar. And I realized the grammar was entirely unfinished as I started trying to fix it. I was fooled by the large file, didn't realize that it had been started by copying in a grammar of another format.
I have a team of client engineers now, and I'd very much like something like GoFmt, or at least initially, something that will warn on style guide inconsistencies.
diff --git a/res/objc.grammar b/res/objc.grammar
index 5dec845..1eb8cd3 100644
--- a/res/objc.grammar
+++ b/res/objc.grammar
@@ -42,23 +42,29 @@ classImpl = '@implementation' className (':' superclassName)? ivars? implementat
categoryInterface = '@interface' className '(' categoryName ')' protocolRefList? interfaceDeclList? '@end';
-category-implementation:
-@implementation class-name ( category-name )
-[ implementation-definition-list ]
-@end
+// category-implementation:
+// @implementation class-name ( category-name )
+// [ implementation-definition-list ]
+// @end
+categoryImpl = '@implementation' className '(' categoryName ')' ivars? implementationDefList? '@end';
-protocol-declaration:
-@protocol protocol-name
-[ protocol-reference-list ]
-[ interface-declaration-list ]
-@end
-class-declaration-list:
-@class class-list ;
+// protocol-declaration:
+// @protocol protocol-name
+// [ protocol-reference-list ]
+// [ interface-declaration-list ]
+// @end
-class-list:
-class-name
-class-list , class-name
+protocolDecl = '@protocol' className protocolRefList? interfaceDeclList? '@end';
+
+// class-declaration-list:
+// @class class-list ;
+
+classDeclList = '@class' className?;
+
+// class-list:
+// class-name
+// class-list , class-name
protocol-reference-list:
< protocol-list >