Skip to content

Commit c3c56d0

Browse files
committed
[grammar] handle multiple DelimitedSections
1 parent 272453a commit c3c56d0

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

pbxproj.pegjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ AssignmentList
4141
if (tail) return merge(head,tail)
4242
else return head
4343
}
44-
/ _ section:DelimitedSection _
44+
/ _ head:DelimitedSection _ tail:AssignmentList*
4545
{
46-
return section
46+
if (tail) return merge(head,tail)
47+
else return head
4748
}
4849

4950
/*

test/projects/two-sections.pbxproj

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 45;
7+
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
8+
objects = {
9+
/* Begin PBXTargetDependency section */
10+
301BF551109A68C00062928A /* PBXTargetDependency */ = {
11+
isa = PBXTargetDependency;
12+
name = PhoneGapLib;
13+
targetProxy = 301BF550109A68C00062928A /* PBXContainerItemProxy */;
14+
};
15+
/* End PBXTargetDependency section */
16+
17+
/* Begin PBXSourcesBuildPhase section */
18+
1D60588E0D05DD3D006BFB54 /* Sources */ = {
19+
isa = PBXSourcesBuildPhase;
20+
buildActionMask = 2147483647;
21+
files = (
22+
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
23+
1D3623260D0F684500981E51 /* AppDelegate.m in Sources */,
24+
);
25+
runOnlyForDeploymentPostprocessing = 0;
26+
};
27+
/* End PBXSourcesBuildPhase section */
28+
};
29+
}

test/two-sections.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var PEG = require('pegjs'),
2+
fs = require('fs'),
3+
pbx = fs.readFileSync('test/projects/two-sections.pbxproj', 'utf-8'),
4+
grammar = fs.readFileSync('pbxproj.pegjs', 'utf-8'),
5+
parser = PEG.buildParser(grammar),
6+
rawProj = parser.parse(pbx),
7+
project = rawProj.project;
8+
9+
exports['should parse a project with two sections'] = function (test) {
10+
// if it gets this far it's worked
11+
test.done();
12+
}
13+
14+
exports['should have both sections on the project object'] = function (test) {
15+
test.ok(project.objects['PBXTargetDependency']);
16+
test.ok(project.objects['PBXSourcesBuildPhase']);
17+
test.done();
18+
}

0 commit comments

Comments
 (0)