return root;
}
static void tree(Node node, TokenParser parser, String endName) {
Token token;
TagToken tag;
MacroToken macro;
while( parser.hasNext() ) {
token = parser.next();
switch(token.getType()) {
case TOKEN_FIXED :
TextNode tn = new TextNode((FixedToken)token);
node.add(tn);
break;
case TOKEN_NOTE :
break;
case TOKEN_MACRO :
macro = (MacroToken) token;
if ( macro.getMacroName().equalsIgnoreCase(endName) ) {
return;
}
try {
MacroNode mn = new MacroNode((MacroToken) token);
node.add(mn);
if ( mn.endName != null ) {
tree(mn, parser, mn.endName);
}
} catch (ParseException e) {
JangodLogger.log(Level.WARNING, "can't create node with token >>> " + token, e.getCause());
}
break;
case TOKEN_ECHO :
VariableNode vn = new VariableNode((EchoToken) token);
node.add(vn);
break;
case TOKEN_TAG :
tag = (TagToken) token;
if ( tag.getTagName().equalsIgnoreCase(endName) ) {
return;
}
try {
TagNode tg = new TagNode((TagToken) token);
node.add(tg);