Skip to content

Commit e1eddfd

Browse files
committed
[grammar] handle arrays
1 parent 5fe4051 commit e1eddfd

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

pbxproj.pegjs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ EmptyBody
3636
{ return Object.create(null) }
3737

3838
AssignmentList
39-
= _ head:Assignment _ tail:((AssignmentList)*) _
39+
= _ head:Assignment _ tail:AssignmentList* _
4040
{
4141
if (tail) return merge(head,tail)
4242
else return head
@@ -130,7 +130,36 @@ DelimitedSectionEnd
130130
* Arrays: lists of values, possible wth comments
131131
*/
132132
Array
133-
= "(" [^)]+ ")"
133+
= "(" arr:(ArrayBody / EmptyArray ) ")" { return arr }
134+
135+
EmptyArray
136+
= _ { return [] }
137+
138+
ArrayBody
139+
= _ head:ArrayEntry _ tail:ArrayBody? _
140+
{
141+
if (tail) {
142+
tail.unshift(head);
143+
return tail;
144+
} else {
145+
return [head];
146+
}
147+
}
148+
149+
ArrayEntry
150+
= SimpleArrayEntry / CommentedArrayEntry
151+
152+
SimpleArrayEntry
153+
= val:Value "," { return val }
154+
155+
CommentedArrayEntry
156+
= val:Value _ comment:InlineComment ","
157+
{
158+
var result = Object.create(null);
159+
result.value = val;
160+
result.comment = comment;
161+
return result;
162+
}
134163

135164
/*
136165
* Identifiers and Values

0 commit comments

Comments
 (0)