-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCocoAstVisitor.cpp
73 lines (53 loc) · 1.71 KB
/
CocoAstVisitor.cpp
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
68
69
70
71
72
73
#include "CocoAstVisitor.h"
#include <cassert>
namespace CocoAST {
//void CocoAstVisitor::visit(CocoAST &ast) {}
void CocoAstVisitor::accept(std::list<Production> &productions) {
for(auto& prod : productions) {
prod.visit(*this);
}
}
void CocoAstVisitor::visit(Production &ast) {
if(ast.attr_decl)
ast.attr_decl->visit(*this);
if(ast.sem_text)
ast.sem_text->visit(*this);
ast.expression.visit(*this);
}
void CocoAstVisitor::visit(AttrDecl &ast) {}
void CocoAstVisitor::visit(Expression &ast) {
for(auto& term : ast.terms)
term.visit(*this);
}
void CocoAstVisitor::visit(Term &ast) {
if(ast.resolver)
ast.resolver->visit(*this);
for(auto& factor : ast.factors) {
assert(factor);
factor->visit(*this);
}
}
void CocoAstVisitor::visit(Factor_Sym &ast) {
ast.sym.visit(*this);
if(ast.attribs)
ast.attribs->visit(*this);
}
void CocoAstVisitor::visit(Factor_Braced &ast) {
ast.expression.visit(*this);
}
void CocoAstVisitor::visit(Factor_Optional &ast) {
ast.expression.visit(*this);
}
void CocoAstVisitor::visit(Factor_Iterate &ast) {
ast.expression.visit(*this);
}
void CocoAstVisitor::visit(Factor_SemText &ast) {
ast.semText.visit(*this);
}
void CocoAstVisitor::visit(Factor_ANY &ast) {}
void CocoAstVisitor::visit(Factor_SYNC &ast) {}
void CocoAstVisitor::visit(Resolver &ast) {}
void CocoAstVisitor::visit(Sym &ast) {}
void CocoAstVisitor::visit(Attribs &ast) {}
void CocoAstVisitor::visit(SemText &ast) {}
}