String defVal = r.stringMatched(7);
if (null != defVal) defVal = neu + " " + defVal;
name = ExpressionParser.processPositionPlaceHolder(name);
ral.add(new F.T4(line, type, name, defVal));
}
return new Directive("", ctx()) {
@Override
public void call() {
for (F.T4<Integer, String, String, String> rd : ral) {
builder().addRenderArgs(rd._1, rd._2, rd._3, rd._4);
}
}
};
}
/*
* parse @args String s...
*/
public Token go() {
String remain = remain();
Regex r = new Regex(String.format("\\n?[ \\t\\x0B\\f]*%s%s(\\([ \t\f]*\\))?[ \t\f]*((?@{}))\\n?", a(), keyword()));
if (r.search(remain)) {
String matched = r.stringMatched();
if (matched.startsWith("\n") || matched.endsWith("\n")) {
ctx.getCodeBuilder().addBuilder(new Token.StringToken("\n", ctx));
}
String s = r.stringMatched(2);
s = S.strip(s, "{", "}");
step(matched.length());
return go2(s);
}
boolean startWithLineBreak = remain.startsWith("\n");
if (startWithLineBreak) {
remain = remain.substring(1);
}
String space = "";
Regex r0 = new Regex("^(\\s+).*");
if (r0.search(remain)) {
space = r0.stringMatched(1);
}
//space = startWithLineBreak ? "\n" + space : space;
step(space.length());
remain = remain.replaceFirst("^\\s+", "");
String key = String.format("%s%s ", a(), keyword());
if (!remain.startsWith(key)) {
raiseParseException("No argument declaration found");
}
step(key.length() + (startWithLineBreak ? 1 : 0));
remain = remain();
r = reg(dialect());
int step = 0;
//final List<CodeBuilder.RenderArgDeclaration> ral = new ArrayList<CodeBuilder.RenderArgDeclaration>();
while (r.search(remain)) {
String matched = r.stringMatched();
if (matched.startsWith("\n") || matched.startsWith("\r")) {
break;
}
step += matched.length();
String type = r.stringMatched(2);
checkRestrictedClass(type);
String name = r.stringMatched(4);
String neu = r.stringMatched(6); // check the 'new' keyword
if (null == neu) neu = "";
String defVal = r.stringMatched(7);
if (null != defVal) defVal = neu + " " + defVal;
name = ExpressionParser.processPositionPlaceHolder(name);
//ral.add(new CodeBuilder.RenderArgDeclaration(ctx().currentLine(), name, type, defVal));
ctx().getCodeBuilder().addRenderArgs(ctx().currentLine(), type, name, defVal);
}
step(step);
// strip off the following ";" symbol and line breaks
char c;
while (true) {
c = peek();
if ((' ' == c || ';' == c || '\n' == c) && ctx.hasRemain()) {
step(1);
if (space.length() > 0) {
ctx.getCodeBuilder().addBuilder(new Token.StringToken(space, ctx));
}
if ('\n' == c && startWithLineBreak) {
ctx.getCodeBuilder().addBuilder(new Token.StringToken("\n", ctx));
}
} else {
break;
}
}
return new Directive("", ctx()) {
@Override
public void call() {
// for (CodeBuilder.RenderArgDeclaration rd: ral) {
// builder().addRenderArgs(rd);
// }