Skip to content

Commit 3704439

Browse files
committed
handled delimited sections
1 parent 4f7a159 commit 3704439

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

pbxproj.pegjs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,52 @@ Anything
2525
= Char / EOF
2626

2727
Object
28-
= "{" obj:(Definition / EmptyBody) "}"
28+
= "{" obj:(AssignmentList / EmptyBody) "}"
2929
{ return obj }
3030

3131
EmptyBody
3232
= _
3333
{ return Object.create(null) }
3434

35-
Definition
36-
= _ head:Assignment _ tail:((Definition)*) _
35+
AssignmentList
36+
= _ head:Assignment _ tail:((AssignmentList)*) _
3737
{
3838
if (tail) return merge(head,tail)
3939
else return head
4040
}
41+
/ _ section:DelimitedSection _
42+
{
43+
return section
44+
}
4145

4246
Assignment
4347
= id:Identifier _ "=" _ val:Value ";"
4448
{
4549
var result = Object.create(null);
46-
result[id.join('')] = val
50+
result[id] = val
4751
return result
4852
}
4953

54+
DelimitedSection
55+
= begin:DelimitedSectionBegin _ fields:(AssignmentList / EmptyBody) _ DelimitedSectionEnd
56+
{
57+
var section = {}
58+
section[begin.name] = fields
59+
60+
return section
61+
}
62+
63+
DelimitedSectionBegin
64+
= "/* Begin " sectionName:Identifier " section */" NewLine
65+
{ return { name: sectionName } }
66+
67+
DelimitedSectionEnd
68+
= "/* End " sectionName:Identifier " section */" NewLine
69+
{ return { name: sectionName } }
70+
5071
Identifier
51-
= [A-Za-z0-9]+
72+
= id:[A-Za-z0-9]+
73+
{ return id.join('') }
5274

5375
Value
5476
= obj:Object { return obj }

0 commit comments

Comments
 (0)