Skip to content

Commit b0758fb

Browse files
committed
[grammar] modifications for array support
1 parent e1eddfd commit b0758fb

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

pbxproj.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ StringValue
179179
= literal:LiteralChar+ { return literal.join('') }
180180

181181
LiteralChar
182-
= !InlineCommentOpen !LineTerminator char:[^;\n]
182+
= !InlineCommentOpen !LineTerminator char:[^;,\n]
183183
{ return char }
184184

185185
/*

test/projects/with_array.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
empties = (
7+
);
8+
ARCHS = (
9+
armv6,
10+
armv7,
11+
);
12+
files = (
13+
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
14+
1D3623260D0F684500981E51 /* AppDelegate.m in Sources */,
15+
);
16+
objectVersion = 45;
17+
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
18+
}

test/with_array.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var PEG = require('pegjs'),
2+
fs = require('fs'),
3+
pbx = fs.readFileSync('test/projects/with_array.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 arrays with commented entries'] = function (test) {
10+
test.ok(project.files instanceof Array);
11+
test.equal(project.files.length, 2);
12+
test.done()
13+
}
14+
15+
exports['should parse arrays with uncommented entries'] = function (test) {
16+
test.ok(project.ARCHS instanceof Array);
17+
test.equal(project.ARCHS.length, 2);
18+
test.done()
19+
}
20+
21+
exports['should parse empty arrays'] = function (test) {
22+
test.ok(project.empties instanceof Array);
23+
test.equal(project.empties.length, 0);
24+
test.done();
25+
}

0 commit comments

Comments
 (0)