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
55
56
57
58
59
60
61
62
63
64
65
66
67
|
function Visitor() {}
Visitor.prototype = {
constructor: Visitor,
accept: function(object) {
return object && this[object.type] && this[object.type](object);
},
program: function(program) {
var statements = program.statements,
i, l;
for(i=0, l=statements.length; i<l; i++) {
this.accept(statements[i]);
}
},
block: function(block) {
this.accept(block.mustache);
this.accept(block.program);
this.accept(block.inverse);
},
mustache: function(mustache) {
this.accept(mustache.sexpr);
},
sexpr: function(sexpr) {
var params = sexpr.params, paramStrings = [], hash;
this.accept(sexpr.id);
for(var i=0, l=params.length; i<l; i++) {
this.accept(params[i]);
}
this.accept(sexpr.hash);
},
hash: function(hash) {
var pairs = hash.pairs;
for(var i=0, l=pairs.length; i<l; i++) {
this.accept(pairs[i][1]);
}
},
partial: function(partial) {
this.accept(partial.partialName);
this.accept(partial.context);
this.accept(partial.hash);
},
PARTIAL_NAME: function(partialName) {},
DATA: function(data) {
this.accept(data.id);
},
STRING: function(string) {},
NUMBER: function(number) {},
BOOLEAN: function(bool) {},
ID: function(id) {},
content: function(content) {},
comment: function(comment) {}
};
export default Visitor;
|