-
Notifications
You must be signed in to change notification settings - Fork 1
/
accepts-parser.pegjs
55 lines (49 loc) · 1009 Bytes
/
accepts-parser.pegjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
tags
= head:tag tail:( " "+ tag )* {
var options = {};
options[head.name] = head;
for (var index = 0; index < tail.length; index++) {
var node = tail[index][1];
options[node.name] = node;
}
return {
type: "options",
options: options
};
}
/ tree:tree {
return tree;
}
tag
= _ name:name as:(":" name)? tree:tree plural:"*"? {
tree.name = name;
if (plural) {
tree.plural = plural;
}
if (as) {
tree.as = as[1];
}
return tree;
}
tree
= "[" _ type:$( "body" / "text" / "html" / "entries" ) _ "]" {
return {
type: type,
name: null
}
}
/ "(" _ tags:tags _ ")" {
return tags;
}
/ "" {
return {
type: "body",
name: null
};
}
name
= name:$([a-zA-Z_0-9-]+) {
return name;
}
_
= " "*