-
Notifications
You must be signed in to change notification settings - Fork 1
/
strXMLVisitor.java
36 lines (28 loc) · 923 Bytes
/
strXMLVisitor.java
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
public class strXMLVisitor extends strBaseVisitor<String> {
@Override
public String visitExprString(strParser.ExprStringContext ctx)
{
return ctx.STRING().getText() + super.visit(ctx.expr());
}
@Override
public String visitExprParenthesis(strParser.ExprParenthesisContext ctx) {
return "(" + super.visit(ctx.expr(0)) + ")" + super.visit(ctx.expr(1));
}
@Override
public String visitExprRule(strParser.ExprRuleContext ctx) {
String value = ctx.LR_STRING_BRACKET().getText().substring(1);
return "<" + value + ">" + super.visit(ctx.expr(0)) + "</" + value + ">" + super.visit(ctx.expr(1));
}
@Override
public String visitExprEnd(strParser.ExprEndContext ctx) {
return "";
}
@Override
public String visitExprEOF(strParser.ExprEOFContext ctx) {
return "";
}
@Override
public String visitExprEpsilon(strParser.ExprEpsilonContext ctx) {
return "";
}
}