Skip to content

Commit e2905b4

Browse files
committed
[grammar] remove Literal rule in favor of Value
1 parent e72df9d commit e2905b4

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

pbxproj.pegjs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CommentedIdentifier
7777
}
7878

7979
CommentedValue
80-
= literal:Literal _ comment:InlineComment
80+
= literal:Value _ comment:InlineComment
8181
{
8282
var result = Object.create(null)
8383
result.comment = comment.trim();
@@ -117,22 +117,23 @@ Identifier
117117
{ return id.join('') }
118118

119119
Value
120-
= obj:Object { return obj } / NumberValue / StringValue
121-
122-
Literal
123-
= StringValue
120+
= Object / NumberValue / StringValue
124121

125122
NumberValue
126-
= number:Digit+ { return parseInt(number, 10) }
123+
= !Alpha number:Digit+ !Alpha
124+
{ return parseInt(number, 10) }
127125

128126
Digit
129127
= [0-9]
130128

129+
Alpha
130+
= [A-Za-z]
131+
131132
StringValue
132133
= literal:LiteralChar+ { return literal.join('') }
133134

134135
LiteralChar
135-
= !InlineCommentOpen char:[^;\n]
136+
= !InlineCommentOpen !LineTerminator char:[^;\n]
136137
{ return char }
137138

138139
SingleLineComment
@@ -153,6 +154,9 @@ NonLine
153154
= !NewLine char:Char
154155
{ return char }
155156

157+
LineTerminator
158+
= NewLine / ";"
159+
156160
NewLine
157161
= [\n\r]
158162

test/hash.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ exports['should split out properties and comments'] = function (test) {
2727
test.equal(project['rootObject_comment'], 'Project object');
2828
test.done();
2929
}
30+
31+
exports['should parse non-commented hash things'] = function (test) {
32+
test.equal(project.nonObject, '29B97313FDCFA39411CA2CEF');
33+
test.done();
34+
}

test/projects/hash.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
classes = {
55
};
66
objectVersion = 45;
7+
nonObject = 29B97313FDCFA39411CA2CEF;
78
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
89
}

0 commit comments

Comments
 (0)