forked from NativeScript/pbxproj-dom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.pegjs
14 lines (13 loc) · 957 Bytes
/
parser.pegjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
var ast = require("./ast");
}
Document = "// !$*UTF8*$!" root:Dictionary s1:Space { return new ast.Document(root, s1); }
Dictionary = s1:Space "{" content:KeyValuePair* s2:Space "}" { return new ast.Dictionary(s1, content, s2); }
KeyValuePair = key:(StringBlock / Identifier) s1:Space "=" value:Value s2:Space ";" { return new ast.KeyValuePair(key, s1, value, s2); }
Value = StringBlock / Dictionary / List / Identifier
List = s1:Space "(" content:(Value Space ",")* s2:Space ")" { return new ast.List(s1, content, s2); }
Identifier = s1:Space id:$[a-zA-Z0-9_\.\/]* { return new ast.Identifier(s1, id); }
StringBlock = s1:Space '"' content:$([^\\\"] / '\\"' / "\\'" / '\\n')* '"' { return new ast.StringBlock(s1, content); }
Space = content:(WhiteSpace / CommentBlock)* { return new ast.Space(content); }
WhiteSpace = ws:$[ \t\n\r]+ { return new ast.WhiteSpace(ws); }
CommentBlock = "/*" content:$[^*]* "*/" { return new ast.CommentBlock(content); }