use of org.beetl.core.parser.BeetlParser.TextStatmentContext in project beetl2.0 by javamonkey.
the class AntlrProgramBuilder method parseTextOutputSt.
protected Statement parseTextOutputSt(TextOutputStContext ctx) {
TextStatmentContext tsc = ctx.textStatment();
FormatExpression format = null;
boolean isSafe = false;
if (tsc.NOT() != null) {
isSafe = true;
}
TextVarContext tvc = tsc.textVar();
if (tvc.COMMA() != null) {
String formatName = null;
String pattern = null;
String tokenName = null;
int line = 0;
TextformatContext tfc = tvc.textformat();
TerminalNode node = tfc.StringLiteral();
if (node != null) {
tokenName = pattern = getStringValue(node.getText());
line = node.getSymbol().getLine();
}
FunctionNsContext fnsc = tfc.functionNs();
if (fnsc != null) {
List<TerminalNode> listId = fnsc.Identifier();
formatName = this.getID(listId);
tokenName = formatName;
line = listId.get(0).getSymbol().getLine();
}
format = new FormatExpression(formatName, pattern, org.beetl.core.statement.GrammarToken.createToken(tokenName, line));
}
Expression exp = this.parseExpress(tvc.expression());
if (isSafe) {
SafePlaceholderST placeholder = new SafePlaceholderST(exp, format, null);
return placeholder;
} else {
PlaceholderST placeholder = new PlaceholderST(exp, format, null);
return placeholder;
}
}
Aggregations