📄 fmparser.java
字号:
break;
default:
jj_la1[33] = jj_gen;
;
}
end = LooseDirectiveEnd();
AssignmentInstruction ai = new AssignmentInstruction(scope);
for (int i = 0; i< assignments.size(); i++) {
ai.addAssignment((Assignment) assignments.get(i));
}
ai.setNamespaceExp(nsExp);
ai.setLocation(template, start, end);
{if (true) return ai;}
break;
case IN:
case DIRECTIVE_END:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IN:
id = jj_consume_token(IN);
nsExp = Expression();
if (scope != Assignment.NAMESPACE) {if (true) throw new ParseException(getErrorStart(id) + "\nCannot assign to namespace here.", id.beginLine, id.beginColumn);}
break;
default:
jj_la1[34] = jj_gen;
;
}
jj_consume_token(DIRECTIVE_END);
block = OptionalBlock();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case END_LOCAL:
end = jj_consume_token(END_LOCAL);
if (scope != Assignment.LOCAL) {if (true) throw new ParseException(getErrorStart(end) + "\nMismatched assignment tags.", end.beginLine, end.beginColumn);}
break;
case END_ASSIGN:
end = jj_consume_token(END_ASSIGN);
if (scope != Assignment.NAMESPACE) {if (true) throw new ParseException(getErrorStart(end) + "\nMismatched assignment tags.", end.beginLine, end.beginColumn);}
break;
case END_GLOBAL:
end = jj_consume_token(END_GLOBAL);
if (scope != Assignment.GLOBAL) {if (true) throw new ParseException(getErrorStart(end) + "\nMismatched assignment tags", end.beginLine, end.beginColumn);}
break;
default:
jj_la1[35] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
BlockAssignment ba = new BlockAssignment(block, varName, scope, nsExp);
ba.setLocation(template, start, end);
{if (true) return ba;}
break;
default:
jj_la1[36] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
final public Include Include() throws ParseException {
Expression nameExp;
Token att, start, end;
Expression exp, parseExp = null, encodingExp = null;
start = jj_consume_token(INCLUDE);
nameExp = Expression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SEMICOLON:
jj_consume_token(SEMICOLON);
break;
default:
jj_la1[37] = jj_gen;
;
}
label_10:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[38] = jj_gen;
break label_10;
}
att = jj_consume_token(ID);
jj_consume_token(EQUALS);
exp = Expression();
String attString = att.image;
if (attString.equalsIgnoreCase("parse")) {
parseExp = exp;
}
else if (attString.equalsIgnoreCase("encoding")) {
encodingExp = exp;
}
else {
String msg = getErrorStart(att)
+ "\nexpecting parse= or encoding= to be specified.";
{if (true) throw new ParseException(msg, att.beginLine, att.beginColumn);}
}
}
end = LooseDirectiveEnd();
Include result = new Include(template, nameExp, encodingExp, parseExp);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public LibraryLoad Import() throws ParseException {
Token start, end, ns;
Expression nameExp;
start = jj_consume_token(IMPORT);
nameExp = Expression();
jj_consume_token(AS);
ns = jj_consume_token(ID);
end = LooseDirectiveEnd();
LibraryLoad result = new LibraryLoad(template, nameExp, ns.image);
result.setLocation(template, start, end);
template.addImport(result);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public Macro Macro() throws ParseException {
Token arg, start, end;
Expression nameExp;
String name;
ArrayList argNames = new ArrayList();
HashMap args = new HashMap();
ArrayList defNames = new ArrayList();
Expression defValue=null;
TemplateElement block;
boolean isFunction = false, hasDefaults=false;
boolean isCatchAll = false;
String catchAll = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case MACRO:
start = jj_consume_token(MACRO);
break;
case FUNCTION:
start = jj_consume_token(FUNCTION);
isFunction = true;
break;
default:
jj_la1[39] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (inMacro || inFunction) {
{if (true) throw new ParseException(getErrorStart(start)
+ "\nMacros cannot be nested.", start.beginLine, start.endLine);}
}
if (isFunction) inFunction = true; else inMacro = true;
nameExp = IdentifierOrStringLiteral();
name = (nameExp instanceof StringLiteral) ? ((StringLiteral) nameExp).getAsString() : nameExp.toString();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OPEN_PAREN:
jj_consume_token(OPEN_PAREN);
break;
default:
jj_la1[40] = jj_gen;
;
}
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[41] = jj_gen;
break label_11;
}
arg = jj_consume_token(ID);
defValue = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ELLIPSIS:
jj_consume_token(ELLIPSIS);
isCatchAll = true;
break;
default:
jj_la1[42] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EQUALS:
jj_consume_token(EQUALS);
defValue = Expression();
defNames.add(arg.image);
hasDefaults = true;
break;
default:
jj_la1[43] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
default:
jj_la1[44] = jj_gen;
;
}
if (catchAll != null) {
{if (true) throw new ParseException(getErrorStart(arg)
+ "\nThere may only be one \"catch-all\" parameter in a macro declaration, "
+ "and it must be the last parameter.", arg.beginLine, arg.endLine);}
}
if (isCatchAll) {
if (defValue != null) {
{if (true) throw new ParseException(getErrorStart(arg)
+ "\n\"Catch-all\" macro parameter may not have a default value.",
arg.beginLine, arg.endLine);}
}
catchAll = arg.image;
} else {
argNames.add(arg.image);
if (hasDefaults && defValue == null) {
{if (true) throw new ParseException(getErrorStart(arg)
+ "\nIn a macro declaration, parameters without a default value "
+ "must all occur before the parameters with default values.",
arg.beginLine, arg.endLine);}
}
args.put(arg.image, defValue);
}
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CLOSE_PAREN:
jj_consume_token(CLOSE_PAREN);
break;
default:
jj_la1[45] = jj_gen;
;
}
jj_consume_token(DIRECTIVE_END);
block = OptionalBlock();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case END_MACRO:
end = jj_consume_token(END_MACRO);
if(isFunction) {if (true) throw new ParseException(getErrorStart(start) + "\nExpected function end tag here.", start.beginLine, start.endLine);}
break;
case END_FUNCTION:
end = jj_consume_token(END_FUNCTION);
if(!isFunction) {if (true) throw new ParseException(getErrorStart(start) + "\nExpected macro end tag here.", start.beginLine, start.endLine);}
break;
default:
jj_la1[46] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
inMacro = inFunction = false;
Macro result = new Macro(name, argNames, args, block);
result.setCatchAll(catchAll);
result.isFunction = isFunction;
result.setLocation(template, start, end);
template.addMacro(result);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public CompressedBlock Compress() throws ParseException {
TemplateElement block;
Token start, end;
start = jj_consume_token(COMPRESS);
block = OptionalBlock();
end = jj_consume_token(END_COMPRESS);
CompressedBlock cb = new CompressedBlock(block);
cb.setLocation(template, start, end);
{if (true) return cb;}
throw new Error("Missing return statement in function");
}
final public TemplateElement UnifiedMacroTransform() throws ParseException {
Token start=null, end, t;
HashMap namedArgs = null;
ArrayList positionalArgs = null, bodyParameters = null;
String directiveName = null;
TemplateElement nestedBlock = null;
Expression exp;
start = jj_consume_token(UNIFIED_CALL);
exp = Expression();
if (exp instanceof Identifier || (exp instanceof Dot && ((Dot) exp).onlyHasIdentifiers())) {
directiveName = exp.getCanonicalForm();
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERMINATING_WHITESPACE:
jj_consume_token(TERMINATING_WHITESPACE);
break;
default:
jj_la1[47] = jj_gen;
;
}
if (jj_2_12(2147483647)) {
namedArgs = NamedArgs();
} else {
positionalArgs = PositionalArgs();
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SEMICOLON:
jj_consume_token(SEMICOLON);
bodyParameters = new ArrayList();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
t = jj_consume_token(ID);
bodyParameters.add(t.image);
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[48] = jj_gen;
break label_12;
}
jj_consume_token(COMMA);
t = jj_consume_token(ID);
bodyParameters.add(t.image);
}
break;
default:
jj_la1[49] = jj_gen;
;
}
break;
default:
jj_la1[50] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EMPTY_DIRECTIVE_END:
end = jj_consume_token(EMPTY_DIRECTIVE_END);
break;
case DIRECTIVE_END:
jj_consume_token(DIRECTIVE_END);
nestedBlock = OptionalBlock();
end = jj_consume_token(UNIFIED_CALL_END);
String s = end.image.substring(3);
s = s.substring(0, s.length() -1).trim();
if (s.length() >0 && !s.equals(directiveName)) {
String msg = getErrorStart(end);
if (directiveName == null) {
{if (true) throw new ParseException(msg + "\nExpecting </@>", end.beginLine, end.beginColumn);}
}
else {
{if (true) throw new ParseException(msg + "\nExpecting </@> or </@" + directiveName + ">", end.beginLine, end.beginColumn);}
}
}
break;
default:
jj_la1[51] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
TemplateElement result = (positionalArgs != null) ? new UnifiedCall(exp, positionalArgs, nestedBlock, bodyParameters)
: new UnifiedCall(exp, namedArgs, nestedBlock, bodyParameters);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TemplateElement Call() throws ParseException {
Token start, end, id;
HashMap namedArgs = null;
ArrayList positionalArgs = null;
String macroName= null;
start = jj_consume_token(CALL);
id = jj_consume_token(ID);
macroName = id.image;
if (jj_2_14(2147483647)) {
namedArgs = NamedArgs();
} else {
if (jj_2_13(2147483647)) {
jj_consume_token(OPEN_PAREN);
} else {
;
}
positionalArgs = PositionalArgs();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CLOSE_PAREN:
jj_consume_token(CLOSE_PAREN);
break;
default:
jj_la1[52] = jj_gen;
;
}
}
end = LooseDirectiveEnd();
UnifiedCall result = null;
if (positionalArgs != null) {
result = new UnifiedCall(new Identifier(macroName), positionalArgs, null, null);
}
else {
result = new UnifiedCall(new Identifier(macroName), namedArgs, null, null);
}
result.legacySyntax = true;
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public HashMap NamedArgs() throws ParseException {
HashMap result = new
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -