=0; i--) {
char c = text[i];
if (c == '\n' || c == '\r') {
return false;
}
if (!Character.isWhitespace(c)) {
return true;
}
}
return true;
}
boolean isIgnorable() {
if (text == null || text.length == 0) {
return true;
}
if (!isWhitespace()) {
return false;
}
boolean atTopLevel = (getParent().getParent() == null);
TemplateElement prevSibling = previousSibling();
TemplateElement nextSibling = nextSibling();
return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling))
&& ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling));
}
private boolean nonOutputtingType(TemplateElement element) {
return (element instanceof Macro ||
element instanceof Assignment ||
element instanceof AssignmentInstruction ||
element instanceof PropertySetting ||
element instanceof LibraryLoad ||
element instanceof Comment);
}
private static char[] substring(char[] c, int from, int to) {
char[] c2 = new char[to - from];
System.arraycopy(c, from, c2, 0, c2.length);
return c2;
}
private static char[] substring(char[] c, int from) {
return substring(c, from, c.length);
}
private static char[] trim(char[] c) {
if (c.length == 0) {
return c;
}
return new String(c).trim().toCharArray();
}
private static char[] concat(char[] c1, char[] c2) {
char[] c = new char[c1.length + c2.length];
System.arraycopy(c1, 0, c, 0, c1.length);
System.arraycopy(c2, 0, c, c1.length, c2.length);
return c;
}
boolean isWhitespace() {
return text == null || trim(text).length == 0;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/ConditionalBlock.java 0000644 0001750 0001750 00000010360 11723544470 025560 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import freemarker.template.*;
/**
* An element that represents a conditionally executed block.
* @author Jonathan Revusky
*/
final class ConditionalBlock extends TemplateElement {
final Expression condition;
private final boolean isFirst;
boolean isSimple;
ConditionalBlock(Expression condition, TemplateElement nestedBlock, boolean isFirst)
{
this.condition = condition;
this.nestedBlock = nestedBlock;
this.isFirst = isFirst;
}
void accept(Environment env) throws TemplateException, IOException {
if (condition == null || condition.isTrue(env)) {
if (nestedBlock != null) {
env.visit(nestedBlock);
}
}
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer();
if (condition == null) {
buf.append("<#else");
}
else if (isFirst) {
buf.append("<#if ");
}
else {
buf.append("<#elseif ");
}
if (condition != null) {
buf.append(condition.getCanonicalForm());
}
buf.append(">");
if (nestedBlock != null) {
buf.append(nestedBlock.getCanonicalForm());
}
if (isSimple) {
buf.append("#if>");
}
return buf.toString();
}
public String getDescription() {
String s = "if ";
if (condition == null) {
s = "else ";
}
else if (!isFirst) {
s = "elseif ";
}
String cond = condition != null ? condition.toString() : "";
return s + cond;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Environment.java 0000644 0001750 0001750 00000176330 11723544472 024662 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.*;
import java.text.*;
import java.util.*;
import freemarker.ext.beans.BeansWrapper;
import freemarker.log.Logger;
import freemarker.template.*;
import freemarker.template.utility.DateUtil;
import freemarker.template.utility.DateUtil.DateToISO8601CalendarFactory;
import freemarker.template.utility.StringUtil;
import freemarker.template.utility.UndeclaredThrowableException;
/**
* Object that represents the runtime environment during template processing.
* For every invocation of a Template.process() method, a new instance
* of this object is created, and then discarded when process() returns.
* This object stores the set of temporary variables created by the template,
* the value of settings set by the template, the reference to the data model root,
* etc. Everything that is needed to fulfill the template processing job.
*
* Data models that need to access the Environment
* object that represents the template processing on the current thread can use
* the {@link #getCurrentEnvironment()} method.
*
*
If you need to modify or read this object before or after the process
* call, use {@link Template#createProcessingEnvironment(Object rootMap, Writer out, ObjectWrapper wrapper)}
*
* @author Jonathan Revusky
* @author Attila Szegedi
*/
public final class Environment extends Configurable {
private static final ThreadLocal threadEnv = new ThreadLocal();
private static final Logger logger = Logger.getLogger("freemarker.runtime");
private static final Logger attemptLogger = Logger.getLogger("freemarker.runtime.attempt");
private static final Map localizedNumberFormats = new HashMap();
private static final Map localizedDateFormats = new HashMap();
// Do not use this object directly; clone it first! DecimalFormat isn't
// thread-safe.
private static final DecimalFormat C_NUMBER_FORMAT
= new DecimalFormat(
"0.################",
new DecimalFormatSymbols(Locale.US));
static {
C_NUMBER_FORMAT.setGroupingUsed(false);
C_NUMBER_FORMAT.setDecimalSeparatorAlwaysShown(false);
}
private final TemplateHashModel rootDataModel;
private final ArrayList elementStack = new ArrayList();
private final ArrayList recoveredErrorStack = new ArrayList();
private NumberFormat numberFormat;
private Map numberFormats;
private DateFormat timeFormat, dateFormat, dateTimeFormat;
private Map[] dateFormats;
private NumberFormat cNumberFormat;
/**
* Used by the "iso_" built-ins to accelerate formatting.
* @see #getISOBuiltInCalendar()
*/
private DateToISO8601CalendarFactory isoBuiltInCalendarFactory;
private Collator collator;
private Writer out;
private Macro.Context currentMacroContext;
private ArrayList localContextStack;
private Namespace mainNamespace, currentNamespace, globalNamespace;
private HashMap loadedLibs;
private Throwable lastThrowable;
private TemplateModel lastReturnValue;
private HashMap macroToNamespaceLookup = new HashMap();
private TemplateNodeModel currentVisitorNode;
private TemplateSequenceModel nodeNamespaces;
// Things we keep track of for the fallback mechanism.
private int nodeNamespaceIndex;
private String currentNodeName, currentNodeNS;
private String cachedURLEscapingCharset;
private boolean urlEscapingCharsetCached;
/**
* Retrieves the environment object associated with the current
* thread. Data model implementations that need access to the
* environment can call this method to obtain the environment object
* that represents the template processing that is currently running
* on the current thread.
*/
public static Environment getCurrentEnvironment()
{
return (Environment)threadEnv.get();
}
public Environment(Template template, final TemplateHashModel rootDataModel, Writer out)
{
super(template);
this.globalNamespace = new Namespace(null);
this.currentNamespace = mainNamespace = new Namespace(template);
this.out = out;
this.rootDataModel = rootDataModel;
importMacros(template);
}
/**
* Retrieves the currently processed template.
*/
public Template getTemplate()
{
return (Template)getParent();
}
/**
* Deletes cached values that meant to be valid only during a single
* template execution.
*/
private void clearCachedValues() {
numberFormats = null;
numberFormat = null;
dateFormats = null;
collator = null;
cachedURLEscapingCharset = null;
urlEscapingCharsetCached = false;
}
/**
* Processes the template to which this environment belongs.
*/
public void process() throws TemplateException, IOException {
Object savedEnv = threadEnv.get();
threadEnv.set(this);
try {
// Cached values from a previous execution are possibly outdated.
clearCachedValues();
try {
doAutoImportsAndIncludes(this);
visit(getTemplate().getRootTreeNode());
// It's here as we must not flush if there was an exception.
if (getAutoFlush()) {
out.flush();
}
} finally {
// It's just to allow the GC to free memory...
clearCachedValues();
}
} finally {
threadEnv.set(savedEnv);
}
}
/**
* "Visit" the template element.
*/
void visit(TemplateElement element)
throws TemplateException, IOException
{
pushElement(element);
try {
element.accept(this);
}
catch (TemplateException te) {
handleTemplateException(te);
}
finally {
popElement();
}
}
private static final TemplateModel[] NO_OUT_ARGS = new TemplateModel[0];
public void visit(final TemplateElement element,
TemplateDirectiveModel directiveModel, Map args,
final List bodyParameterNames) throws TemplateException, IOException {
TemplateDirectiveBody nested;
if(element == null) {
nested = null;
}
else {
nested = new TemplateDirectiveBody() {
public void render(Writer newOut) throws TemplateException, IOException {
Writer prevOut = out;
out = newOut;
try {
Environment.this.visit(element);
}
finally {
out = prevOut;
}
}
};
}
final TemplateModel[] outArgs;
if(bodyParameterNames == null || bodyParameterNames.isEmpty()) {
outArgs = NO_OUT_ARGS;
}
else {
outArgs = new TemplateModel[bodyParameterNames.size()];
}
if(outArgs.length > 0) {
pushLocalContext(new LocalContext() {
public TemplateModel getLocalVariable(String name) {
int index = bodyParameterNames.indexOf(name);
return index != -1 ? outArgs[index] : null;
}
public Collection getLocalVariableNames() {
return bodyParameterNames;
}
});
}
try {
directiveModel.execute(this, args, outArgs, nested);
}
finally {
if(outArgs.length > 0) {
popLocalContext();
}
}
}
/**
* "Visit" the template element, passing the output
* through a TemplateTransformModel
* @param element the element to visit through a transform
* @param transform the transform to pass the element output
* through
* @param args optional arguments fed to the transform
*/
void visit(TemplateElement element,
TemplateTransformModel transform,
Map args)
throws TemplateException, IOException
{
try {
Writer tw = transform.getWriter(out, args);
if (tw == null) tw = EMPTY_BODY_WRITER;
TransformControl tc =
tw instanceof TransformControl
? (TransformControl)tw
: null;
Writer prevOut = out;
out = tw;
try {
if(tc == null || tc.onStart() != TransformControl.SKIP_BODY) {
do {
if(element != null) {
visit(element);
}
} while(tc != null && tc.afterBody() == TransformControl.REPEAT_EVALUATION);
}
}
catch(Throwable t) {
try {
if(tc != null) {
tc.onError(t);
}
else {
throw t;
}
}
catch(TemplateException e) {
throw e;
}
catch(IOException e) {
throw e;
}
catch(RuntimeException e) {
throw e;
}
catch(Error e) {
throw e;
}
catch(Throwable e) {
throw new UndeclaredThrowableException(e);
}
}
finally {
out = prevOut;
tw.close();
}
}
catch(TemplateException te) {
handleTemplateException(te);
}
}
/**
* Visit a block using buffering/recovery
*/
void visit(TemplateElement attemptBlock, TemplateElement recoveryBlock)
throws TemplateException, IOException {
Writer prevOut = this.out;
StringWriter sw = new StringWriter();
this.out = sw;
TemplateException thrownException = null;
try {
visit(attemptBlock);
} catch (TemplateException te) {
thrownException = te;
} finally {
this.out = prevOut;
}
if (thrownException != null) {
if (attemptLogger.isDebugEnabled()) {
attemptLogger.debug("Error in attempt block " +
attemptBlock.getStartLocationQuoted(), thrownException);
}
try {
recoveredErrorStack.add(thrownException.getMessage());
visit(recoveryBlock);
} finally {
recoveredErrorStack.remove(recoveredErrorStack.size() -1);
}
} else {
out.write(sw.toString());
}
}
String getCurrentRecoveredErrorMesssage() throws TemplateException {
if(recoveredErrorStack.isEmpty()) {
throw new TemplateException(
".error is not available outside of a <#recover> block", this);
}
return (String) recoveredErrorStack.get(recoveredErrorStack.size() -1);
}
void visit(BodyInstruction.Context bctxt) throws TemplateException, IOException {
Macro.Context invokingMacroContext = getCurrentMacroContext();
ArrayList prevLocalContextStack = localContextStack;
TemplateElement body = invokingMacroContext.body;
if (body != null) {
this.currentMacroContext = invokingMacroContext.prevMacroContext;
currentNamespace = invokingMacroContext.bodyNamespace;
Configurable prevParent = getParent();
setParent(currentNamespace.getTemplate());
this.localContextStack = invokingMacroContext.prevLocalContextStack;
if (invokingMacroContext.bodyParameterNames != null) {
pushLocalContext(bctxt);
}
try {
visit(body);
}
finally {
if (invokingMacroContext.bodyParameterNames != null) {
popLocalContext();
}
this.currentMacroContext = invokingMacroContext;
currentNamespace = getMacroNamespace(invokingMacroContext.getMacro());
setParent(prevParent);
this.localContextStack = prevLocalContextStack;
}
}
}
/**
* "visit" an IteratorBlock
*/
void visit(IteratorBlock.Context ictxt)
throws TemplateException, IOException
{
pushLocalContext(ictxt);
try {
ictxt.runLoop(this);
}
catch (BreakInstruction.Break br) {
}
catch (TemplateException te) {
handleTemplateException(te);
}
finally {
popLocalContext();
}
}
/**
* "Visit" A TemplateNodeModel
*/
void visit(TemplateNodeModel node, TemplateSequenceModel namespaces)
throws TemplateException, IOException
{
if (nodeNamespaces == null) {
SimpleSequence ss = new SimpleSequence(1);
ss.add(currentNamespace);
nodeNamespaces = ss;
}
int prevNodeNamespaceIndex = this.nodeNamespaceIndex;
String prevNodeName = this.currentNodeName;
String prevNodeNS = this.currentNodeNS;
TemplateSequenceModel prevNodeNamespaces = nodeNamespaces;
TemplateNodeModel prevVisitorNode = currentVisitorNode;
currentVisitorNode = node;
if (namespaces != null) {
this.nodeNamespaces = namespaces;
}
try {
TemplateModel macroOrTransform = getNodeProcessor(node);
if (macroOrTransform instanceof Macro) {
visit((Macro) macroOrTransform, null, null, null, null);
}
else if (macroOrTransform instanceof TemplateTransformModel) {
visit(null, (TemplateTransformModel) macroOrTransform, null);
}
else {
String nodeType = node.getNodeType();
if (nodeType != null) {
// If the node's type is 'text', we just output it.
if ((nodeType.equals("text") && node instanceof TemplateScalarModel))
{
out.write(((TemplateScalarModel) node).getAsString());
}
else if (nodeType.equals("document")) {
recurse(node, namespaces);
}
// We complain here, unless the node's type is 'pi', or "comment" or "document_type", in which case
// we just ignore it.
else if (!nodeType.equals("pi")
&& !nodeType.equals("comment")
&& !nodeType.equals("document_type"))
{
String nsBit = "";
String ns = node.getNodeNamespace();
if (ns != null) {
if (ns.length() >0) {
nsBit = " and namespace " + ns;
} else {
nsBit = " and no namespace";
}
}
throw new TemplateException("No macro or transform defined for node named "
+ node.getNodeName() + nsBit
+ ", and there is no fallback handler called @" + nodeType + " either.",
this);
}
}
else {
String nsBit = "";
String ns = node.getNodeNamespace();
if (ns != null) {
if (ns.length() >0) {
nsBit = " and namespace " + ns;
} else {
nsBit = " and no namespace";
}
}
throw new TemplateException("No macro or transform defined for node with name "
+ node.getNodeName() + nsBit
+ ", and there is no macro or transform called @default either.",
this);
}
}
}
finally {
this.currentVisitorNode = prevVisitorNode;
this.nodeNamespaceIndex = prevNodeNamespaceIndex;
this.currentNodeName = prevNodeName;
this.currentNodeNS = prevNodeNS;
this.nodeNamespaces = prevNodeNamespaces;
}
}
void fallback() throws TemplateException, IOException {
TemplateModel macroOrTransform = getNodeProcessor(currentNodeName, currentNodeNS, nodeNamespaceIndex);
if (macroOrTransform instanceof Macro) {
visit((Macro) macroOrTransform, null, null, null, null);
}
else if (macroOrTransform instanceof TemplateTransformModel) {
visit(null, (TemplateTransformModel) macroOrTransform, null);
}
}
/**
* "visit" a macro.
*/
void visit(Macro macro,
Map namedArgs,
List positionalArgs,
List bodyParameterNames,
TemplateElement nestedBlock)
throws TemplateException, IOException
{
if (macro == Macro.DO_NOTHING_MACRO) {
return;
}
pushElement(macro);
try {
Macro.Context previousMacroContext = currentMacroContext;
Macro.Context mc = macro.new Context(this, nestedBlock, bodyParameterNames);
String catchAll = macro.getCatchAll();
TemplateModel unknownVars = null;
if (namedArgs != null) {
if (catchAll != null)
unknownVars = new SimpleHash();
for (Iterator it = namedArgs.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
String varName = (String) entry.getKey();
boolean hasVar = macro.hasArgNamed(varName);
if (hasVar || catchAll != null) {
Expression arg = (Expression) entry.getValue();
TemplateModel value = arg.getAsTemplateModel(this);
if (hasVar) {
mc.setLocalVar(varName, value);
} else {
((SimpleHash)unknownVars).put(varName, value);
}
} else {
String msg = "Macro " + macro.getName() + " has no such argument: " + varName;
throw new TemplateException(msg, this);
}
}
}
else if (positionalArgs != null) {
if (catchAll != null)
unknownVars = new SimpleSequence();
String[] argumentNames = macro.getArgumentNamesInternal();
int size = positionalArgs.size();
if (argumentNames.length < size && catchAll == null) {
throw new TemplateException("Macro " + macro.getName()
+ " only accepts " + argumentNames.length + " parameters.", this);
}
for (int i = 0; i < size; i++) {
Expression argExp = (Expression) positionalArgs.get(i);
TemplateModel argModel = argExp.getAsTemplateModel(this);
try {
if (i < argumentNames.length) {
String argName = argumentNames[i];
mc.setLocalVar(argName, argModel);
} else {
((SimpleSequence)unknownVars).add(argModel);
}
} catch (RuntimeException re) {
throw new TemplateException(re, this);
}
}
}
if (catchAll != null) {
mc.setLocalVar(catchAll, unknownVars);
}
ArrayList prevLocalContextStack = localContextStack;
localContextStack = null;
Namespace prevNamespace = currentNamespace;
Configurable prevParent = getParent();
currentNamespace = (Namespace) macroToNamespaceLookup.get(macro);
currentMacroContext = mc;
try {
mc.runMacro(this);
}
catch (ReturnInstruction.Return re) {
}
catch (TemplateException te) {
handleTemplateException(te);
} finally {
currentMacroContext = previousMacroContext;
localContextStack = prevLocalContextStack;
currentNamespace = prevNamespace;
setParent(prevParent);
}
} finally {
popElement();
}
}
void visitMacroDef(Macro macro) {
macroToNamespaceLookup.put(macro, currentNamespace);
currentNamespace.put(macro.getName(), macro);
}
Namespace getMacroNamespace(Macro macro) {
return (Namespace) macroToNamespaceLookup.get(macro);
}
void recurse(TemplateNodeModel node, TemplateSequenceModel namespaces)
throws TemplateException, IOException
{
if (node == null) {
node = this.getCurrentVisitorNode();
if (node == null) {
throw new TemplateModelException(
"The target node of recursion is missing or null.");
}
}
TemplateSequenceModel children = node.getChildNodes();
if (children == null) return;
for (int i=0; isetting directive, it still must be allowed to set it from Java
* code while the template executes, since some frameworks allow templates
* to actually change the output encoding on-the-fly.
*/
public void setOutputEncoding(String outputEncoding) {
urlEscapingCharsetCached = false;
super.setOutputEncoding(outputEncoding);
}
/**
* Returns the name of the charset that should be used for URL encoding.
* This will be null
if the information is not available.
* The function caches the return value, so it is quick to call it
* repeately.
*/
String getEffectiveURLEscapingCharset() {
if (!urlEscapingCharsetCached) {
cachedURLEscapingCharset = getURLEscapingCharset();
if (cachedURLEscapingCharset == null) {
cachedURLEscapingCharset = getOutputEncoding();
}
urlEscapingCharsetCached = true;
}
return cachedURLEscapingCharset;
}
Collator getCollator() {
if(collator == null) {
collator = Collator.getInstance(getLocale());
}
return collator;
}
public void setOut(Writer out) {
this.out = out;
}
public Writer getOut() {
return out;
}
String formatNumber(Number number) {
if(numberFormat == null) {
numberFormat = getNumberFormatObject(getNumberFormat());
}
return numberFormat.format(number);
}
public void setNumberFormat(String formatName) {
super.setNumberFormat(formatName);
numberFormat = null;
}
String formatDate(Date date, int type) throws TemplateModelException {
DateFormat df = getDateFormatObject(type);
if(df == null) {
throw new TemplateModelException("Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date.");
}
return df.format(date);
}
public void setTimeFormat(String formatName) {
super.setTimeFormat(formatName);
timeFormat = null;
}
public void setDateFormat(String formatName) {
super.setDateFormat(formatName);
dateFormat = null;
}
public void setDateTimeFormat(String formatName) {
super.setDateTimeFormat(formatName);
dateTimeFormat = null;
}
public Configuration getConfiguration() {
return getTemplate().getConfiguration();
}
TemplateModel getLastReturnValue() {
return lastReturnValue;
}
void setLastReturnValue(TemplateModel lastReturnValue) {
this.lastReturnValue = lastReturnValue;
}
void clearLastReturnValue() {
this.lastReturnValue = null;
}
NumberFormat getNumberFormatObject(String pattern)
{
if(numberFormats == null) {
numberFormats = new HashMap();
}
NumberFormat format = (NumberFormat) numberFormats.get(pattern);
if(format != null)
{
return format;
}
// Get format from global format cache
synchronized(localizedNumberFormats)
{
Locale locale = getLocale();
NumberFormatKey fk = new NumberFormatKey(pattern, locale);
format = (NumberFormat)localizedNumberFormats.get(fk);
if(format == null)
{
// Add format to global format cache. Note this is
// globally done once per locale per pattern.
if("number".equals(pattern))
{
format = NumberFormat.getNumberInstance(locale);
}
else if("currency".equals(pattern))
{
format = NumberFormat.getCurrencyInstance(locale);
}
else if("percent".equals(pattern))
{
format = NumberFormat.getPercentInstance(locale);
}
else if ("computer".equals(pattern))
{
format = getCNumberFormat();
}
else
{
format = new DecimalFormat(pattern, new DecimalFormatSymbols(getLocale()));
}
localizedNumberFormats.put(fk, format);
}
}
// Clone it and store the clone in the local cache
format = (NumberFormat)format.clone();
numberFormats.put(pattern, format);
return format;
}
DateFormat getDateFormatObject(int dateType)
throws
TemplateModelException
{
switch(dateType) {
case TemplateDateModel.UNKNOWN: {
return null;
}
case TemplateDateModel.TIME: {
if(timeFormat == null) {
timeFormat = getDateFormatObject(dateType, getTimeFormat());
}
return timeFormat;
}
case TemplateDateModel.DATE: {
if(dateFormat == null) {
dateFormat = getDateFormatObject(dateType, getDateFormat());
}
return dateFormat;
}
case TemplateDateModel.DATETIME: {
if(dateTimeFormat == null) {
dateTimeFormat = getDateFormatObject(dateType, getDateTimeFormat());
}
return dateTimeFormat;
}
default: {
throw new TemplateModelException("Unrecognized date type " + dateType);
}
}
}
DateFormat getDateFormatObject(int dateType, String pattern)
throws
TemplateModelException
{
if(dateFormats == null) {
dateFormats = new Map[4];
dateFormats[TemplateDateModel.UNKNOWN] = new HashMap();
dateFormats[TemplateDateModel.TIME] = new HashMap();
dateFormats[TemplateDateModel.DATE] = new HashMap();
dateFormats[TemplateDateModel.DATETIME] = new HashMap();
}
Map typedDateFormat = dateFormats[dateType];
DateFormat format = (DateFormat) typedDateFormat.get(pattern);
if(format != null) {
return format;
}
// Get format from global format cache
synchronized(localizedDateFormats) {
Locale locale = getLocale();
TimeZone timeZone = getTimeZone();
DateFormatKey fk = new DateFormatKey(dateType, pattern, locale, timeZone);
format = (DateFormat)localizedDateFormats.get(fk);
if(format == null) {
// Add format to global format cache. Note this is
// globally done once per locale per pattern.
StringTokenizer tok = new StringTokenizer(pattern, "_");
int style = tok.hasMoreTokens() ? parseDateStyleToken(tok.nextToken()) : DateFormat.DEFAULT;
if(style != -1) {
switch(dateType) {
case TemplateDateModel.UNKNOWN: {
throw new TemplateModelException(
"Can't convert the date to string using a " +
"built-in format, because it is not known which " +
"parts of the date variable are in use. Use " +
"?date, ?time or ?datetime built-in, or " +
"?string. or ?string() built-in "+
"with explicit formatting pattern with this date.");
}
case TemplateDateModel.TIME: {
format = DateFormat.getTimeInstance(style, locale);
break;
}
case TemplateDateModel.DATE: {
format = DateFormat.getDateInstance(style, locale);
break;
}
case TemplateDateModel.DATETIME: {
int timestyle = tok.hasMoreTokens() ? parseDateStyleToken(tok.nextToken()) : style;
if(timestyle != -1) {
format = DateFormat.getDateTimeInstance(style, timestyle, locale);
}
break;
}
}
}
if(format == null) {
try {
format = new SimpleDateFormat(pattern, locale);
}
catch(IllegalArgumentException e) {
throw new TemplateModelException("Can't parse " + pattern + " to a date format.", e);
}
}
format.setTimeZone(timeZone);
localizedDateFormats.put(fk, format);
}
}
// Clone it and store the clone in the local cache
format = (DateFormat)format.clone();
typedDateFormat.put(pattern, format);
return format;
}
int parseDateStyleToken(String token) {
if("short".equals(token)) {
return DateFormat.SHORT;
}
if("medium".equals(token)) {
return DateFormat.MEDIUM;
}
if("long".equals(token)) {
return DateFormat.LONG;
}
if("full".equals(token)) {
return DateFormat.FULL;
}
return -1;
}
/**
* Returns the {@link DateUtil.DateToISO8601CalendarFactory} used by the
* the "iso_" built-ins. Be careful when using this; it should only by used
* with {@link DateUtil#dateToISO8601String(Date, boolean, boolean, boolean,
* int, TimeZone, DateToISO8601CalendarFactory)}.
*/
DateToISO8601CalendarFactory getISOBuiltInCalendar() {
if (isoBuiltInCalendarFactory == null) {
isoBuiltInCalendarFactory = new DateUtil.TrivialDateToISO8601CalendarFactory();
}
return isoBuiltInCalendarFactory;
}
/**
* Returns the {@link NumberFormat} used for the c built-in.
* This is always US English "0.################"
, without
* grouping and without superfluous decimal separator.
*/
public NumberFormat getCNumberFormat() {
// It can't be cached in a static field, because DecimalFormat-s aren't
// thread-safe.
if (cNumberFormat == null) {
cNumberFormat = (DecimalFormat) C_NUMBER_FORMAT.clone();
}
return cNumberFormat;
}
TemplateTransformModel getTransform(Expression exp) throws TemplateException {
TemplateTransformModel ttm = null;
TemplateModel tm = exp.getAsTemplateModel(this);
if (tm instanceof TemplateTransformModel) {
ttm = (TemplateTransformModel) tm;
}
else if (exp instanceof Identifier) {
tm = getConfiguration().getSharedVariable(exp.toString());
if (tm instanceof TemplateTransformModel) {
ttm = (TemplateTransformModel) tm;
}
}
return ttm;
}
/**
* Returns the loop or macro local variable corresponding to this
* variable name. Possibly null.
* (Note that the misnomer is kept for backward compatibility: loop variables
* are not local variables according to our terminology.)
*/
public TemplateModel getLocalVariable(String name) throws TemplateModelException {
if (localContextStack != null) {
for (int i = localContextStack.size()-1; i>=0; i--) {
LocalContext lc = (LocalContext) localContextStack.get(i);
TemplateModel tm = lc.getLocalVariable(name);
if (tm != null) {
return tm;
}
}
}
return currentMacroContext == null ? null : currentMacroContext.getLocalVariable(name);
}
/**
* Returns the variable that is visible in this context.
* This is the correspondent to an FTL top-level variable reading expression.
* That is, it tries to find the the variable in this order:
*
* - An loop variable (if we're in a loop or user defined directive body) such as foo_has_next
*
- A local variable (if we're in a macro)
*
- A variable defined in the current namespace (say, via <#assign ...>)
*
- A variable defined globally (say, via <#global ....>)
*
- Variable in the data model:
*
* - A variable in the root hash that was exposed to this
rendering environment in the Template.process(...) call
*
- A shared variable set in the configuration via a call to Configuration.setSharedVariable(...)
*
*
*
*/
public TemplateModel getVariable(String name) throws TemplateModelException {
TemplateModel result = getLocalVariable(name);
if (result == null) {
result = currentNamespace.get(name);
}
if (result == null) {
result = getGlobalVariable(name);
}
return result;
}
/**
* Returns the globally visible variable of the given name (or null).
* This is correspondent to FTL .globals.name
.
* This will first look at variables that were assigned globally via:
* <#global ...> and then at the data model exposed to the template.
*/
public TemplateModel getGlobalVariable(String name) throws TemplateModelException {
TemplateModel result = globalNamespace.get(name);
if (result == null) {
result = rootDataModel.get(name);
}
if (result == null) {
result = getConfiguration().getSharedVariable(name);
}
return result;
}
/**
* Sets a variable that is visible globally.
* This is correspondent to FTL <#global name=model>
.
* This can be considered a convenient shorthand for:
* getGlobalNamespace().put(name, model)
*/
public void setGlobalVariable(String name, TemplateModel model) {
globalNamespace.put(name, model);
}
/**
* Sets a variable in the current namespace.
* This is correspondent to FTL <#assign name=model>
.
* This can be considered a convenient shorthand for:
* getCurrentNamespace().put(name, model)
*/
public void setVariable(String name, TemplateModel model) {
currentNamespace.put(name, model);
}
/**
* Sets a local variable (one effective only during a macro invocation).
* This is correspondent to FTL <#local name=model>
.
* @param name the identifier of the variable
* @param model the value of the variable.
* @throws IllegalStateException if the environment is not executing a
* macro body.
*/
public void setLocalVariable(String name, TemplateModel model) {
if(currentMacroContext == null) {
throw new IllegalStateException("Not executing macro body");
}
currentMacroContext.setLocalVar(name, model);
}
/**
* Returns a set of variable names that are known at the time of call. This
* includes names of all shared variables in the {@link Configuration},
* names of all global variables that were assigned during the template processing,
* names of all variables in the current name-space, names of all local variables
* and loop variables. If the passed root data model implements the
* {@link TemplateHashModelEx} interface, then all names it retrieves through a call to
* {@link TemplateHashModelEx#keys()} method are returned as well.
* The method returns a new Set object on each call that is completely
* disconnected from the Environment. That is, modifying the set will have
* no effect on the Environment object.
*/
public Set getKnownVariableNames() throws TemplateModelException {
// shared vars.
Set set = getConfiguration().getSharedVariableNames();
// root hash
if (rootDataModel instanceof TemplateHashModelEx) {
TemplateModelIterator rootNames =
((TemplateHashModelEx) rootDataModel).keys().iterator();
while(rootNames.hasNext()) {
set.add(((TemplateScalarModel)rootNames.next()).getAsString());
}
}
// globals
for (TemplateModelIterator tmi = globalNamespace.keys().iterator(); tmi.hasNext();) {
set.add(((TemplateScalarModel) tmi.next()).getAsString());
}
// current name-space
for (TemplateModelIterator tmi = currentNamespace.keys().iterator(); tmi.hasNext();) {
set.add(((TemplateScalarModel) tmi.next()).getAsString());
}
// locals and loop vars
if(currentMacroContext != null) {
set.addAll(currentMacroContext.getLocalVariableNames());
}
if (localContextStack != null) {
for (int i = localContextStack.size()-1; i>=0; i--) {
LocalContext lc = (LocalContext) localContextStack.get(i);
set.addAll(lc.getLocalVariableNames());
}
}
return set;
}
/**
* Outputs the instruction stack. Useful for debugging.
* {@link TemplateException}s incorporate this information in their stack
* traces.
*/
public void outputInstructionStack(PrintWriter pw) {
pw.println("----------");
ListIterator iter = elementStack.listIterator(elementStack.size());
if(iter.hasPrevious()) {
pw.print("==> ");
TemplateElement prev = (TemplateElement) iter.previous();
pw.print(prev.getDescription());
pw.print(" [");
pw.print(prev.getStartLocation());
pw.println("]");
}
while(iter.hasPrevious()) {
TemplateElement prev = (TemplateElement) iter.previous();
if (prev instanceof UnifiedCall || prev instanceof Include) {
String location = prev.getDescription() + " [" + prev.getStartLocation() + "]";
if(location != null && location.length() > 0) {
pw.print(" in ");
pw.println(location);
}
}
}
pw.println("----------");
pw.flush();
}
private void pushLocalContext(LocalContext localContext) {
if (localContextStack == null) {
localContextStack = new ArrayList();
}
localContextStack.add(localContext);
}
private void popLocalContext() {
localContextStack.remove(localContextStack.size() - 1);
}
ArrayList getLocalContextStack() {
return localContextStack;
}
/**
* Returns the name-space for the name if exists, or null.
* @param name the template path that you have used with the import
directive
* or {@link #importLib(String, String)} call, in normalized form. That is, the path must be an absolute
* path, and it must not contain "/../" or "/./". The leading "/" is optional.
*/
public Namespace getNamespace(String name) {
if (name.startsWith("/")) name = name.substring(1);
if (loadedLibs != null) {
return (Namespace) loadedLibs.get(name);
} else {
return null;
}
}
/**
* Returns the main name-space.
* This is correspondent of FTL .main
hash.
*/
public Namespace getMainNamespace() {
return mainNamespace;
}
/**
* Returns the main name-space.
* This is correspondent of FTL .namespace
hash.
*/
public Namespace getCurrentNamespace() {
return currentNamespace;
}
/**
* Returns a fictitious name-space that contains the globally visible variables
* that were created in the template, but not the variables of the data-model.
* There is no such thing in FTL; this strange method was added because of the
* JSP taglib support, since this imaginary name-space contains the page-scope
* attributes.
*/
public Namespace getGlobalNamespace() {
return globalNamespace;
}
public TemplateHashModel getDataModel() {
final TemplateHashModel result = new TemplateHashModel() {
public boolean isEmpty() {
return false;
}
public TemplateModel get(String key) throws TemplateModelException {
TemplateModel value = rootDataModel.get(key);
if (value == null) {
value = getConfiguration().getSharedVariable(key);
}
return value;
}
};
if (rootDataModel instanceof TemplateHashModelEx) {
return new TemplateHashModelEx() {
public boolean isEmpty() throws TemplateModelException {
return result.isEmpty();
}
public TemplateModel get(String key) throws TemplateModelException {
return result.get(key);
}
//NB: The methods below do not take into account
// configuration shared variables even though
// the hash will return them, if only for BWC reasons
public TemplateCollectionModel values() throws TemplateModelException {
return ((TemplateHashModelEx) rootDataModel).values();
}
public TemplateCollectionModel keys() throws TemplateModelException {
return ((TemplateHashModelEx) rootDataModel).keys();
}
public int size() throws TemplateModelException {
return ((TemplateHashModelEx) rootDataModel).size();
}
};
}
return result;
}
/**
* Returns the read-only hash of globally visible variables.
* This is the correspondent of FTL .globals
hash.
* That is, you see the variables created with
* <#global ...>
, and the variables of the data-model.
* To create new global variables, use {@link #setGlobalVariable setGlobalVariable}.
*/
public TemplateHashModel getGlobalVariables() {
return new TemplateHashModel() {
public boolean isEmpty() {
return false;
}
public TemplateModel get(String key) throws TemplateModelException {
TemplateModel result = globalNamespace.get(key);
if (result == null) {
result = rootDataModel.get(key);
}
if (result == null) {
result = getConfiguration().getSharedVariable(key);
}
return result;
}
};
}
private void pushElement(TemplateElement element) {
elementStack.add(element);
}
private void popElement() {
elementStack.remove(elementStack.size() - 1);
}
public TemplateNodeModel getCurrentVisitorNode() {
return currentVisitorNode;
}
/**
* sets TemplateNodeModel as the current visitor node. .current_node
*/
public void setCurrentVisitorNode(TemplateNodeModel node) {
currentVisitorNode = node;
}
TemplateModel getNodeProcessor(TemplateNodeModel node) throws TemplateException {
String nodeName = node.getNodeName();
if (nodeName == null) {
throw new TemplateException("Node name is null.", this);
}
TemplateModel result = getNodeProcessor(nodeName, node.getNodeNamespace(), 0);
if (result == null) {
String type = node.getNodeType();
/* DD: Original version: */
if (type == null) {
type = "default";
}
result = getNodeProcessor("@" + type, null, 0);
/* DD: Jonathan's non-BC version and IMHO otherwise wrong version:
if (type != null) {
result = getNodeProcessor("@" + type, null, 0);
}
if (result == null) {
result = getNodeProcessor("@default", null, 0);
}
*/
}
return result;
}
private TemplateModel getNodeProcessor(final String nodeName, final String nsURI, int startIndex)
throws TemplateException
{
TemplateModel result = null;
int i;
for (i = startIndex; i0) {
result = ns.get(prefix + ":" + localName);
if (!(result instanceof Macro) && !(result instanceof TemplateTransformModel)) {
result = null;
}
} else {
if (nsURI.length() == 0) {
result = ns.get(Template.NO_NS_PREFIX + ":" + localName);
if (!(result instanceof Macro) && !(result instanceof TemplateTransformModel)) {
result = null;
}
}
if (nsURI.equals(template.getDefaultNS())) {
result = ns.get(Template.DEFAULT_NAMESPACE_PREFIX + ":" + localName);
if (!(result instanceof Macro) && !(result instanceof TemplateTransformModel)) {
result = null;
}
}
if (result == null) {
result = ns.get(localName);
if (!(result instanceof Macro) && !(result instanceof TemplateTransformModel)) {
result = null;
}
}
}
}
return result;
}
/**
* Emulates include
directive, except that name
must be tempate
* root relative.
*
* It's the same as include(getTemplateForInclusion(name, encoding, parse))
.
* But, you may want to separately call these two methods, so you can determine the source of
* exceptions more precisely, and thus achieve more intelligent error handling.
*
* @see #getTemplateForInclusion(String name, String encoding, boolean parse)
* @see #include(Template includedTemplate)
*/
public void include(String name, String encoding, boolean parse)
throws IOException, TemplateException
{
include(getTemplateForInclusion(name, encoding, parse));
}
/**
* Gets a template for inclusion; used with {@link #include(Template includedTemplate)}.
* The advantage over simply using config.getTemplate(...)
is that it chooses
* the default encoding as the include
directive does.
*
* @param name the name of the template, relatively to the template root directory
* (not the to the directory of the currently executing template file!).
* (Note that you can use {@link freemarker.cache.TemplateCache#getFullTemplatePath}
* to convert paths to template root relative paths.)
* @param encoding the encoding of the obtained template. If null,
* the encoding of the Template that is currently being processed in this
* Environment is used.
* @param parse whether to process a parsed template or just include the
* unparsed template source.
*/
public Template getTemplateForInclusion(String name, String encoding, boolean parse)
throws IOException
{
if (encoding == null) {
encoding = getTemplate().getEncoding();
}
if (encoding == null) {
encoding = getConfiguration().getEncoding(this.getLocale());
}
return getConfiguration().getTemplate(name, getLocale(), encoding, parse);
}
/**
* Processes a Template in the context of this Environment
, including its
* output in the Environment
's Writer.
*
* @param includedTemplate the template to process. Note that it does not need
* to be a template returned by
* {@link #getTemplateForInclusion(String name, String encoding, boolean parse)}.
*/
public void include(Template includedTemplate)
throws TemplateException, IOException
{
Template prevTemplate = getTemplate();
setParent(includedTemplate);
importMacros(includedTemplate);
try {
visit(includedTemplate.getRootTreeNode());
}
finally {
setParent(prevTemplate);
}
}
/**
* Emulates import
directive, except that name
must be tempate
* root relative.
*
*
It's the same as importLib(getTemplateForImporting(name), namespace)
.
* But, you may want to separately call these two methods, so you can determine the source of
* exceptions more precisely, and thus achieve more intelligent error handling.
*
* @see #getTemplateForImporting(String name)
* @see #importLib(Template includedTemplate, String namespace)
*/
public Namespace importLib(String name, String namespace)
throws IOException, TemplateException
{
return importLib(getTemplateForImporting(name), namespace);
}
/**
* Gets a template for importing; used with
* {@link #importLib(Template importedTemplate, String namespace)}. The advantage
* over simply using config.getTemplate(...)
is that it chooses the encoding
* as the import
directive does.
*
* @param name the name of the template, relatively to the template root directory
* (not the to the directory of the currently executing template file!).
* (Note that you can use {@link freemarker.cache.TemplateCache#getFullTemplatePath}
* to convert paths to template root relative paths.)
*/
public Template getTemplateForImporting(String name) throws IOException {
return getTemplateForInclusion(name, null, true);
}
/**
* Emulates import
directive.
*
* @param loadedTemplate the template to import. Note that it does not need
* to be a template returned by {@link #getTemplateForImporting(String name)}.
*/
public Namespace importLib(Template loadedTemplate, String namespace)
throws IOException, TemplateException
{
if (loadedLibs == null) {
loadedLibs = new HashMap();
}
String templateName = loadedTemplate.getName();
Namespace existingNamespace = (Namespace) loadedLibs.get(templateName);
if (existingNamespace != null) {
if (namespace != null) {
setVariable(namespace, existingNamespace);
}
}
else {
Namespace newNamespace = new Namespace(loadedTemplate);
if (namespace != null) {
currentNamespace.put(namespace, newNamespace);
if (currentNamespace == mainNamespace) {
globalNamespace.put(namespace, newNamespace);
}
}
Namespace prevNamespace = this.currentNamespace;
this.currentNamespace = newNamespace;
loadedLibs.put(templateName, currentNamespace);
Writer prevOut = out;
this.out = NULL_WRITER;
try {
include(loadedTemplate);
} finally {
this.out = prevOut;
this.currentNamespace = prevNamespace;
}
}
return (Namespace) loadedLibs.get(templateName);
}
String renderElementToString(TemplateElement te) throws IOException, TemplateException {
Writer prevOut = out;
try {
StringWriter sw = new StringWriter();
this.out = sw;
visit(te);
return sw.toString();
}
finally {
this.out = prevOut;
}
}
void importMacros(Template template) {
for (Iterator it = template.getMacros().values().iterator(); it.hasNext();) {
visitMacroDef((Macro) it.next());
}
}
/**
* @return the namespace URI registered for this prefix, or null.
* This is based on the mappings registered in the current namespace.
*/
public String getNamespaceForPrefix(String prefix) {
return currentNamespace.getTemplate().getNamespaceForPrefix(prefix);
}
public String getPrefixForNamespace(String nsURI) {
return currentNamespace.getTemplate().getPrefixForNamespace(nsURI);
}
/**
* @return the default node namespace for the current FTL namespace
*/
public String getDefaultNS() {
return currentNamespace.getTemplate().getDefaultNS();
}
/**
* A hook that Jython uses.
*/
public Object __getitem__(String key) throws TemplateModelException {
return BeansWrapper.getDefaultInstance().unwrap(getVariable(key));
}
/**
* A hook that Jython uses.
*/
public void __setitem__(String key, Object o) throws TemplateException {
setGlobalVariable(key, getObjectWrapper().wrap(o));
}
private static final class NumberFormatKey
{
private final String pattern;
private final Locale locale;
NumberFormatKey(String pattern, Locale locale)
{
this.pattern = pattern;
this.locale = locale;
}
public boolean equals(Object o)
{
if(o instanceof NumberFormatKey)
{
NumberFormatKey fk = (NumberFormatKey)o;
return fk.pattern.equals(pattern) && fk.locale.equals(locale);
}
return false;
}
public int hashCode()
{
return pattern.hashCode() ^ locale.hashCode();
}
}
private static final class DateFormatKey
{
private final int dateType;
private final String pattern;
private final Locale locale;
private final TimeZone timeZone;
DateFormatKey(int dateType, String pattern, Locale locale, TimeZone timeZone)
{
this.dateType = dateType;
this.pattern = pattern;
this.locale = locale;
this.timeZone = timeZone;
}
public boolean equals(Object o)
{
if(o instanceof DateFormatKey)
{
DateFormatKey fk = (DateFormatKey)o;
return dateType == fk.dateType && fk.pattern.equals(pattern) && fk.locale.equals(locale) && fk.timeZone.equals(timeZone);
}
return false;
}
public int hashCode()
{
return dateType ^ pattern.hashCode() ^ locale.hashCode() ^ timeZone.hashCode();
}
}
public class Namespace extends SimpleHash {
private Template template;
Namespace() {
this.template = Environment.this.getTemplate();
}
Namespace(Template template) {
this.template = template;
}
/**
* @return the Template object with which this Namespace is associated.
*/
public Template getTemplate() {
return template == null ? Environment.this.getTemplate() : template;
}
}
static final Writer NULL_WRITER = new Writer() {
public void write(char cbuf[], int off, int len) {}
public void flush() {}
public void close() {}
};
private static final Writer EMPTY_BODY_WRITER = new Writer() {
public void write(char[] cbuf, int off, int len) throws IOException {
if (len > 0) {
throw new IOException(
"This transform does not allow nested content.");
}
}
public void flush() {
}
public void close() {
}
};
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/HashLiteral.java 0000644 0001750 0001750 00000013752 11723544470 024552 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
import java.util.*;
final class HashLiteral extends Expression {
private final ArrayList keys, values;
private final int size;
HashLiteral(ArrayList keys, ArrayList values) {
this.keys = keys;
this.values = values;
this.size = keys.size();
keys.trimToSize();
values.trimToSize();
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
return new SequenceHash(env);
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer("{");
for (int i = 0; i < size; i++) {
Expression key = (Expression) keys.get(i);
Expression value = (Expression) values.get(i);
buf.append(key.getCanonicalForm());
buf.append(" : ");
buf.append(value.getCanonicalForm());
if (i != size-1) {
buf.append(",");
}
}
buf.append("}");
return buf.toString();
}
boolean isLiteral() {
if (constantValue != null) {
return true;
}
for (int i = 0; i < size; i++) {
Expression key = (Expression) keys.get(i);
Expression value = (Expression) values.get(i);
if (!key.isLiteral() || !value.isLiteral()) {
return false;
}
}
return true;
}
Expression _deepClone(String name, Expression subst) {
ArrayList clonedKeys = (ArrayList)keys.clone();
for (ListIterator iter = clonedKeys.listIterator(); iter.hasNext();) {
iter.set(((Expression)iter.next()).deepClone(name, subst));
}
ArrayList clonedValues = (ArrayList)values.clone();
for (ListIterator iter = clonedValues.listIterator(); iter.hasNext();) {
iter.set(((Expression)iter.next()).deepClone(name, subst));
}
return new HashLiteral(clonedKeys, clonedValues);
}
private class SequenceHash implements TemplateHashModelEx {
private HashMap keyMap; // maps keys to integer offset
private TemplateCollectionModel keyCollection, valueCollection; // ordered lists of keys and values
SequenceHash(Environment env) throws TemplateException {
keyMap = new HashMap();
ArrayList keyList = new ArrayList(size);
ArrayList valueList = new ArrayList(size);
for (int i = 0; i< size; i++) {
Expression keyExp = (Expression) keys.get(i);
Expression valExp = (Expression) values.get(i);
String key = keyExp.getStringValue(env);
TemplateModel value = valExp.getAsTemplateModel(env);
assertNonNull(value, valExp, env);
keyMap.put(key, value);
keyList.add(key);
valueList.add(value);
}
keyCollection = new CollectionAndSequence(new SimpleSequence(keyList));
valueCollection = new CollectionAndSequence(new SimpleSequence(valueList));
}
public int size() {
return size;
}
public TemplateCollectionModel keys() {
return keyCollection;
}
public TemplateCollectionModel values() {
return valueCollection;
}
public TemplateModel get(String key) {
return (TemplateModel) keyMap.get(key);
}
public boolean isEmpty() {
return size == 0;
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/SwitchBlock.java 0000644 0001750 0001750 00000011754 11723544471 024567 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.util.*;
import java.io.IOException;
import freemarker.template.*;
/**
* An instruction representing a switch-case structure.
*/
final class SwitchBlock extends TemplateElement {
private Case defaultCase;
private Expression testExpression;
/**
* @param testExpression the expression to be tested.
*/
SwitchBlock(Expression testExpression) {
this.testExpression = testExpression;
nestedElements = new LinkedList();
}
/**
* @param cas a Case element.
*/
void addCase(Case cas) {
if (cas.isDefault) {
defaultCase = cas;
}
nestedElements.add(cas);
}
void accept(Environment env)
throws TemplateException, IOException
{
boolean processedCase = false;
Iterator iterator = nestedElements.iterator();
try {
while (iterator.hasNext()) {
Case cas = (Case)iterator.next();
boolean processCase = false;
// Fall through if a previous case tested true.
if (processedCase) {
processCase = true;
} else if (!cas.isDefault) {
// Otherwise, if this case isn't the default, test it.
ComparisonExpression equalsOp = new ComparisonExpression(testExpression, cas.expression, "==");
processCase = equalsOp.isTrue(env);
}
if (processCase) {
env.visit(cas);
processedCase = true;
}
}
// If we didn't process any nestedElements, and we have a default,
// process it.
if (!processedCase && defaultCase != null) {
env.visit(defaultCase);
}
}
catch (BreakInstruction.Break br) {}
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer("<#switch ");
buf.append(testExpression.getCanonicalForm());
buf.append(">");
for (int i = 0; i");
return buf.toString();
}
public String getDescription() {
return "switch " + testExpression;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/AttemptBlock.java 0000644 0001750 0001750 00000007152 11723544470 024740 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import java.util.ArrayList;
import freemarker.template.*;
final class AttemptBlock extends TemplateElement {
private TemplateElement attemptBlock, recoveryBlock;
AttemptBlock(TemplateElement attemptBlock, TemplateElement recoveryBlock) {
this.attemptBlock = attemptBlock;
this.recoveryBlock = recoveryBlock;
nestedElements = new ArrayList();
nestedElements.add(attemptBlock);
nestedElements.add(recoveryBlock);
}
void accept(Environment env) throws TemplateException, IOException
{
env.visit(attemptBlock, recoveryBlock);
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer("<#attempt>");
if (attemptBlock != null) {
buf.append(attemptBlock.getCanonicalForm());
}
if (recoveryBlock != null) {
buf.append(recoveryBlock.getCanonicalForm());
}
return buf.toString();
}
public String getDescription() {
return "attempt block";
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/ExistsExpression.java 0000644 0001750 0001750 00000006622 11723544471 025710 0 ustar ebourg ebourg /*
* Copyright (c) 2006 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
class ExistsExpression extends Expression {
private Expression exp;
ExistsExpression(Expression exp) {
this.exp = exp;
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
TemplateModel tm = null;
try {
tm = exp.getAsTemplateModel(env);
} catch (InvalidReferenceException ire) {
if (!(exp instanceof ParentheticalExpression)) {
throw ire;
}
}
return tm == null ? TemplateBooleanModel.FALSE : TemplateBooleanModel.TRUE;
}
boolean isLiteral() {
return false;
}
Expression _deepClone(String name, Expression subst) {
return new ExistsExpression(exp.deepClone(name, subst));
}
public String getCanonicalForm() {
return exp.getCanonicalForm() + "??";
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/TemplateElement.java 0000644 0001750 0001750 00000030044 11723544470 025430 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.util.*;
import java.io.IOException;
import javax.swing.tree.TreeNode;
import freemarker.template.*;
import freemarker.template.utility.Collections12;
/**
* Objects that represent elements in the compiled
* tree representation of the template necessarily
* descend from this abstract class.
*/
abstract public class TemplateElement extends TemplateObject implements TreeNode {
TemplateElement parent;
// Only one of nestedBlock and nestedElements can be non-null.
TemplateElement nestedBlock;
List nestedElements;
/**
* Processes the contents of this TemplateElement and
* outputs the resulting text
*
* @param env The runtime environment
*/
abstract void accept(Environment env) throws TemplateException, IOException;
abstract public String getDescription();
// Methods to implement TemplateNodeModel
public TemplateNodeModel getParentNode() {
// return parent;
return null;
}
public String getNodeNamespace() {
return null;
}
public String getNodeType() {
return "element";
}
public TemplateSequenceModel getChildNodes() {
if (nestedElements != null) {
return new SimpleSequence(nestedElements);
}
SimpleSequence result = new SimpleSequence();
if (nestedBlock != null) {
result.add(nestedBlock);
}
return result;
}
public String getNodeName() {
String classname = this.getClass().getName();
int shortNameOffset = classname.lastIndexOf('.')+1;
return classname.substring(shortNameOffset);
}
// Methods so that we can implement the Swing TreeNode API.
public boolean isLeaf() {
return nestedBlock == null
&& (nestedElements == null || nestedElements.isEmpty());
}
public boolean getAllowsChildren() {
return !isLeaf();
}
public int getIndex(TreeNode node) {
if (nestedBlock instanceof MixedContent) {
return nestedBlock.getIndex(node);
}
if (nestedBlock != null) {
if (node == nestedBlock) {
return 0;
}
}
else if (nestedElements != null) {
return nestedElements.indexOf(node);
}
return -1;
}
public int getChildCount() {
if (nestedBlock instanceof MixedContent) {
return nestedBlock.getChildCount();
}
if (nestedBlock != null) {
return 1;
}
else if (nestedElements != null) {
return nestedElements.size();
}
return 0;
}
public Enumeration children() {
if (nestedBlock instanceof MixedContent) {
return nestedBlock.children();
}
if (nestedBlock != null) {
return Collections.enumeration(Collections12.singletonList(nestedBlock));
}
else if (nestedElements != null) {
return Collections.enumeration(nestedElements);
}
return Collections.enumeration(Collections.EMPTY_LIST);
}
public TreeNode getChildAt(int index) {
if (nestedBlock instanceof MixedContent) {
return nestedBlock.getChildAt(index);
}
if (nestedBlock != null) {
if (index == 0) {
return nestedBlock;
}
throw new ArrayIndexOutOfBoundsException("invalid index");
}
else if (nestedElements != null) {
return(TreeNode) nestedElements.get(index);
}
throw new ArrayIndexOutOfBoundsException("element has no children");
}
public void setChildAt(int index, TemplateElement element) {
if(nestedBlock instanceof MixedContent) {
nestedBlock.setChildAt(index, element);
}
else if(nestedBlock != null) {
if(index == 0) {
nestedBlock = element;
element.parent = this;
}
else {
throw new IndexOutOfBoundsException("invalid index");
}
}
else if(nestedElements != null) {
nestedElements.set(index, element);
element.parent = this;
}
else {
throw new IndexOutOfBoundsException("element has no children");
}
}
public TreeNode getParent() {
return parent;
}
// Walk the tree and set the parent field in all the nested elements recursively.
void setParentRecursively(TemplateElement parent) {
this.parent = parent;
int nestedSize = nestedElements == null ? 0 : nestedElements.size();
for (int i = 0; i < nestedSize; i++) {
((TemplateElement) nestedElements.get(i)).setParentRecursively(this);
}
if (nestedBlock != null) {
nestedBlock.setParentRecursively(this);
}
}
/**
* We walk the tree and do some cleanup
* @param stripWhitespace whether to clean up superfluous whitespace
*/
TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException {
if (nestedElements != null) {
for (int i = 0; i < nestedElements.size(); i++) {
TemplateElement te = (TemplateElement) nestedElements.get(i);
te = te.postParseCleanup(stripWhitespace);
nestedElements.set(i, te);
te.parent = this;
}
if (stripWhitespace) {
for (Iterator it = nestedElements.iterator(); it.hasNext();) {
TemplateElement te = (TemplateElement) it.next();
if (te.isIgnorable()) {
it.remove();
}
}
}
if (nestedElements instanceof ArrayList) {
((ArrayList) nestedElements).trimToSize();
}
}
if (nestedBlock != null) {
nestedBlock = nestedBlock.postParseCleanup(stripWhitespace);
if (nestedBlock.isIgnorable()) {
nestedBlock = null;
} else {
nestedBlock.parent = this;
}
}
return this;
}
boolean isIgnorable() {
return false;
}
// The following methods exist to support some fancier tree-walking
// and were introduced to support the whitespace cleanup feature in 2.2
TemplateElement prevTerminalNode() {
TemplateElement prev = previousSibling();
if (prev != null) {
return prev.getLastLeaf();
}
else if (parent != null) {
return parent.prevTerminalNode();
}
return null;
}
TemplateElement nextTerminalNode() {
TemplateElement next = nextSibling();
if (next != null) {
return next.getFirstLeaf();
}
else if (parent != null) {
return parent.nextTerminalNode();
}
return null;
}
TemplateElement previousSibling() {
if (parent == null) {
return null;
}
List siblings = parent.nestedElements;
if (siblings == null) {
return null;
}
for (int i = siblings.size() - 1; i>=0; i--) {
if (siblings.get(i) == this) {
return(i >0) ? (TemplateElement) siblings.get(i-1) : null;
}
}
return null;
}
TemplateElement nextSibling() {
if (parent == null) {
return null;
}
List siblings = parent.nestedElements;
if (siblings == null) {
return null;
}
for (int i = 0; i < siblings.size(); i++) {
if (siblings.get(i) == this) {
return (i+1) < siblings.size() ? (TemplateElement) siblings.get(i+1) : null;
}
}
return null;
}
private TemplateElement getFirstChild() {
if (nestedBlock != null) {
return nestedBlock;
}
if (nestedElements != null && nestedElements.size() >0) {
return(TemplateElement) nestedElements.get(0);
}
return null;
}
private TemplateElement getLastChild() {
if (nestedBlock != null) {
return nestedBlock;
}
if (nestedElements != null && nestedElements.size() >0) {
return(TemplateElement) nestedElements.get(nestedElements.size() -1);
}
return null;
}
private TemplateElement getFirstLeaf() {
TemplateElement te = this;
while (!te.isLeaf() && !(te instanceof Macro) && !(te instanceof BlockAssignment)) {
// A macro or macro invocation is treated as a leaf here for special reasons
te = te.getFirstChild();
}
return te;
}
private TemplateElement getLastLeaf() {
TemplateElement te = this;
while (!te.isLeaf() && !(te instanceof Macro) && !(te instanceof BlockAssignment)) {
// A macro or macro invocation is treated as a leaf here for special reasons
te = te.getLastChild();
}
return te;
}
/**
* determines whether this element's presence on a line
* indicates that we should not strip opening whitespace
* in the post-parse whitespace gobbling step.
*/
boolean heedsOpeningWhitespace() {
return false;
}
/**
* determines whether this element's presence on a line
* indicates that we should not strip trailing whitespace
* in the post-parse whitespace gobbling step.
*/
boolean heedsTrailingWhitespace() {
return false;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/OrExpression.java 0000644 0001750 0001750 00000006542 11723544471 025012 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.TemplateException;
final class OrExpression extends BooleanExpression {
private final Expression left;
private final Expression right;
OrExpression(Expression left, Expression right) {
this.left = left;
this.right = right;
}
boolean isTrue(Environment env) throws TemplateException {
return left.isTrue(env) || right.isTrue(env);
}
public String getCanonicalForm() {
return left.getCanonicalForm() + " || " + right.getCanonicalForm();
}
boolean isLiteral() {
return constantValue !=null || (left.isLiteral() && right.isLiteral());
}
Expression _deepClone(String name, Expression subst) {
return new OrExpression(left.deepClone(name, subst), right.deepClone(name, subst));
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/NumericalOutput.java 0000644 0001750 0001750 00000013316 11723544471 025507 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.Locale;
import freemarker.template.*;
/**
* An instruction that outputs the value of a numerical expression.
* @author Jonathan Revusky
*/
final class NumericalOutput extends TemplateElement {
private final Expression expression;
private final boolean hasFormat;
private final int minFracDigits;
private final int maxFracDigits;
private volatile FormatHolder formatCache; // creating new NumberFormat is slow operation
NumericalOutput(Expression expression) {
this.expression = expression;
hasFormat = false;
this.minFracDigits = 0;
this.maxFracDigits = 0;
}
NumericalOutput(Expression expression,
int minFracDigits,
int maxFracDigits)
{
this.expression = expression;
hasFormat = true;
this.minFracDigits = minFracDigits;
this.maxFracDigits = maxFracDigits;
}
void accept(Environment env) throws TemplateException, IOException
{
Number num = EvaluationUtil.getNumber(expression, env);
FormatHolder fmth = formatCache; // atomic sampling
if (fmth == null || !fmth.locale.equals(env.getLocale())) {
synchronized(this) {
fmth = formatCache;
if (fmth == null || !fmth.locale.equals(env.getLocale())) {
NumberFormat fmt = NumberFormat.getNumberInstance(env.getLocale());
if (hasFormat) {
fmt.setMinimumFractionDigits(minFracDigits);
fmt.setMaximumFractionDigits(maxFracDigits);
} else {
fmt.setMinimumFractionDigits(0);
fmt.setMaximumFractionDigits(50);
}
fmt.setGroupingUsed(false);
formatCache = new FormatHolder(fmt, env.getLocale());
fmth = formatCache;
}
}
}
// We must use Format even if hasFormat == false.
// Some locales may use non-Arabic digits, thus replacing the
// decimal separator in the result of toString() is not enough.
env.getOut().write(fmth.format.format(num));
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer("#{");
buf.append(expression.getCanonicalForm());
if (hasFormat) {
buf.append(" ; ");
buf.append("m");
buf.append(minFracDigits);
buf.append("M");
buf.append(maxFracDigits);
}
buf.append("}");
return buf.toString();
}
public String getDescription() {
return getSource();
}
boolean heedsOpeningWhitespace() {
return true;
}
boolean heedsTrailingWhitespace() {
return true;
}
private static class FormatHolder {
final NumberFormat format;
final Locale locale;
FormatHolder(NumberFormat format, Locale locale) {
this.format = format;
this.locale = locale;
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/DefaultToExpression.java 0000644 0001750 0001750 00000010725 11723544471 026317 0 ustar ebourg ebourg /*
* Copyright (c) 2006 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
class DefaultToExpression extends Expression {
private static final TemplateCollectionModel EMPTY_COLLECTION = new SimpleCollection(new java.util.ArrayList(0));
static private class EmptyStringAndSequence
implements TemplateScalarModel, TemplateSequenceModel, TemplateHashModelEx {
public String getAsString() {
return "";
}
public TemplateModel get(int i) {
return null;
}
public TemplateModel get(String s) {
return null;
}
public int size() {
return 0;
}
public boolean isEmpty() {
return true;
}
public TemplateCollectionModel keys() {
return EMPTY_COLLECTION;
}
public TemplateCollectionModel values() {
return EMPTY_COLLECTION;
}
}
static final TemplateModel EMPTY_STRING_AND_SEQUENCE = new EmptyStringAndSequence();
private Expression lhs, rhs;
DefaultToExpression(Expression lhs, Expression rhs) {
this.lhs = lhs;
this.rhs = rhs;
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
TemplateModel left = null;
try {
left = lhs.getAsTemplateModel(env);
} catch (InvalidReferenceException ire) {
if (!(lhs instanceof ParentheticalExpression)) {
throw ire;
}
}
if (left != null) return left;
if (rhs == null) return EMPTY_STRING_AND_SEQUENCE;
return rhs.getAsTemplateModel(env);
}
boolean isLiteral() {
return false;
}
Expression _deepClone(String name, Expression subst) {
if (rhs == null) {
return new DefaultToExpression(lhs.deepClone(name, subst), null);
}
return new DefaultToExpression(lhs.deepClone(name, subst), rhs.deepClone(name, subst));
}
public String getCanonicalForm() {
if (rhs == null) {
return lhs.getCanonicalForm() + "!";
}
return lhs.getCanonicalForm() + "!" + rhs.getCanonicalForm();
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/UnaryPlusMinusExpression.java 0000644 0001750 0001750 00000007674 11723544471 027417 0 ustar ebourg ebourg /*
* Copyright (c) 2005 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
final class UnaryPlusMinusExpression extends Expression {
private final Expression target;
private final boolean isMinus;
private static final Integer MINUS_ONE = new Integer(-1);
UnaryPlusMinusExpression(Expression target, boolean isMinus) {
this.target = target;
this.isMinus = isMinus;
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
TemplateNumberModel targetModel = null;
try {
targetModel = (TemplateNumberModel) target.getAsTemplateModel(env);
} catch (ClassCastException cce) {
String msg = "Error " + getStartLocation();
msg += "\nExpression " + target + " is not numerical.";
throw new NonNumericalException(msg, env);
}
if (!isMinus) {
return targetModel;
}
Number n = targetModel.getAsNumber();
n = ArithmeticEngine.CONSERVATIVE_ENGINE.multiply(MINUS_ONE, n);
return new SimpleNumber(n);
}
public String getCanonicalForm() {
String op = isMinus ? "-" : "+";
return op + target.getCanonicalForm();
}
boolean isLiteral() {
return target.isLiteral();
}
Expression _deepClone(String name, Expression subst) {
return new UnaryPlusMinusExpression(target.deepClone(name, subst), isMinus);
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/StringBuiltins.java 0000644 0001750 0001750 00000021172 11723544471 025326 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
import freemarker.template.utility.StringUtil;
import java.io.StringReader;
import java.util.StringTokenizer;
/**
* A holder for builtins that operate exclusively on strings.
*/
abstract class StringBuiltins {
abstract static class StringBuiltIn extends BuiltIn {
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException
{
return calculateResult(target.getStringValue(env), env);
}
abstract TemplateModel calculateResult(String s, Environment env) throws TemplateException;
}
static class capitalizeBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
return new SimpleScalar(StringUtil.capitalize(s));
}
}
static class chop_linebreakBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
return new SimpleScalar(StringUtil.chomp(s));
}
}
static class j_stringBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
return new SimpleScalar(StringUtil.javaStringEnc(s));
}
}
static class js_stringBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
return new SimpleScalar(StringUtil.javaScriptStringEnc(s));
}
}
static class json_stringBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
return new SimpleScalar(StringUtil.jsonStringEnc(s));
}
}
static class cap_firstBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
int i = 0;
int ln = s.length();
while (i < ln && Character.isWhitespace(s.charAt(i))) {
i++;
}
if (i < ln) {
StringBuffer b = new StringBuffer(s);
b.setCharAt(i, Character.toUpperCase(s.charAt(i)));
s = b.toString();
}
return new SimpleScalar(s);
}
}
static class uncap_firstBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
int i = 0;
int ln = s.length();
while (i < ln && Character.isWhitespace(s.charAt(i))) {
i++;
}
if (i < ln) {
StringBuffer b = new StringBuffer(s);
b.setCharAt(i, Character.toLowerCase(s.charAt(i)));
s = b.toString();
}
return new SimpleScalar(s);
}
}
static class upper_caseBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env)
{
return new SimpleScalar(s.toUpperCase(env.getLocale()));
}
}
static class lower_caseBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env)
{
return new SimpleScalar(s.toLowerCase(env.getLocale()));
}
}
static class word_listBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) {
SimpleSequence result = new SimpleSequence();
StringTokenizer st = new StringTokenizer(s);
while (st.hasMoreTokens()) {
result.add(st.nextToken());
}
return result;
}
}
static class evalBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) throws TemplateException
{
SimpleCharStream scs = new SimpleCharStream(
new StringReader("(" + s + ")"), target.beginLine,
target.beginColumn, s.length() + 2);
FMParserTokenManager token_source = new FMParserTokenManager(scs);
token_source.incompatibleChanges = env.getConfiguration().getParsedIncompatibleEnhancements();
token_source.SwitchTo(FMParserConstants.FM_EXPRESSION);
FMParser parser = new FMParser(token_source);
parser.template = getTemplate();
Expression exp = null;
try {
exp = parser.Expression();
} catch (ParseException pe) {
pe.setTemplateName(getTemplate().getName());
throw new TemplateException(pe, env);
}
return exp.getAsTemplateModel(env);
}
}
static class numberBI extends StringBuiltIn {
TemplateModel calculateResult(String s, Environment env) throws TemplateException
{
try {
return new SimpleNumber(env.getArithmeticEngine().toNumber(s));
}
catch(NumberFormatException nfe) {
String mess = "Error: " + getStartLocation()
+ "\nExpecting a number here, found: " + s;
throw new NonNumericalException(mess, env);
}
}
}
static class substringBI extends StringBuiltIn {
TemplateModel calculateResult(final String s, final Environment env) throws TemplateException {
return new TemplateMethodModelEx() {
public Object exec(java.util.List args) throws TemplateModelException {
int argCount = args.size(), left=0, right=0;
if (argCount != 1 && argCount != 2) {
throw new TemplateModelException("Error: " + getStartLocation() + "\nExpecting 1 or 2 numerical arguments here");
}
try {
TemplateNumberModel tnm = (TemplateNumberModel) args.get(0);
left = tnm.getAsNumber().intValue();
if (argCount == 2) {
tnm = (TemplateNumberModel) args.get(1);
right = tnm.getAsNumber().intValue();
}
} catch (ClassCastException cce) {
String mess = "Error: " + getStartLocation() + "\nExpecting numerical argument here";
throw new TemplateModelException(mess);
}
if (argCount == 1) {
return new SimpleScalar(s.substring(left));
}
return new SimpleScalar(s.substring(left, right));
}
};
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/FreeMarkerTree.java 0000644 0001750 0001750 00000006505 11723544471 025214 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeModel;
abstract public class FreeMarkerTree extends JTree {
public FreeMarkerTree(Template template) {
super(template.getRootTreeNode());
}
public void setTemplate(Template template) {
this.setModel(new DefaultTreeModel(template.getRootTreeNode()));
this.invalidate();
}
public String convertValueToText(Object value, boolean selected,
boolean expanded, boolean leaf, int row,
boolean hasFocus)
{
if (value instanceof TemplateElement) {
return ((TemplateElement) value).getDescription();
}
return value.toString();
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/DollarVariable.java 0000644 0001750 0001750 00000007264 11723544470 025236 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import freemarker.template.TemplateException;
/**
* An instruction that outputs the value of an Expression.
*/
final class DollarVariable extends TemplateElement {
private final Expression expression;
private final Expression escapedExpression;
DollarVariable(Expression expression, Expression escapedExpression) {
this.expression = expression;
this.escapedExpression = escapedExpression;
}
/**
* Outputs the string value of the enclosed expression.
*/
void accept(Environment env) throws TemplateException, IOException {
env.getOut().write(escapedExpression.getStringValue(env));
}
public String getCanonicalForm() {
return "${" + expression.getCanonicalForm() + "}";
}
public String getDescription() {
return this.getSource() +
(expression == escapedExpression
? ""
: " escaped ${" + escapedExpression.getCanonicalForm() + "}");
}
boolean heedsOpeningWhitespace() {
return true;
}
boolean heedsTrailingWhitespace() {
return true;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/ArithmeticEngine.java 0000644 0001750 0001750 00000054072 11723544467 025577 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.math.*;
import java.util.HashMap;
import java.util.Map;
import freemarker.template.*;
import freemarker.template.utility.OptimizerUtil;
/**
* Class to perform arithmetic operations.
* @author Jonathan Revusky
* @author Attila Szegedi
*/
public abstract class ArithmeticEngine {
/**
* Arithmetic engine that converts all numbers to {@link BigDecimal} and
* then operates on them. This is FreeMarker's default arithmetic engine.
*/
public static final BigDecimalEngine BIGDECIMAL_ENGINE = new BigDecimalEngine();
/**
* Arithmetic engine that uses (more-or-less) the widening conversions of
* Java language to determine the type of result of operation, instead of
* converting everything to BigDecimal up front.
*/
public static final ConservativeEngine CONSERVATIVE_ENGINE = new ConservativeEngine();
public abstract int compareNumbers(Number first, Number second) throws TemplateException;
public abstract Number add(Number first, Number second) throws TemplateException;
public abstract Number subtract(Number first, Number second) throws TemplateException;
public abstract Number multiply(Number first, Number second) throws TemplateException;
public abstract Number divide(Number first, Number second) throws TemplateException;
public abstract Number modulus(Number first, Number second) throws TemplateException;
public abstract Number toNumber(String s);
protected int minScale = 12;
protected int maxScale = 12;
protected int roundingPolicy = BigDecimal.ROUND_HALF_UP;
/**
* Sets the minimal scale to use when dividing BigDecimal numbers. Default
* value is 12.
*/
public void setMinScale(int minScale) {
if(minScale < 0) {
throw new IllegalArgumentException("minScale < 0");
}
this.minScale = minScale;
}
/**
* Sets the maximal scale to use when multiplying BigDecimal numbers.
* Default value is 100.
*/
public void setMaxScale(int maxScale) {
if(maxScale < minScale) {
throw new IllegalArgumentException("maxScale < minScale");
}
this.maxScale = maxScale;
}
public void setRoundingPolicy(int roundingPolicy) {
if (roundingPolicy != BigDecimal.ROUND_CEILING
&& roundingPolicy != BigDecimal.ROUND_DOWN
&& roundingPolicy != BigDecimal.ROUND_FLOOR
&& roundingPolicy != BigDecimal.ROUND_HALF_DOWN
&& roundingPolicy != BigDecimal.ROUND_HALF_EVEN
&& roundingPolicy != BigDecimal.ROUND_HALF_UP
&& roundingPolicy != BigDecimal.ROUND_UNNECESSARY
&& roundingPolicy != BigDecimal.ROUND_UP)
{
throw new IllegalArgumentException("invalid rounding policy");
}
this.roundingPolicy = roundingPolicy;
}
/**
* This is the default arithmetic engine in FreeMarker. It converts every
* number it receives into {@link BigDecimal}, then operates on these
* converted {@link BigDecimal}s.
*/
public static class BigDecimalEngine
extends
ArithmeticEngine
{
public int compareNumbers(Number first, Number second) {
BigDecimal left = toBigDecimal(first);
BigDecimal right = toBigDecimal(second);
return left.compareTo(right);
}
public Number add(Number first, Number second) {
BigDecimal left = toBigDecimal(first);
BigDecimal right = toBigDecimal(second);
return left.add(right);
}
public Number subtract(Number first, Number second) {
BigDecimal left = toBigDecimal(first);
BigDecimal right = toBigDecimal(second);
return left.subtract(right);
}
public Number multiply(Number first, Number second) {
BigDecimal left = toBigDecimal(first);
BigDecimal right = toBigDecimal(second);
BigDecimal result = left.multiply(right);
if (result.scale() > maxScale) {
result = result.setScale(maxScale, roundingPolicy);
}
return result;
}
public Number divide(Number first, Number second) {
BigDecimal left = toBigDecimal(first);
BigDecimal right = toBigDecimal(second);
return divide(left, right);
}
public Number modulus(Number first, Number second) {
long left = first.longValue();
long right = second.longValue();
return new Long(left % right);
}
public Number toNumber(String s) {
return new BigDecimal(s);
}
private BigDecimal divide(BigDecimal left, BigDecimal right) {
int scale1 = left.scale();
int scale2 = right.scale();
int scale = Math.max(scale1, scale2);
scale = Math.max(minScale, scale);
return left.divide(right, scale, roundingPolicy);
}
}
/**
* An arithmetic engine that conservatively widens the operation arguments
* to extent that they can hold the result of the operation. Widening
* conversions occur in following situations:
*
* - byte and short are always widened to int (alike to Java language).
* - To preserve magnitude: when operands are of different types, the
* result type is the type of the wider operand.
* - to avoid overflows: if add, subtract, or multiply would overflow on
* integer types, the result is widened from int to long, or from long to
* BigInteger.
* - to preserve fractional part: if a division of integer types would
* have a fractional part, int and long are converted to double, and
* BigInteger is converted to BigDecimal. An operation on a float and a
* long results in a double. An operation on a float or double and a
* BigInteger results in a BigDecimal.
*
*/
public static class ConservativeEngine extends ArithmeticEngine {
private static final int INTEGER = 0;
private static final int LONG = 1;
private static final int FLOAT = 2;
private static final int DOUBLE = 3;
private static final int BIGINTEGER = 4;
private static final int BIGDECIMAL = 5;
private static final Map classCodes = createClassCodesMap();
public int compareNumbers(Number first, Number second) throws TemplateException {
switch(getCommonClassCode(first, second)) {
case INTEGER: {
int n1 = first.intValue();
int n2 = second.intValue();
return n1 < n2 ? -1 : (n1 == n2 ? 0 : 1);
}
case LONG: {
long n1 = first.longValue();
long n2 = second.longValue();
return n1 < n2 ? -1 : (n1 == n2 ? 0 : 1);
}
case FLOAT: {
float n1 = first.floatValue();
float n2 = second.floatValue();
return n1 < n2 ? -1 : (n1 == n2 ? 0 : 1);
}
case DOUBLE: {
double n1 = first.doubleValue();
double n2 = second.doubleValue();
return n1 < n2 ? -1 : (n1 == n2 ? 0 : 1);
}
case BIGINTEGER: {
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
return n1.compareTo(n2);
}
case BIGDECIMAL: {
BigDecimal n1 = toBigDecimal(first);
BigDecimal n2 = toBigDecimal(second);
return n1.compareTo(n2);
}
}
// Make the compiler happy. getCommonClassCode() is guaranteed to
// return only above codes, or throw an exception.
throw new Error();
}
public Number add(Number first, Number second) throws TemplateException {
switch(getCommonClassCode(first, second)) {
case INTEGER: {
int n1 = first.intValue();
int n2 = second.intValue();
int n = n1 + n2;
return
((n ^ n1) < 0 && (n ^ n2) < 0) // overflow check
? (Number)new Long(((long)n1) + n2)
: (Number)new Integer(n);
}
case LONG: {
long n1 = first.longValue();
long n2 = second.longValue();
long n = n1 + n2;
return
((n ^ n1) < 0 && (n ^ n2) < 0) // overflow check
? (Number)toBigInteger(first).add(toBigInteger(second))
: (Number)new Long(n);
}
case FLOAT: {
return new Float(first.floatValue() + second.floatValue());
}
case DOUBLE: {
return new Double(first.doubleValue() + second.doubleValue());
}
case BIGINTEGER: {
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
return n1.add(n2);
}
case BIGDECIMAL: {
BigDecimal n1 = toBigDecimal(first);
BigDecimal n2 = toBigDecimal(second);
return n1.add(n2);
}
}
// Make the compiler happy. getCommonClassCode() is guaranteed to
// return only above codes, or throw an exception.
throw new Error();
}
public Number subtract(Number first, Number second) throws TemplateException {
switch(getCommonClassCode(first, second)) {
case INTEGER: {
int n1 = first.intValue();
int n2 = second.intValue();
int n = n1 - n2;
return
((n ^ n1) < 0 && (n ^ ~n2) < 0) // overflow check
? (Number)new Long(((long)n1) - n2)
: (Number)new Integer(n);
}
case LONG: {
long n1 = first.longValue();
long n2 = second.longValue();
long n = n1 - n2;
return
((n ^ n1) < 0 && (n ^ ~n2) < 0) // overflow check
? (Number)toBigInteger(first).subtract(toBigInteger(second))
: (Number)new Long(n);
}
case FLOAT: {
return new Float(first.floatValue() - second.floatValue());
}
case DOUBLE: {
return new Double(first.doubleValue() - second.doubleValue());
}
case BIGINTEGER: {
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
return n1.subtract(n2);
}
case BIGDECIMAL: {
BigDecimal n1 = toBigDecimal(first);
BigDecimal n2 = toBigDecimal(second);
return n1.subtract(n2);
}
}
// Make the compiler happy. getCommonClassCode() is guaranteed to
// return only above codes, or throw an exception.
throw new Error();
}
public Number multiply(Number first, Number second) throws TemplateException {
switch(getCommonClassCode(first, second)) {
case INTEGER: {
int n1 = first.intValue();
int n2 = second.intValue();
int n = n1 * n2;
return
n1== 0 || n/n1 == n2 // overflow check
? (Number)new Integer(n)
: (Number)new Long(((long)n1) * n2);
}
case LONG: {
long n1 = first.longValue();
long n2 = second.longValue();
long n = n1 * n2;
return
n1==0L || n / n1 == n2 // overflow check
? (Number)new Long(n)
: (Number)toBigInteger(first).multiply(toBigInteger(second));
}
case FLOAT: {
return new Float(first.floatValue() * second.floatValue());
}
case DOUBLE: {
return new Double(first.doubleValue() * second.doubleValue());
}
case BIGINTEGER: {
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
return n1.multiply(n2);
}
case BIGDECIMAL: {
BigDecimal n1 = toBigDecimal(first);
BigDecimal n2 = toBigDecimal(second);
BigDecimal r = n1.multiply(n2);
return r.scale() > maxScale ? r.setScale(maxScale, roundingPolicy) : r;
}
}
// Make the compiler happy. getCommonClassCode() is guaranteed to
// return only above codes, or throw an exception.
throw new Error();
}
public Number divide(Number first, Number second) throws TemplateException {
switch(getCommonClassCode(first, second)) {
case INTEGER: {
int n1 = first.intValue();
int n2 = second.intValue();
if (n1 % n2 == 0) {
return new Integer(n1/n2);
}
return new Double(((double)n1)/n2);
}
case LONG: {
long n1 = first.longValue();
long n2 = second.longValue();
if (n1 % n2 == 0) {
return new Long(n1/n2);
}
return new Double(((double)n1)/n2);
}
case FLOAT: {
return new Float(first.floatValue() / second.floatValue());
}
case DOUBLE: {
return new Double(first.doubleValue() / second.doubleValue());
}
case BIGINTEGER: {
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
BigInteger[] divmod = n1.divideAndRemainder(n2);
if(divmod[1].equals(BigInteger.ZERO)) {
return divmod[0];
}
else {
BigDecimal bd1 = new BigDecimal(n1);
BigDecimal bd2 = new BigDecimal(n2);
return bd1.divide(bd2, minScale, roundingPolicy);
}
}
case BIGDECIMAL: {
BigDecimal n1 = toBigDecimal(first);
BigDecimal n2 = toBigDecimal(second);
int scale1 = n1.scale();
int scale2 = n2.scale();
int scale = Math.max(scale1, scale2);
scale = Math.max(minScale, scale);
return n1.divide(n2, scale, roundingPolicy);
}
}
// Make the compiler happy. getCommonClassCode() is guaranteed to
// return only above codes, or throw an exception.
throw new Error();
}
public Number modulus(Number first, Number second) throws TemplateException {
switch(getCommonClassCode(first, second)) {
case INTEGER: {
return new Integer(first.intValue() % second.intValue());
}
case LONG: {
return new Long(first.longValue() % second.longValue());
}
case FLOAT: {
return new Float(first.floatValue() % second.floatValue());
}
case DOUBLE: {
return new Double(first.doubleValue() % second.doubleValue());
}
case BIGINTEGER: {
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
return n1.mod(n2);
}
case BIGDECIMAL: {
throw new TemplateException("Can't calculate remainder on BigDecimals", Environment.getCurrentEnvironment());
}
}
// Make the compiler happy. getCommonClassCode() is guaranteed to
// return only above codes, or throw an exception.
throw new Error();
}
public Number toNumber(String s) {
return OptimizerUtil.optimizeNumberRepresentation(new BigDecimal(s));
}
private static Map createClassCodesMap() {
Map map = new HashMap(17);
Integer intcode = new Integer(INTEGER);
map.put(Byte.class, intcode);
map.put(Short.class, intcode);
map.put(Integer.class, intcode);
map.put(Long.class, new Integer(LONG));
map.put(Float.class, new Integer(FLOAT));
map.put(Double.class, new Integer(DOUBLE));
map.put(BigInteger.class, new Integer(BIGINTEGER));
map.put(BigDecimal.class, new Integer(BIGDECIMAL));
return map;
}
private static int getClassCode(Number num) throws TemplateException {
try {
return ((Integer)classCodes.get(num.getClass())).intValue();
}
catch(NullPointerException e) {
if(num == null) {
throw new TemplateException("Unknown number type null", Environment.getCurrentEnvironment());
}
throw new TemplateException("Unknown number type " + num.getClass().getName(), Environment.getCurrentEnvironment());
}
}
private static int getCommonClassCode(Number num1, Number num2) throws TemplateException {
int c1 = getClassCode(num1);
int c2 = getClassCode(num2);
int c = c1 > c2 ? c1 : c2;
// If BigInteger is combined with a Float or Double, the result is a
// BigDecimal instead of BigInteger in order not to lose the
// fractional parts. If Float is combined with Long, the result is a
// Double instead of Float to preserve the bigger bit width.
switch(c) {
case FLOAT: {
if((c1 < c2 ? c1 : c2) == LONG) {
return DOUBLE;
}
break;
}
case BIGINTEGER: {
int min = c1 < c2 ? c1 : c2;
if(min == DOUBLE || min == FLOAT) {
return BIGDECIMAL;
}
break;
}
}
return c;
}
private static BigInteger toBigInteger(Number num) {
return num instanceof BigInteger ? (BigInteger) num : new BigInteger(num.toString());
}
}
private static BigDecimal toBigDecimal(Number num) {
return num instanceof BigDecimal ? (BigDecimal) num : new BigDecimal(num.toString());
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/FMParserConstants.java 0000644 0001750 0001750 00000013205 11723544470 025717 0 ustar ebourg ebourg /* Generated By:JavaCC: Do not edit this line. FMParserConstants.java */
package freemarker.core;
interface FMParserConstants {
int EOF = 0;
int BLANK = 1;
int START_TAG = 2;
int END_TAG = 3;
int CLOSE_TAG1 = 4;
int CLOSE_TAG2 = 5;
int ATTEMPT = 6;
int RECOVER = 7;
int IF = 8;
int ELSE_IF = 9;
int LIST = 10;
int FOREACH = 11;
int SWITCH = 12;
int CASE = 13;
int ASSIGN = 14;
int GLOBALASSIGN = 15;
int LOCALASSIGN = 16;
int _INCLUDE = 17;
int IMPORT = 18;
int FUNCTION = 19;
int MACRO = 20;
int TRANSFORM = 21;
int VISIT = 22;
int STOP = 23;
int RETURN = 24;
int CALL = 25;
int SETTING = 26;
int COMPRESS = 27;
int COMMENT = 28;
int TERSE_COMMENT = 29;
int NOPARSE = 30;
int END_IF = 31;
int END_LIST = 32;
int END_RECOVER = 33;
int END_ATTEMPT = 34;
int END_FOREACH = 35;
int END_LOCAL = 36;
int END_GLOBAL = 37;
int END_ASSIGN = 38;
int END_FUNCTION = 39;
int END_MACRO = 40;
int END_COMPRESS = 41;
int END_TRANSFORM = 42;
int END_SWITCH = 43;
int ELSE = 44;
int BREAK = 45;
int SIMPLE_RETURN = 46;
int HALT = 47;
int FLUSH = 48;
int TRIM = 49;
int LTRIM = 50;
int RTRIM = 51;
int NOTRIM = 52;
int DEFAUL = 53;
int SIMPLE_NESTED = 54;
int NESTED = 55;
int SIMPLE_RECURSE = 56;
int RECURSE = 57;
int FALLBACK = 58;
int ESCAPE = 59;
int END_ESCAPE = 60;
int NOESCAPE = 61;
int END_NOESCAPE = 62;
int UNIFIED_CALL = 63;
int UNIFIED_CALL_END = 64;
int FTL_HEADER = 65;
int TRIVIAL_FTL_HEADER = 66;
int UNKNOWN_DIRECTIVE = 67;
int WHITESPACE = 68;
int PRINTABLE_CHARS = 69;
int FALSE_ALERT = 70;
int OUTPUT_ESCAPE = 71;
int NUMERICAL_ESCAPE = 72;
int ESCAPED_CHAR = 80;
int STRING_LITERAL = 81;
int RAW_STRING = 82;
int FALSE = 83;
int TRUE = 84;
int INTEGER = 85;
int DECIMAL = 86;
int DOT = 87;
int DOT_DOT = 88;
int BUILT_IN = 89;
int EXISTS = 90;
int EQUALS = 91;
int DOUBLE_EQUALS = 92;
int NOT_EQUALS = 93;
int LESS_THAN = 94;
int LESS_THAN_EQUALS = 95;
int ESCAPED_GT = 96;
int ESCAPED_GTE = 97;
int PLUS = 98;
int MINUS = 99;
int TIMES = 100;
int DOUBLE_STAR = 101;
int ELLIPSIS = 102;
int DIVIDE = 103;
int PERCENT = 104;
int AND = 105;
int OR = 106;
int EXCLAM = 107;
int COMMA = 108;
int SEMICOLON = 109;
int COLON = 110;
int OPEN_BRACKET = 111;
int CLOSE_BRACKET = 112;
int OPEN_PAREN = 113;
int CLOSE_PAREN = 114;
int OPEN_BRACE = 115;
int CLOSE_BRACE = 116;
int IN = 117;
int AS = 118;
int USING = 119;
int ID = 120;
int LETTER = 121;
int DIGIT = 122;
int DIRECTIVE_END = 123;
int EMPTY_DIRECTIVE_END = 124;
int NATURAL_GT = 125;
int NATURAL_GTE = 126;
int TERMINATING_WHITESPACE = 127;
int TERMINATING_EXCLAM = 128;
int TERSE_COMMENT_END = 129;
int MAYBE_END = 130;
int KEEP_GOING = 131;
int LONE_LESS_THAN_OR_DASH = 132;
int DEFAULT = 0;
int NODIRECTIVE = 1;
int FM_EXPRESSION = 2;
int IN_PAREN = 3;
int NAMED_PARAMETER_EXPRESSION = 4;
int EXPRESSION_COMMENT = 5;
int NO_SPACE_EXPRESSION = 6;
int NO_PARSE = 7;
String[] tokenImage = {
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"<_INCLUDE>",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"\"${\"",
"\"#{\"",
"",
"",
"",
"\">\"",
"\"]\"",
"\"-\"",
"",
"",
"",
"",
"\"false\"",
"\"true\"",
"",
"",
"\".\"",
"\"..\"",
"\"?\"",
"\"??\"",
"\"=\"",
"\"==\"",
"\"!=\"",
"",
"",
"",
"",
"\"+\"",
"\"-\"",
"\"*\"",
"\"**\"",
"\"...\"",
"\"/\"",
"\"%\"",
"",
"",
"\"!\"",
"\",\"",
"\";\"",
"\":\"",
"\"[\"",
"\"]\"",
"\"(\"",
"\")\"",
"\"{\"",
"\"}\"",
"\"in\"",
"\"as\"",
"\"using\"",
"",
"",
"",
"\">\"",
"",
"\">\"",
"\">=\"",
"",
"",
"",
"",
"",
"",
};
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/StringArraySequence.java 0000644 0001750 0001750 00000007422 11723544471 026306 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.SimpleScalar;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateScalarModel;
import freemarker.template.TemplateSequenceModel;
/**
* Sequence variable implementation that wraps a String[] with relatively low
* resource utilization. Warning: it does not copy the wrapped array, so do
* not modify that after the model was made!
*
* @author Daniel Dekany
* @version $Id: StringArraySequence.java,v 1.2 2004/01/06 17:06:42 szegedia Exp $
*/
public class StringArraySequence implements TemplateSequenceModel {
private String[] stringArray;
private TemplateScalarModel[] array;
/**
* Warning: Does not copy the argument array!
*/
public StringArraySequence(String[] stringArray) {
this.stringArray = stringArray;
}
public TemplateModel get(int index) {
if (array == null) {
array = new TemplateScalarModel[stringArray.length];
}
TemplateScalarModel result = array[index];
if (result == null) {
result = new SimpleScalar(stringArray[index]);
array[index] = result;
}
return result;
}
public int size() {
return stringArray.length;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Include.java 0000644 0001750 0001750 00000020154 11723544470 023727 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import freemarker.cache.TemplateCache;
import freemarker.template.*;
import freemarker.template.utility.StringUtil;
import freemarker.template.utility.UndeclaredThrowableException;
/**
* An instruction that gets another template
* and processes it within the current template.
*/
final class Include extends TemplateElement {
private Expression includedTemplateName, encodingExp, parseExp;
private String encoding;
private boolean parse;
private final String templatePath;
/**
* @param template the template that this Include is a part of.
* @param includedTemplateName the name of the template to be included.
* @param encodingExp the encoding to be used or null, if it is a default.
* @param parseExp whether the template should be parsed (or is raw text)
*/
Include(Template template,
Expression includedTemplateName,
Expression encodingExp,
Expression parseExp) throws ParseException
{
String templatePath1 = template.getName();
int lastSlash = templatePath1.lastIndexOf('/');
templatePath = lastSlash == -1 ? "" : templatePath1.substring(0, lastSlash + 1);
this.includedTemplateName = includedTemplateName;
if (encodingExp instanceof StringLiteral) {
encoding = encodingExp.toString();
encoding = encoding.substring(1, encoding.length() -1);
}
else {
this.encodingExp = encodingExp;
}
if(parseExp == null) {
parse = true;
}
else if(parseExp.isLiteral()) {
try {
if (parseExp instanceof StringLiteral) {
parse = StringUtil.getYesNo(parseExp.getStringValue(null));
}
else {
try {
parse = parseExp.isTrue(null);
}
catch(NonBooleanException e) {
throw new ParseException("Expected a boolean or string as the value of the parse attribute", parseExp);
}
}
}
catch(TemplateException e) {
// evaluation of literals must not throw a TemplateException
throw new UndeclaredThrowableException(e);
}
}
else {
this.parseExp = parseExp;
}
}
void accept(Environment env) throws TemplateException, IOException {
String templateNameString = includedTemplateName.getStringValue(env);
if( templateNameString == null ) {
String msg = "Error " + getStartLocation()
+ "The expression " + includedTemplateName + " is undefined.";
throw new InvalidReferenceException(msg, env);
}
String enc = encoding;
if (encoding == null && encodingExp != null) {
enc = encodingExp.getStringValue(env);
}
boolean parse = this.parse;
if (parseExp != null) {
TemplateModel tm = parseExp.getAsTemplateModel(env);
if(tm == null) {
if(env.isClassicCompatible()) {
parse = false;
}
else {
assertNonNull(tm, parseExp, env);
}
}
if (tm instanceof TemplateScalarModel) {
parse = getYesNo(EvaluationUtil.getString((TemplateScalarModel)tm, parseExp, env));
}
else {
parse = parseExp.isTrue(env);
}
}
Template includedTemplate;
try {
templateNameString = TemplateCache.getFullTemplatePath(env, templatePath, templateNameString);
includedTemplate = env.getTemplateForInclusion(templateNameString, enc, parse);
}
catch (ParseException pe) {
String msg = "Error parsing included template "
+ templateNameString + "\n" + pe.getMessage();
throw new TemplateException(msg, pe, env);
}
catch (IOException ioe) {
String msg = "Error reading included file "
+ templateNameString;
throw new TemplateException(msg, ioe, env);
}
env.include(includedTemplate);
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer("<#include ");
buf.append(includedTemplateName);
if (encoding != null) {
buf.append(" encoding=\"");
buf.append(encodingExp.getCanonicalForm());
buf.append("\"");
}
if(parseExp != null) {
buf.append(" parse=" + parseExp.getCanonicalForm());
}
else if (!parse) {
buf.append(" parse=false");
}
buf.append("/>");
return buf.toString();
}
public String getDescription() {
return "include " + includedTemplateName;
}
private boolean getYesNo(String s) throws ParseException {
try {
return StringUtil.getYesNo(s);
}
catch (IllegalArgumentException iae) {
throw new ParseException("Error " + getStartLocation()
+ "\nValue of include parse parameter "
+ "must be boolean or one of these strings: "
+ "\"n\", \"no\", \"f\", \"false\", \"y\", \"yes\", \"t\", \"true\""
+ "\nFound: " + parseExp, parseExp);
}
}
/*
boolean heedsOpeningWhitespace() {
return true;
}
boolean heedsTrailingWhitespace() {
return true;
}
*/
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Interpret.java 0000644 0001750 0001750 00000015366 11723544471 024332 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.*;
import java.util.*;
import freemarker.template.*;
/**
* A method that takes a parameter and evaluates it as a scalar,
* then treats that scalar as template source code and returns a
* transform model that evaluates the template in place.
* The template inherits the configuration and environment of the executing
* template. By default, its name will be equal to
* executingTemplate.getName() + "$anonymous_interpreted". You can
* specify another parameter to the method call in which case the
* template name suffix is the specified id instead of "anonymous_interpreted".
* @version $Id: Interpret.java,v 1.2 2005/06/16 18:13:56 ddekany Exp $
* @author Attila Szegedi
*/
class Interpret extends BuiltIn
{
/**
* Constructs a template on-the-fly and returns it embedded in a
* {@link TemplateTransformModel}.
*
* The built-in has two arguments:
* the arguments passed to the method. It can receive at
* least one and at most two arguments, both must evaluate to a scalar.
* The first scalar is interpreted as a template source code and a template
* is built from it. The second (optional) is used to give the generated
* template a name.
*
* @return a {@link TemplateTransformModel} that when executed inside
* a <transform> block will process the generated template
* just as if it had been <transform>-ed at that point.
*/
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException
{
TemplateModel model = target.getAsTemplateModel(env);
Expression sourceExpr = null;
String id = "anonymous_interpreted";
if(model instanceof TemplateSequenceModel)
{
sourceExpr = ((Expression)new DynamicKeyName(target, new NumberLiteral(new Integer(0))).copyLocationFrom(target));
if(((TemplateSequenceModel)model).size() > 1)
{
id = ((Expression)new DynamicKeyName(target, new NumberLiteral(new Integer(1))).copyLocationFrom(target)).getStringValue(env);
}
}
else if (model instanceof TemplateScalarModel)
{
sourceExpr = target;
}
else
{
throw invalidTypeException(model, target, env, "sequence or string");
}
String templateSource = sourceExpr.getStringValue(env);
Template parentTemplate = env.getTemplate();
try
{
Template template = new Template(parentTemplate.getName() + "$" + id, new StringReader(templateSource), parentTemplate.getConfiguration());
template.setLocale(env.getLocale());
return new TemplateProcessorModel(template);
}
catch(IOException e)
{
throw new TemplateException("", e, env);
}
}
private static class TemplateProcessorModel
implements
TemplateTransformModel
{
private final Template template;
TemplateProcessorModel(Template template)
{
this.template = template;
}
public Writer getWriter(final Writer out, Map args) throws TemplateModelException, IOException
{
try
{
Environment env = Environment.getCurrentEnvironment();
env.include(template);
}
catch(TemplateModelException e)
{
throw e;
}
catch(IOException e)
{
throw e;
}
catch(RuntimeException e)
{
throw e;
}
catch(Exception e)
{
throw new TemplateModelException(e);
}
return new Writer(out)
{
public void close()
{
}
public void flush() throws IOException
{
out.flush();
}
public void write(char[] cbuf, int off, int len) throws IOException
{
out.write(cbuf, off, len);
}
};
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Macro.java 0000644 0001750 0001750 00000022175 11723544470 023412 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import java.util.*;
import freemarker.template.*;
/**
* An element representing a macro declaration.
*/
public final class Macro extends TemplateElement implements TemplateModel {
private final String name;
private final String[] argumentNames;
private Map args;
private String catchAll;
boolean isFunction;
static final Macro DO_NOTHING_MACRO = new Macro(".pass",
Collections.EMPTY_LIST,
freemarker.template.utility.Collections12.EMPTY_MAP,
TextBlock.EMPTY_BLOCK);
Macro(String name, List argumentNames, Map args,
TemplateElement nestedBlock)
{
this.name = name;
this.argumentNames = (String[])argumentNames.toArray(
new String[argumentNames.size()]);
this.args = args;
this.nestedBlock = nestedBlock;
}
public String getCatchAll() {
return catchAll;
}
public void setCatchAll(String value) {
catchAll = value;
}
public String[] getArgumentNames() {
return (String[])argumentNames.clone();
}
String[] getArgumentNamesInternal() {
return argumentNames;
}
boolean hasArgNamed(String name) {
return args.containsKey(name);
}
public String getName() {
return name;
}
void accept(Environment env) {
env.visitMacroDef(this);
}
public String getCanonicalForm() {
String directiveName = isFunction ? "function" : "macro";
StringBuffer buf = new StringBuffer("<#");
buf.append(directiveName);
buf.append(' ');
buf.append(name);
buf.append('(');
int size = argumentNames.length;
for (int i = 0; i");
if (nestedBlock != null) {
buf.append(nestedBlock.getCanonicalForm());
}
buf.append("#");
buf.append(directiveName);
buf.append('>');
return buf.toString();
}
public String getDescription() {
return (isFunction() ? "function " : "macro ") + name;
}
public boolean isFunction() {
return isFunction;
}
class Context implements LocalContext {
Environment.Namespace localVars;
TemplateElement body;
Environment.Namespace bodyNamespace;
List bodyParameterNames;
Context prevMacroContext;
ArrayList prevLocalContextStack;
Context(Environment env,
TemplateElement body,
List bodyParameterNames)
{
this.localVars = env.new Namespace();
this.prevMacroContext = env.getCurrentMacroContext();
this.bodyNamespace = env.getCurrentNamespace();
this.prevLocalContextStack = env.getLocalContextStack();
this.body = body;
this.bodyParameterNames = bodyParameterNames;
}
Macro getMacro() {
return Macro.this;
}
void runMacro(Environment env) throws TemplateException, IOException {
sanityCheck(env);
// Set default values for unspecified parameters
if (nestedBlock != null) {
env.visit(nestedBlock);
}
}
// Set default parameters, check if all the required parameters are defined.
void sanityCheck(Environment env) throws TemplateException {
boolean resolvedAnArg, hasUnresolvedArg;
Expression firstUnresolvedExpression;
InvalidReferenceException firstReferenceException;
do {
firstUnresolvedExpression = null;
firstReferenceException = null;
resolvedAnArg = hasUnresolvedArg = false;
for(int i = 0; i < argumentNames.length; ++i) {
String argName = argumentNames[i];
if(localVars.get(argName) == null) {
Expression valueExp = (Expression) args.get(argName);
if (valueExp != null) {
try {
TemplateModel tm = valueExp.getAsTemplateModel(env);
if(tm == null) {
if(!hasUnresolvedArg) {
firstUnresolvedExpression = valueExp;
hasUnresolvedArg = true;
}
}
else {
localVars.put(argName, tm);
resolvedAnArg = true;
}
}
catch(InvalidReferenceException e) {
if(!hasUnresolvedArg) {
hasUnresolvedArg = true;
firstReferenceException = e;
}
}
}
else {
throw new TemplateException("Error executing macro: " + name + "\nrequired parameter: " + argName + " is not specified.", env);
}
}
}
}
while(resolvedAnArg && hasUnresolvedArg);
if(hasUnresolvedArg) {
if(firstReferenceException != null) {
throw firstReferenceException;
}
else {
assertNonNull(null, firstUnresolvedExpression, env);
}
}
}
/**
* @return the local variable of the given name
* or null if it doesn't exist.
*/
public TemplateModel getLocalVariable(String name) throws TemplateModelException {
return localVars.get(name);
}
Environment.Namespace getLocals() {
return localVars;
}
/**
* Set a local variable in this macro
*/
void setLocalVar(String name, TemplateModel var) {
localVars.put(name, var);
}
public Collection getLocalVariableNames() throws TemplateModelException {
HashSet result = new HashSet();
for (TemplateModelIterator it = localVars.keys().iterator(); it.hasNext();) {
result.add(it.next().toString());
}
return result;
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/FMParser.java 0000644 0001750 0001750 00000415045 11723544471 024033 0 ustar ebourg ebourg /* Generated By:JavaCC: Do not edit this line. FMParser.java */
package freemarker.core;
import freemarker.template.*;
import freemarker.template.utility.StringUtil;
import freemarker.template.utility.DeepUnwrap;
import java.io.*;
import java.util.*;
/**
* This class is generated by JavaCC from a grammar file.
*/
public class FMParser implements FMParserConstants {
// Necessary for adding macros and setting location info.
Template template;
private String templateName;
// variables that keep track of whether we are in a loop or a switch.
private int loopNesting, switchNesting;
private boolean inMacro, inFunction, stripWhitespace, stripText;
private LinkedList escapes = new LinkedList();
private int contentNesting; // for stripText
/**
* Create an FM expression parser using a string.
*/
static public FMParser createExpressionParser(String s) {
SimpleCharStream scs = new SimpleCharStream(new StringReader(s), 1, 1, s.length());
FMParserTokenManager token_source = new FMParserTokenManager(scs);
token_source.SwitchTo(FMParserConstants.FM_EXPRESSION);
return new FMParser(token_source);
}
/**
* Constructs a new parser object.
* @param template The template associated with this parser.
* @param reader The character stream to use as input
* @param strictEscapeSyntax Whether FreeMarker directives must start with a #
*/
public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace) {
this(reader);
this.template = template;
token_source.strictEscapeSyntax = strictEscapeSyntax;
this.templateName = template != null ? template.getName() : "";
token_source.templateName = templateName;
this.stripWhitespace = stripWhitespace;
}
public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace, int tagSyntax) {
this(template, reader, strictEscapeSyntax, stripWhitespace, tagSyntax, Configuration.PARSED_DEFAULT_INCOMPATIBLE_ENHANCEMENTS);
}
public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace, int tagSyntax, int incompatibleChanges) {
this(template, reader, strictEscapeSyntax, stripWhitespace);
switch (tagSyntax) {
case Configuration.AUTO_DETECT_TAG_SYNTAX :
token_source.autodetectTagSyntax = true;
break;
case Configuration.ANGLE_BRACKET_TAG_SYNTAX :
token_source.altDirectiveSyntax = false;
break;
case Configuration.SQUARE_BRACKET_TAG_SYNTAX :
token_source.altDirectiveSyntax = true;
break;
default : throw new IllegalArgumentException("Illegal argument for tagSyntax");
}
token_source.incompatibleChanges = incompatibleChanges;
}
public FMParser(String template) {
this(null, new StringReader(template), true, true);
}
private String getErrorStart(Token t) {
return "Error in template: " + template.getName()
+ "\non line " + t.beginLine + ", column " + t.beginColumn;
}
/**
* Throw an exception if the expression passed in is a String
* Literal
*/
private void notStringLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof StringLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound string literal: " + exp
+ "\nExpecting: " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a Number
* Literal
*/
private void notNumberLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof NumberLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound number literal: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a boolean
* Literal
*/
private void notBooleanLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof BooleanLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a Hash
* Literal
*/
private void notHashLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof HashLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound hash literal: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a List
* Literal
*/
private void notListLiteral(Expression exp, String expected)
throws ParseException
{
if (exp instanceof ListLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound list literal: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a literal
* other than of the numerical type
*/
private void numberLiteralOnly(Expression exp) throws ParseException {
notStringLiteral(exp, "number");
notListLiteral(exp, "number");
notHashLiteral(exp, "number");
notBooleanLiteral(exp, "number");
}
/**
* Throw an exception if the expression passed in is
* not a string.
*/
private void stringLiteralOnly(Expression exp) throws ParseException {
notNumberLiteral(exp, "number");
notListLiteral(exp, "number");
notHashLiteral(exp, "number");
notBooleanLiteral(exp, "number");
}
/**
* Throw an exception if the expression passed in is a literal
* other than of the boolean type
*/
private void booleanLiteralOnly(Expression exp) throws ParseException {
notStringLiteral(exp, "boolean (true/false)");
notListLiteral(exp, "boolean (true/false)");
notHashLiteral(exp, "boolean (true/false)");
notNumberLiteral(exp, "boolean (true/false)");
}
private Expression escapedExpression(Expression exp) {
if(!escapes.isEmpty()) {
return ((EscapeBlock)escapes.getFirst()).doEscape(exp);
}
return exp;
}
private boolean getBoolean(Expression exp) throws ParseException {
TemplateModel tm = null;
try {
tm = exp.getAsTemplateModel(null);
} catch (Exception e) {
throw new ParseException(e.getMessage()
+ "\nCould not evaluate expression: "
+ exp.getCanonicalForm()
+ exp.getStartLocation(), exp);
}
if (tm instanceof TemplateBooleanModel) {
try {
return ((TemplateBooleanModel) tm).getAsBoolean();
} catch (TemplateModelException tme) {
}
}
if (tm instanceof TemplateScalarModel) {
try {
return StringUtil.getYesNo(((TemplateScalarModel) tm).getAsString());
} catch (Exception e) {
throw new ParseException(e.getMessage()
+ "\nExpecting yes/no, found: " + exp.getCanonicalForm()
+ exp.getStartLocation(), exp);
}
}
throw new ParseException("Expecting boolean (yes/no) parameter" + exp.getStartLocation(), exp);
}
// Now the actual parsing code, starting
// with the productions for FreeMarker's
// expression syntax.
/**
* This is the same as OrExpression, since
* the OR is the operator with the lowest
* precedence.
*/
final public Expression Expression() throws ParseException {
Expression exp;
exp = OrExpression();
{if (true) return exp;}
throw new Error("Missing return statement in function");
}
/**
* Lowest level expression, a literal, a variable,
* or a possibly more complex expression bounded
* by parentheses.
*/
final public Expression PrimaryExpression() throws ParseException {
Expression exp;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case INTEGER:
case DECIMAL:
exp = NumberLiteral();
break;
case OPEN_BRACE:
exp = HashLiteral();
break;
case STRING_LITERAL:
case RAW_STRING:
exp = StringLiteral(true);
break;
case FALSE:
case TRUE:
exp = BooleanLiteral();
break;
case OPEN_BRACKET:
exp = ListLiteral();
break;
case ID:
exp = Identifier();
break;
case OPEN_PAREN:
exp = Parenthesis();
break;
case DOT:
exp = BuiltinVariable();
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
label_1:
while (true) {
if (jj_2_1(2147483647)) {
;
} else {
break label_1;
}
exp = AddSubExpression(exp);
}
{if (true) return exp;}
throw new Error("Missing return statement in function");
}
final public Expression Parenthesis() throws ParseException {
Expression exp, result;
Token start, end;
start = jj_consume_token(OPEN_PAREN);
exp = Expression();
end = jj_consume_token(CLOSE_PAREN);
result = new ParentheticalExpression(exp);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* A primary expression preceded by zero or
* more unary operators. (The only unary operator we
* currently have is the NOT.)
*/
final public Expression UnaryExpression() throws ParseException {
Expression exp, result;
boolean haveNot = false;
Token t = null, start=null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case PLUS:
case MINUS:
result = UnaryPlusMinusExpression();
break;
case EXCLAM:
result = NotExpression();
break;
case STRING_LITERAL:
case RAW_STRING:
case FALSE:
case TRUE:
case INTEGER:
case DECIMAL:
case DOT:
case OPEN_BRACKET:
case OPEN_PAREN:
case OPEN_BRACE:
case ID:
result = PrimaryExpression();
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public Expression NotExpression() throws ParseException {
Token t;
Expression exp, result=null;
ArrayList nots = new ArrayList();
label_2:
while (true) {
t = jj_consume_token(EXCLAM);
nots.add(t);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EXCLAM:
;
break;
default:
jj_la1[2] = jj_gen;
break label_2;
}
}
exp = PrimaryExpression();
for (int i=0; i + keyname
*/
final public Expression DotVariable(Expression exp) throws ParseException {
Token t;
jj_consume_token(DOT);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
t = jj_consume_token(ID);
break;
case TIMES:
t = jj_consume_token(TIMES);
break;
case DOUBLE_STAR:
t = jj_consume_token(DOUBLE_STAR);
break;
case FALSE:
case TRUE:
case LESS_THAN:
case LESS_THAN_EQUALS:
case ESCAPED_GT:
case ESCAPED_GTE:
case IN:
case AS:
case USING:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case LESS_THAN:
t = jj_consume_token(LESS_THAN);
break;
case LESS_THAN_EQUALS:
t = jj_consume_token(LESS_THAN_EQUALS);
break;
case ESCAPED_GT:
t = jj_consume_token(ESCAPED_GT);
break;
case ESCAPED_GTE:
t = jj_consume_token(ESCAPED_GTE);
break;
case FALSE:
t = jj_consume_token(FALSE);
break;
case TRUE:
t = jj_consume_token(TRUE);
break;
case IN:
t = jj_consume_token(IN);
break;
case AS:
t = jj_consume_token(AS);
break;
case USING:
t = jj_consume_token(USING);
break;
default:
jj_la1[12] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (!Character.isLetter(t.image.charAt(0))) {
String msg = getErrorStart(t)
+ "\n" + t.image + " is not a valid identifier.";
{if (true) throw new ParseException(msg, t.beginLine, t.beginColumn);}
}
break;
default:
jj_la1[13] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
notListLiteral(exp, "hash");
notStringLiteral(exp, "hash");
notBooleanLiteral(exp, "hash");
Dot dot = new Dot(exp, t.image);
dot.setLocation(template, exp, t);
{if (true) return dot;}
throw new Error("Missing return statement in function");
}
/**
* production for when the key is specified
* in brackets.
*/
final public Expression DynamicKey(Expression exp) throws ParseException {
Expression arg;
Token t;
jj_consume_token(OPEN_BRACKET);
arg = Expression();
t = jj_consume_token(CLOSE_BRACKET);
notBooleanLiteral(exp, "list or hash");
notNumberLiteral(exp, "list or hash");
DynamicKeyName dkn = new DynamicKeyName(exp, arg);
dkn.setLocation(template, exp, t);
{if (true) return dkn;}
throw new Error("Missing return statement in function");
}
/**
* production for an arglist part of a method invocation.
*/
final public MethodCall MethodArgs(Expression exp) throws ParseException {
ArrayList args = new ArrayList();
Token end;
jj_consume_token(OPEN_PAREN);
args = PositionalArgs();
end = jj_consume_token(CLOSE_PAREN);
args.trimToSize();
MethodCall result = new MethodCall(exp, args);
result.setLocation(template, exp, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public StringLiteral StringLiteral(boolean interpolate) throws ParseException {
Token t;
boolean raw = false;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
t = jj_consume_token(STRING_LITERAL);
break;
case RAW_STRING:
t = jj_consume_token(RAW_STRING);
raw = true;
break;
default:
jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
String s = t.image;
// Get rid of the quotes.
s = s.substring(1, s.length() -1);
if (raw) {
s=s.substring(1);
}
else try {
s = StringUtil.FTLStringLiteralDec(s);
} catch (ParseException pe) {
pe.lineNumber = t.beginLine;
pe.columnNumber = t.beginColumn;
{if (true) throw pe;}
}
StringLiteral result = new StringLiteral(s);
result.setLocation(template, t, t);
if (interpolate && !raw) {
if (t.image.indexOf("${") >=0 || t.image.indexOf("#{") >=0)
result.checkInterpolation();
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public Expression BooleanLiteral() throws ParseException {
Token t;
Expression result;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case FALSE:
t = jj_consume_token(FALSE);
result = new BooleanLiteral(false);
break;
case TRUE:
t = jj_consume_token(TRUE);
result = new BooleanLiteral(true);
break;
default:
jj_la1[15] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
result.setLocation(template, t, t);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public HashLiteral HashLiteral() throws ParseException {
Token begin, end;
Expression key, value;
ArrayList keys = new ArrayList();
ArrayList values = new ArrayList();
begin = jj_consume_token(OPEN_BRACE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
case RAW_STRING:
case FALSE:
case TRUE:
case INTEGER:
case DECIMAL:
case DOT:
case PLUS:
case MINUS:
case EXCLAM:
case OPEN_BRACKET:
case OPEN_PAREN:
case OPEN_BRACE:
case ID:
key = Expression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
case COLON:
jj_consume_token(COLON);
break;
default:
jj_la1[16] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
value = Expression();
stringLiteralOnly(key);
keys.add(key);
values.add(value);
label_7:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[17] = jj_gen;
break label_7;
}
jj_consume_token(COMMA);
key = Expression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
case COLON:
jj_consume_token(COLON);
break;
default:
jj_la1[18] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
value = Expression();
stringLiteralOnly(key);
keys.add(key);
values.add(value);
}
break;
default:
jj_la1[19] = jj_gen;
;
}
end = jj_consume_token(CLOSE_BRACE);
HashLiteral result = new HashLiteral(keys, values);
result.setLocation(template, begin, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* A production representing the ${...}
* that outputs a variable.
*/
final public DollarVariable StringOutput() throws ParseException {
Expression exp;
Token begin, end;
begin = jj_consume_token(OUTPUT_ESCAPE);
exp = Expression();
notHashLiteral(exp, "scalar");
notListLiteral(exp, "scalar");
notBooleanLiteral(exp, "scalar");
end = jj_consume_token(CLOSE_BRACE);
DollarVariable result = new DollarVariable(exp, escapedExpression(exp));
result.setLocation(template, begin, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public NumericalOutput NumericalOutput() throws ParseException {
Expression exp;
Token fmt = null, begin, end;
begin = jj_consume_token(NUMERICAL_ESCAPE);
exp = Expression();
numberLiteralOnly(exp);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SEMICOLON:
jj_consume_token(SEMICOLON);
fmt = jj_consume_token(ID);
break;
default:
jj_la1[20] = jj_gen;
;
}
end = jj_consume_token(CLOSE_BRACE);
NumericalOutput result;
if (fmt != null) {
int minFrac = -1; // -1 indicates that the value has not been set
int maxFrac = -1;
StringTokenizer st = new StringTokenizer(fmt.image, "mM", true);
char type = '-';
while (st.hasMoreTokens()) {
String token = st.nextToken();
try {
if (type != '-') {
switch (type) {
case 'm':
if (minFrac != -1) {if (true) throw new ParseException("invalid formatting string", fmt.beginLine, fmt.beginColumn);}
minFrac = Integer.parseInt(token);
break;
case 'M':
if (maxFrac != -1) {if (true) throw new ParseException("invalid formatting string", fmt.beginLine, fmt.beginColumn);}
maxFrac = Integer.parseInt(token);
break;
default:
{if (true) throw new ParseException();}
}
type = '-';
} else if (token.equals("m")) {
type = 'm';
} else if (token.equals("M")) {
type = 'M';
} else {
{if (true) throw new ParseException();}
}
}
catch (ParseException e) {
String msg = getErrorStart(fmt)
+ "\nInvalid format specifier "
+ fmt.image;
{if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
}
catch (NumberFormatException e) {
String msg = getErrorStart(fmt)
+ "\nInvalid number in the format specifier "
+ fmt.image;
{if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
}
}
if (maxFrac == -1) {
if (minFrac == -1) {
String msg = getErrorStart(fmt)
+ "\nInvalid format specification, at least one of m and M must be specified!";
{if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
}
maxFrac = minFrac;
} else if (minFrac == -1) {
minFrac = 0;
}
if (minFrac > maxFrac) {
String msg = getErrorStart(fmt)
+ "\nInvalid format specification, min cannot be greater than max!";
{if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
}
if (minFrac > 50 || maxFrac > 50) {// sanity check
String msg = getErrorStart(fmt)
+ "\nCannot specify more than 50 fraction digits";
{if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
}
result = new NumericalOutput(exp, minFrac, maxFrac);
} else { // if format != null
result = new NumericalOutput(exp);
}
result.setLocation(template, begin, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TemplateElement If() throws ParseException {
Token start, end, t;
Expression condition;
TemplateElement block;
IfBlock ifBlock;
ConditionalBlock cblock;
start = jj_consume_token(IF);
condition = Expression();
jj_consume_token(DIRECTIVE_END);
block = OptionalBlock();
cblock = new ConditionalBlock(condition, block, true);
cblock.setLocation(template, start, block);
ifBlock = new IfBlock(cblock);
label_8:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ELSE_IF:
;
break;
default:
jj_la1[21] = jj_gen;
break label_8;
}
t = jj_consume_token(ELSE_IF);
condition = Expression();
LooseDirectiveEnd();
block = OptionalBlock();
cblock = new ConditionalBlock(condition, block, false);
cblock.setLocation(template, t, block);
ifBlock.addBlock(cblock);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ELSE:
t = jj_consume_token(ELSE);
block = OptionalBlock();
cblock = new ConditionalBlock(null, block, false);
cblock.setLocation(template, t, block);
ifBlock.addBlock(cblock);
break;
default:
jj_la1[22] = jj_gen;
;
}
end = jj_consume_token(END_IF);
ifBlock.setLocation(template, start, end);
{if (true) return ifBlock;}
throw new Error("Missing return statement in function");
}
final public AttemptBlock Attempt() throws ParseException {
Token start, end;
TemplateElement block, recoveryBlock;
start = jj_consume_token(ATTEMPT);
block = OptionalBlock();
recoveryBlock = Recover();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case END_RECOVER:
end = jj_consume_token(END_RECOVER);
break;
case END_ATTEMPT:
end = jj_consume_token(END_ATTEMPT);
break;
default:
jj_la1[23] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
AttemptBlock result = new AttemptBlock(block, recoveryBlock);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public RecoveryBlock Recover() throws ParseException {
Token start;
TemplateElement block;
start = jj_consume_token(RECOVER);
block = OptionalBlock();
RecoveryBlock result = new RecoveryBlock(block);
result.setLocation(template, start, block);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public IteratorBlock List() throws ParseException {
Expression exp;
Token index, start, end;
TemplateElement block;
start = jj_consume_token(LIST);
++loopNesting;
exp = Expression();
jj_consume_token(AS);
index = jj_consume_token(ID);
jj_consume_token(DIRECTIVE_END);
block = OptionalBlock();
end = jj_consume_token(END_LIST);
--loopNesting;
IteratorBlock result = new IteratorBlock(exp,
index.image,
block,
false);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public IteratorBlock ForEach() throws ParseException {
Expression exp;
Token index, start, end;
TemplateElement block;
start = jj_consume_token(FOREACH);
++loopNesting;
index = jj_consume_token(ID);
jj_consume_token(IN);
exp = Expression();
jj_consume_token(DIRECTIVE_END);
block = OptionalBlock();
end = jj_consume_token(END_FOREACH);
--loopNesting;
IteratorBlock result = new IteratorBlock(exp,
index.image,
block,
true);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public VisitNode Visit() throws ParseException {
Token start, end;
Expression targetNode, namespaces=null;
start = jj_consume_token(VISIT);
targetNode = Expression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case USING:
jj_consume_token(USING);
namespaces = Expression();
break;
default:
jj_la1[24] = jj_gen;
;
}
end = LooseDirectiveEnd();
VisitNode result = new VisitNode(targetNode, namespaces);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public RecurseNode Recurse() throws ParseException {
Token start, end = null;
Expression node=null, namespaces=null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SIMPLE_RECURSE:
start = jj_consume_token(SIMPLE_RECURSE);
break;
case RECURSE:
start = jj_consume_token(RECURSE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
case RAW_STRING:
case FALSE:
case TRUE:
case INTEGER:
case DECIMAL:
case DOT:
case PLUS:
case MINUS:
case EXCLAM:
case OPEN_BRACKET:
case OPEN_PAREN:
case OPEN_BRACE:
case ID:
node = Expression();
break;
default:
jj_la1[25] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case USING:
jj_consume_token(USING);
namespaces = Expression();
break;
default:
jj_la1[26] = jj_gen;
;
}
end = LooseDirectiveEnd();
break;
default:
jj_la1[27] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (end == null) end = start;
RecurseNode result = new RecurseNode(node, namespaces);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public FallbackInstruction FallBack() throws ParseException {
Token tok;
tok = jj_consume_token(FALLBACK);
if (!inMacro) {
{if (true) throw new ParseException(getErrorStart(tok)
+ "\nCannot fall back "
+ " outside a macro.",
tok.beginLine, tok.beginColumn);}
}
FallbackInstruction result = new FallbackInstruction();
result.setLocation(template, tok, tok);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* Production used to break out of a loop or a switch block.
*/
final public BreakInstruction Break() throws ParseException {
Token start;
start = jj_consume_token(BREAK);
if (loopNesting < 1 && switchNesting <1)
{
String msg = getErrorStart(start) + "\n"
+ start.image
+ " occurred outside a loop or a switch block.";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
BreakInstruction result = new BreakInstruction();
result.setLocation(template, start, start);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* Production used to jump out of a macro.
* The stop instruction terminates the rendering of the template.
*/
final public ReturnInstruction Return() throws ParseException {
Token start, end=null;
Expression exp = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SIMPLE_RETURN:
start = jj_consume_token(SIMPLE_RETURN);
end = start;
break;
case RETURN:
start = jj_consume_token(RETURN);
exp = Expression();
end = LooseDirectiveEnd();
break;
default:
jj_la1[28] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (inMacro) {
if (exp != null) {
String msg = getErrorStart(start)
+ "\nA macro cannot return a value";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
}
else if (inFunction) {
if (exp == null) {
String msg = getErrorStart(start)
+ "\nA function must return a value";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
}
else {
if (exp == null) {
String msg = getErrorStart(start)
+ "\nA return instruction can only occur inside a macro of function";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
}
ReturnInstruction result = new ReturnInstruction(exp);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public StopInstruction Stop() throws ParseException {
Token start = null;
Expression exp = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case HALT:
start = jj_consume_token(HALT);
break;
case STOP:
start = jj_consume_token(STOP);
exp = Expression();
LooseDirectiveEnd();
break;
default:
jj_la1[29] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
StopInstruction result = new StopInstruction(exp);
result.setLocation(template, start, start);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TemplateElement Nested() throws ParseException {
Token t, end;
ArrayList bodyParameters;
BodyInstruction result = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SIMPLE_NESTED:
t = jj_consume_token(SIMPLE_NESTED);
result = new BodyInstruction(null);
result.setLocation(template, t, t);
break;
case NESTED:
t = jj_consume_token(NESTED);
bodyParameters = PositionalArgs();
end = LooseDirectiveEnd();
result = new BodyInstruction(bodyParameters);
result.setLocation(template, t, end);
break;
default:
jj_la1[30] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (!inMacro) {
{if (true) throw new ParseException(getErrorStart(t)
+ "\nCannot use a "
+ t.image
+ " instruction outside a macro.",
t.beginLine, t.beginColumn);}
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TemplateElement Flush() throws ParseException {
Token t;
t = jj_consume_token(FLUSH);
FlushInstruction result = new FlushInstruction();
result.setLocation(template, t, t);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TemplateElement Trim() throws ParseException {
Token t;
TrimInstruction result=null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TRIM:
t = jj_consume_token(TRIM);
result = new TrimInstruction(true, true);
break;
case LTRIM:
t = jj_consume_token(LTRIM);
result = new TrimInstruction(true, false);
break;
case RTRIM:
t = jj_consume_token(RTRIM);
result = new TrimInstruction(false, true);
break;
case NOTRIM:
t = jj_consume_token(NOTRIM);
result = new TrimInstruction(false, false);
break;
default:
jj_la1[31] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
result.setLocation(template, t, t);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TemplateElement Assign() throws ParseException {
Token start, end;
int scope;
Token id=null;
Expression nameExp, exp, nsExp=null;
String varName;
ArrayList assignments = new ArrayList();
Assignment ass;
TemplateElement block;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ASSIGN:
start = jj_consume_token(ASSIGN);
scope = Assignment.NAMESPACE;
break;
case GLOBALASSIGN:
start = jj_consume_token(GLOBALASSIGN);
scope = Assignment.GLOBAL;
break;
case LOCALASSIGN:
start = jj_consume_token(LOCALASSIGN);
scope = Assignment.LOCAL;
scope = Assignment.LOCAL;
if (!inMacro && !inFunction) {
String msg = getErrorStart(start)
+ "\nLocal variable assigned outside a macro.";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
break;
default:
jj_la1[32] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
nameExp = IdentifierOrStringLiteral();
varName = (nameExp instanceof StringLiteral) ? ((StringLiteral) nameExp).getAsString() : nameExp.toString();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EQUALS:
jj_consume_token(EQUALS);
exp = Expression();
ass = new Assignment(varName, exp, scope);
ass.setLocation(template, nameExp, exp);
assignments.add(ass);
label_9:
while (true) {
if (jj_2_11(2147483647)) {
;
} else {
break label_9;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
default:
jj_la1[33] = jj_gen;
;
}
nameExp = IdentifierOrStringLiteral();
varName = (nameExp instanceof StringLiteral) ? ((StringLiteral) nameExp).getAsString() : nameExp.toString();
jj_consume_token(EQUALS);
exp = Expression();
ass = new Assignment(varName, exp, scope);
ass.setLocation(template, nameExp, exp);
assignments.add(ass);
}
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;
;
}
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[35] = 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[36] = 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[37] = 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[38] = jj_gen;
;
}
label_10:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[39] = 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[40] = 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[41] = jj_gen;
;
}
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[42] = 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[43] = 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[44] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
default:
jj_la1[45] = 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[46] = 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[47] = 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[48] = 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:
case TERMINATING_WHITESPACE:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERMINATING_WHITESPACE:
jj_consume_token(TERMINATING_WHITESPACE);
break;
default:
jj_la1[49] = jj_gen;
;
}
t = jj_consume_token(ID);
bodyParameters.add(t.image);
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
case TERMINATING_WHITESPACE:
;
break;
default:
jj_la1[50] = jj_gen;
break label_12;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERMINATING_WHITESPACE:
jj_consume_token(TERMINATING_WHITESPACE);
break;
default:
jj_la1[51] = jj_gen;
;
}
jj_consume_token(COMMA);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERMINATING_WHITESPACE:
jj_consume_token(TERMINATING_WHITESPACE);
break;
default:
jj_la1[52] = jj_gen;
;
}
t = jj_consume_token(ID);
bodyParameters.add(t.image);
}
break;
default:
jj_la1[53] = jj_gen;
;
}
break;
default:
jj_la1[54] = 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[55] = 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[56] = 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 HashMap();
Token t;
Expression exp;
label_13:
while (true) {
t = jj_consume_token(ID);
jj_consume_token(EQUALS);
token_source.SwitchTo(token_source.NAMED_PARAMETER_EXPRESSION);
token_source.inInvocation = true;
exp = Expression();
result.put(t.image, exp);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[57] = jj_gen;
break label_13;
}
}
token_source.inInvocation = false;
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public ArrayList PositionalArgs() throws ParseException {
ArrayList result = new ArrayList();
Expression arg;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
case RAW_STRING:
case FALSE:
case TRUE:
case INTEGER:
case DECIMAL:
case DOT:
case PLUS:
case MINUS:
case EXCLAM:
case OPEN_BRACKET:
case OPEN_PAREN:
case OPEN_BRACE:
case ID:
arg = Expression();
result.add(arg);
label_14:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
case RAW_STRING:
case FALSE:
case TRUE:
case INTEGER:
case DECIMAL:
case DOT:
case PLUS:
case MINUS:
case EXCLAM:
case COMMA:
case OPEN_BRACKET:
case OPEN_PAREN:
case OPEN_BRACE:
case ID:
;
break;
default:
jj_la1[58] = jj_gen;
break label_14;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
default:
jj_la1[59] = jj_gen;
;
}
arg = Expression();
result.add(arg);
}
break;
default:
jj_la1[60] = jj_gen;
;
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public Comment Comment() throws ParseException {
Token start, end;
StringBuffer buf = new StringBuffer();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMENT:
start = jj_consume_token(COMMENT);
break;
case TERSE_COMMENT:
start = jj_consume_token(TERSE_COMMENT);
break;
default:
jj_la1[61] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
end = UnparsedContent(buf);
Comment result = new Comment(buf.toString());
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TextBlock NoParse() throws ParseException {
Token start, end;
StringBuffer buf = new StringBuffer();
start = jj_consume_token(NOPARSE);
end = UnparsedContent(buf);
TextBlock result = new TextBlock(buf.toString(), true);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public TransformBlock Transform() throws ParseException {
Token start, end, argName;
Expression exp, argExp;
TemplateElement content = null;
HashMap args = null;
start = jj_consume_token(TRANSFORM);
exp = Expression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SEMICOLON:
jj_consume_token(SEMICOLON);
break;
default:
jj_la1[62] = jj_gen;
;
}
label_15:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[63] = jj_gen;
break label_15;
}
argName = jj_consume_token(ID);
jj_consume_token(EQUALS);
argExp = Expression();
if (args == null) args = new HashMap();
args.put(argName.image, argExp);
}
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);
content = OptionalBlock();
end = jj_consume_token(END_TRANSFORM);
break;
default:
jj_la1[64] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
TransformBlock result = new TransformBlock(exp, args, content);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public SwitchBlock Switch() throws ParseException {
SwitchBlock switchBlock;
Case caseIns;
Expression switchExp;
Token start, end;
boolean defaultFound = false;
start = jj_consume_token(SWITCH);
switchExp = Expression();
jj_consume_token(DIRECTIVE_END);
++switchNesting;
switchBlock = new SwitchBlock(switchExp);
label_16:
while (true) {
if (jj_2_15(2)) {
;
} else {
break label_16;
}
caseIns = Case();
if (caseIns.isDefault) {
if (defaultFound) {
String msg = getErrorStart(start)
+ "\nYou can only have one default case in a switch statement";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
defaultFound = true;
}
switchBlock.addCase(caseIns);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
jj_consume_token(WHITESPACE);
break;
default:
jj_la1[65] = jj_gen;
;
}
end = jj_consume_token(END_SWITCH);
--switchNesting;
switchBlock.setLocation(template, start, end);
{if (true) return switchBlock;}
throw new Error("Missing return statement in function");
}
final public Case Case() throws ParseException {
Expression exp = null;
TemplateElement block;
boolean isDefault = false;
Token start;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
jj_consume_token(WHITESPACE);
break;
default:
jj_la1[66] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CASE:
start = jj_consume_token(CASE);
exp = Expression();
jj_consume_token(DIRECTIVE_END);
break;
case DEFAUL:
start = jj_consume_token(DEFAUL);
isDefault = true;
break;
default:
jj_la1[67] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
block = OptionalBlock();
Case result = new Case(exp, block, isDefault);
result.setLocation(template, start, block);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public EscapeBlock Escape() throws ParseException {
Token variable, start, end;
Expression escapeExpr;
TemplateElement content;
start = jj_consume_token(ESCAPE);
variable = jj_consume_token(ID);
jj_consume_token(AS);
escapeExpr = Expression();
jj_consume_token(DIRECTIVE_END);
EscapeBlock result = new EscapeBlock(variable.image, escapeExpr, escapedExpression(escapeExpr));
escapes.addFirst(result);
content = OptionalBlock();
result.setContent(content);
escapes.removeFirst();
end = jj_consume_token(END_ESCAPE);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
final public NoEscapeBlock NoEscape() throws ParseException {
Token start, end;
TemplateElement content;
start = jj_consume_token(NOESCAPE);
if(escapes.isEmpty()) {
String msg = getErrorStart(start)
+ "\nnoescape with no matching escape encountered.";
{if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
}
Object escape = escapes.removeFirst();
content = OptionalBlock();
end = jj_consume_token(END_NOESCAPE);
escapes.addFirst(escape);
NoEscapeBlock result = new NoEscapeBlock(content);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* Production to terminate potentially empty elements. Either a ">" or "/>"
*/
final public Token LooseDirectiveEnd() throws ParseException {
Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DIRECTIVE_END:
t = jj_consume_token(DIRECTIVE_END);
break;
case EMPTY_DIRECTIVE_END:
t = jj_consume_token(EMPTY_DIRECTIVE_END);
break;
default:
jj_la1[68] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return t;}
throw new Error("Missing return statement in function");
}
final public PropertySetting Setting() throws ParseException {
Token start, end, key;
Expression value;
start = jj_consume_token(SETTING);
key = jj_consume_token(ID);
jj_consume_token(EQUALS);
value = Expression();
end = LooseDirectiveEnd();
PropertySetting result = new PropertySetting(key.image, value);
result.setLocation(template, start, end);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* A production for FreeMarker directives.
*/
final public TemplateElement FreemarkerDirective() throws ParseException {
TemplateElement tp;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IF:
tp = If();
break;
case LIST:
tp = List();
break;
case FOREACH:
tp = ForEach();
break;
case ASSIGN:
case GLOBALASSIGN:
case LOCALASSIGN:
tp = Assign();
break;
case _INCLUDE:
tp = Include();
break;
case IMPORT:
tp = Import();
break;
case FUNCTION:
case MACRO:
tp = Macro();
break;
case COMPRESS:
tp = Compress();
break;
case UNIFIED_CALL:
tp = UnifiedMacroTransform();
break;
case CALL:
tp = Call();
break;
case COMMENT:
case TERSE_COMMENT:
tp = Comment();
break;
case NOPARSE:
tp = NoParse();
break;
case TRANSFORM:
tp = Transform();
break;
case SWITCH:
tp = Switch();
break;
case SETTING:
tp = Setting();
break;
case BREAK:
tp = Break();
break;
case RETURN:
case SIMPLE_RETURN:
tp = Return();
break;
case STOP:
case HALT:
tp = Stop();
break;
case FLUSH:
tp = Flush();
break;
case TRIM:
case LTRIM:
case RTRIM:
case NOTRIM:
tp = Trim();
break;
case SIMPLE_NESTED:
case NESTED:
tp = Nested();
break;
case ESCAPE:
tp = Escape();
break;
case NOESCAPE:
tp = NoEscape();
break;
case VISIT:
tp = Visit();
break;
case SIMPLE_RECURSE:
case RECURSE:
tp = Recurse();
break;
case FALLBACK:
tp = FallBack();
break;
case ATTEMPT:
tp = Attempt();
break;
default:
jj_la1[69] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return tp;}
throw new Error("Missing return statement in function");
}
/**
* Production for a block of raw text
* i.e. text that contains no
* FreeMarker directives.
*/
final public TextBlock PCData() throws ParseException {
StringBuffer buf = new StringBuffer();
Token t=null, start=null, prevToken = null;
label_17:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
prevToken = t;
t = jj_consume_token(WHITESPACE);
break;
case PRINTABLE_CHARS:
t = jj_consume_token(PRINTABLE_CHARS);
break;
case FALSE_ALERT:
t = jj_consume_token(FALSE_ALERT);
break;
default:
jj_la1[70] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
buf.append(t.image);
if (start == null) start = t;
{if (prevToken != null) prevToken.next = null;}
if (jj_2_16(2147483647)) {
;
} else {
break label_17;
}
}
if (stripText && contentNesting == 1)
{if (true) return TextBlock.EMPTY_BLOCK;}
TextBlock result = new TextBlock(buf.toString(), false);
result.setLocation(template, start, t);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* Production for dealing with unparsed content,
* i.e. what is inside a comment or noparse tag.
* It returns the ending token. The content
* of the tag is put in buf.
*/
final public Token UnparsedContent(StringBuffer buf) throws ParseException {
Token t;
label_18:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case KEEP_GOING:
t = jj_consume_token(KEEP_GOING);
break;
case MAYBE_END:
t = jj_consume_token(MAYBE_END);
break;
case TERSE_COMMENT_END:
t = jj_consume_token(TERSE_COMMENT_END);
break;
case LONE_LESS_THAN_OR_DASH:
t = jj_consume_token(LONE_LESS_THAN_OR_DASH);
break;
default:
jj_la1[71] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
buf.append(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TERSE_COMMENT_END:
case MAYBE_END:
case KEEP_GOING:
case LONE_LESS_THAN_OR_DASH:
;
break;
default:
jj_la1[72] = jj_gen;
break label_18;
}
}
buf.setLength(buf.length() - t.image.length());
{if (true) return t;}
throw new Error("Missing return statement in function");
}
final public TemplateElement Content() throws ParseException {
MixedContent nodes = new MixedContent();
TemplateElement elem, begin=null;
contentNesting++;
label_19:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
case PRINTABLE_CHARS:
case FALSE_ALERT:
elem = PCData();
break;
case OUTPUT_ESCAPE:
elem = StringOutput();
break;
case NUMERICAL_ESCAPE:
elem = NumericalOutput();
break;
case ATTEMPT:
case IF:
case LIST:
case FOREACH:
case SWITCH:
case ASSIGN:
case GLOBALASSIGN:
case LOCALASSIGN:
case _INCLUDE:
case IMPORT:
case FUNCTION:
case MACRO:
case TRANSFORM:
case VISIT:
case STOP:
case RETURN:
case CALL:
case SETTING:
case COMPRESS:
case COMMENT:
case TERSE_COMMENT:
case NOPARSE:
case BREAK:
case SIMPLE_RETURN:
case HALT:
case FLUSH:
case TRIM:
case LTRIM:
case RTRIM:
case NOTRIM:
case SIMPLE_NESTED:
case NESTED:
case SIMPLE_RECURSE:
case RECURSE:
case FALLBACK:
case ESCAPE:
case NOESCAPE:
case UNIFIED_CALL:
elem = FreemarkerDirective();
break;
default:
jj_la1[73] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (begin == null) {
begin = elem;
}
nodes.addElement(elem);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ATTEMPT:
case IF:
case LIST:
case FOREACH:
case SWITCH:
case ASSIGN:
case GLOBALASSIGN:
case LOCALASSIGN:
case _INCLUDE:
case IMPORT:
case FUNCTION:
case MACRO:
case TRANSFORM:
case VISIT:
case STOP:
case RETURN:
case CALL:
case SETTING:
case COMPRESS:
case COMMENT:
case TERSE_COMMENT:
case NOPARSE:
case BREAK:
case SIMPLE_RETURN:
case HALT:
case FLUSH:
case TRIM:
case LTRIM:
case RTRIM:
case NOTRIM:
case SIMPLE_NESTED:
case NESTED:
case SIMPLE_RECURSE:
case RECURSE:
case FALLBACK:
case ESCAPE:
case NOESCAPE:
case UNIFIED_CALL:
case WHITESPACE:
case PRINTABLE_CHARS:
case FALSE_ALERT:
case OUTPUT_ESCAPE:
case NUMERICAL_ESCAPE:
;
break;
default:
jj_la1[74] = jj_gen;
break label_19;
}
}
contentNesting--;
nodes.setLocation(template, begin, elem);
{if (true) return nodes;}
throw new Error("Missing return statement in function");
}
/**
* A production freemarker text that may contain
* ${...} and #{...} but no directives.
*/
final public TemplateElement FreeMarkerText() throws ParseException {
MixedContent nodes = new MixedContent();
TemplateElement elem, begin = null;
label_20:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
case PRINTABLE_CHARS:
case FALSE_ALERT:
elem = PCData();
break;
case OUTPUT_ESCAPE:
elem = StringOutput();
break;
case NUMERICAL_ESCAPE:
elem = NumericalOutput();
break;
default:
jj_la1[75] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (begin == null) {
begin = elem;
}
nodes.addElement(elem);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
case PRINTABLE_CHARS:
case FALSE_ALERT:
case OUTPUT_ESCAPE:
case NUMERICAL_ESCAPE:
;
break;
default:
jj_la1[76] = jj_gen;
break label_20;
}
}
nodes.setLocation(template, begin, elem);
{if (true) return nodes;}
throw new Error("Missing return statement in function");
}
/**
* A production for a block of optional content.
* Returns an empty Text block if there is no
* content.
*/
final public TemplateElement OptionalBlock() throws ParseException {
TemplateElement tp = TextBlock.EMPTY_BLOCK;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ATTEMPT:
case IF:
case LIST:
case FOREACH:
case SWITCH:
case ASSIGN:
case GLOBALASSIGN:
case LOCALASSIGN:
case _INCLUDE:
case IMPORT:
case FUNCTION:
case MACRO:
case TRANSFORM:
case VISIT:
case STOP:
case RETURN:
case CALL:
case SETTING:
case COMPRESS:
case COMMENT:
case TERSE_COMMENT:
case NOPARSE:
case BREAK:
case SIMPLE_RETURN:
case HALT:
case FLUSH:
case TRIM:
case LTRIM:
case RTRIM:
case NOTRIM:
case SIMPLE_NESTED:
case NESTED:
case SIMPLE_RECURSE:
case RECURSE:
case FALLBACK:
case ESCAPE:
case NOESCAPE:
case UNIFIED_CALL:
case WHITESPACE:
case PRINTABLE_CHARS:
case FALSE_ALERT:
case OUTPUT_ESCAPE:
case NUMERICAL_ESCAPE:
// has no effect but to get rid of a spurious warning.
tp = Content();
break;
default:
jj_la1[77] = jj_gen;
;
}
{if (true) return tp;}
throw new Error("Missing return statement in function");
}
final public void HeaderElement() throws ParseException {
Token key;
Expression exp = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHITESPACE:
jj_consume_token(WHITESPACE);
break;
default:
jj_la1[78] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TRIVIAL_FTL_HEADER:
jj_consume_token(TRIVIAL_FTL_HEADER);
break;
case FTL_HEADER:
jj_consume_token(FTL_HEADER);
label_21:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[79] = jj_gen;
break label_21;
}
key = jj_consume_token(ID);
jj_consume_token(EQUALS);
exp = Expression();
String ks = key.image;
TemplateModel value = null;
try {
value = exp.getAsTemplateModel(null);
} catch (Exception e) {
{if (true) throw new ParseException("Could not evaluate expression: "
+ exp.getCanonicalForm() + " "
+ exp.getStartLocation()
+ "\nUnderlying cause: " +
e.getMessage(), exp);}
}
String vs = null;
if (value instanceof TemplateScalarModel) {
try {
vs = ((TemplateScalarModel) exp).getAsString();
} catch (TemplateModelException tme) {}
}
if (template != null) {
if (ks.equalsIgnoreCase("encoding")) {
if (vs == null) {
{if (true) throw new ParseException("expecting encoding string here: "
+ exp.getStartLocation(), exp);}
}
String encoding = template.getEncoding();
if (encoding != null && !encoding.equals(vs)) {
{if (true) throw new Template.WrongEncodingException(vs);}
}
}
else if (ks.equalsIgnoreCase("STRIP_WHITESPACE")) {
this.stripWhitespace = getBoolean(exp);
}
else if (ks.equalsIgnoreCase("STRIP_TEXT")) {
this.stripText = getBoolean(exp);
}
else if (ks.equalsIgnoreCase("STRICT_SYNTAX")) {
this.token_source.strictEscapeSyntax = getBoolean(exp);
}
else if (ks.equalsIgnoreCase("ns_prefixes")) {
if (!(value instanceof TemplateHashModelEx)) {
{if (true) throw new ParseException("Expecting a hash of prefixes to namespace URI's here. " + exp.getStartLocation(), exp);}
}
TemplateHashModelEx prefixMap = (TemplateHashModelEx) value;
try {
TemplateCollectionModel keys = prefixMap.keys();
for (TemplateModelIterator it = keys.iterator(); it.hasNext();) {
String prefix = ((TemplateScalarModel) it.next()).getAsString();
TemplateModel valueModel = prefixMap.get(prefix);
if (!(valueModel instanceof TemplateScalarModel)) {
{if (true) throw new ParseException("Non-string value in prefix to namespace hash. " + exp.getStartLocation(), exp);}
}
String nsURI = ((TemplateScalarModel) valueModel).getAsString();
try {
template.addPrefixNSMapping(prefix, nsURI);
} catch (IllegalArgumentException iae) {
{if (true) throw new ParseException(iae.getMessage() + " " + exp.getStartLocation(), exp);}
}
}
} catch (TemplateModelException tme) {
}
}
else if (ks.equalsIgnoreCase("attributes")) {
if (!(value instanceof TemplateHashModelEx)) {
{if (true) throw new ParseException("Expecting a hash of attribute names to values here. " + exp.getStartLocation(), exp);}
}
TemplateHashModelEx attributeMap = (TemplateHashModelEx) value;
try {
TemplateCollectionModel keys = attributeMap.keys();
for (TemplateModelIterator it = keys.iterator(); it.hasNext();) {
String attName = ((TemplateScalarModel) it.next()).getAsString();
Object attValue = DeepUnwrap.unwrap(attributeMap.get(attName));
template.setCustomAttribute(attName, attValue);
}
} catch (TemplateModelException tme) {
}
}
else {
{if (true) throw new ParseException("Unknown FTL header parameter: " + key.image,
key.beginLine, key.beginColumn);}
}
}
}
LooseDirectiveEnd();
break;
default:
jj_la1[80] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
final public Map ParamList() throws ParseException {
Identifier id;
Expression exp;
Map result = new HashMap();
label_22:
while (true) {
id = Identifier();
jj_consume_token(EQUALS);
exp = Expression();
result.put(id.toString(), exp);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
jj_consume_token(COMMA);
break;
default:
jj_la1[81] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ID:
;
break;
default:
jj_la1[82] = jj_gen;
break label_22;
}
}
{if (true) return result;}
throw new Error("Missing return statement in function");
}
/**
* Root production to be used when parsing
* an entire file.
*/
final public TemplateElement Root() throws ParseException {
TemplateElement doc;
if (jj_2_17(2147483647)) {
HeaderElement();
} else {
;
}
doc = OptionalBlock();
jj_consume_token(0);
doc.setParentRecursively(null);
{if (true) return doc.postParseCleanup(stripWhitespace);}
throw new Error("Missing return statement in function");
}
final private boolean jj_2_1(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_1(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(0, xla); }
}
final private boolean jj_2_2(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_2(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(1, xla); }
}
final private boolean jj_2_3(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_3(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(2, xla); }
}
final private boolean jj_2_4(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_4(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(3, xla); }
}
final private boolean jj_2_5(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_5(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(4, xla); }
}
final private boolean jj_2_6(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_6(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(5, xla); }
}
final private boolean jj_2_7(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_7(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(6, xla); }
}
final private boolean jj_2_8(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_8(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(7, xla); }
}
final private boolean jj_2_9(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_9(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(8, xla); }
}
final private boolean jj_2_10(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_10(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(9, xla); }
}
final private boolean jj_2_11(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_11(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(10, xla); }
}
final private boolean jj_2_12(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_12(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(11, xla); }
}
final private boolean jj_2_13(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_13(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(12, xla); }
}
final private boolean jj_2_14(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_14(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(13, xla); }
}
final private boolean jj_2_15(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_15(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(14, xla); }
}
final private boolean jj_2_16(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_16(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(15, xla); }
}
final private boolean jj_2_17(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_17(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(16, xla); }
}
final private boolean jj_3R_32() {
if (jj_3R_35()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_36()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_110() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(56)) {
jj_scanpos = xsp;
if (jj_3R_132()) return true;
}
return false;
}
final private boolean jj_3R_108() {
if (jj_scan_token(NOESCAPE)) return true;
return false;
}
final private boolean jj_3R_170() {
if (jj_scan_token(OPEN_BRACKET)) return true;
if (jj_3R_23()) return true;
if (jj_scan_token(CLOSE_BRACKET)) return true;
return false;
}
final private boolean jj_3R_122() {
if (jj_scan_token(FUNCTION)) return true;
return false;
}
final private boolean jj_3_3() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(100)) {
jj_scanpos = xsp;
if (jj_scan_token(103)) {
jj_scanpos = xsp;
if (jj_scan_token(104)) return true;
}
}
return false;
}
final private boolean jj_3R_118() {
if (jj_scan_token(PERCENT)) return true;
return false;
}
final private boolean jj_3R_92() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(20)) {
jj_scanpos = xsp;
if (jj_3R_122()) return true;
}
return false;
}
final private boolean jj_3R_117() {
if (jj_scan_token(DIVIDE)) return true;
return false;
}
final private boolean jj_3R_109() {
if (jj_scan_token(VISIT)) return true;
return false;
}
final private boolean jj_3R_116() {
if (jj_scan_token(TIMES)) return true;
return false;
}
final private boolean jj_3R_82() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_116()) {
jj_scanpos = xsp;
if (jj_3R_117()) {
jj_scanpos = xsp;
if (jj_3R_118()) return true;
}
}
if (jj_3R_81()) return true;
return false;
}
final private boolean jj_3R_107() {
if (jj_scan_token(ESCAPE)) return true;
return false;
}
final private boolean jj_3R_50() {
if (jj_3R_81()) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_82()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_88() {
if (jj_scan_token(FOREACH)) return true;
return false;
}
final private boolean jj_3R_176() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(94)) {
jj_scanpos = xsp;
if (jj_scan_token(95)) {
jj_scanpos = xsp;
if (jj_scan_token(96)) {
jj_scanpos = xsp;
if (jj_scan_token(97)) {
jj_scanpos = xsp;
if (jj_scan_token(83)) {
jj_scanpos = xsp;
if (jj_scan_token(84)) {
jj_scanpos = xsp;
if (jj_scan_token(117)) {
jj_scanpos = xsp;
if (jj_scan_token(118)) {
jj_scanpos = xsp;
if (jj_scan_token(119)) return true;
}
}
}
}
}
}
}
}
return false;
}
final private boolean jj_3R_27() {
if (jj_scan_token(DEFAUL)) return true;
return false;
}
final private boolean jj_3R_26() {
if (jj_scan_token(CASE)) return true;
if (jj_3R_23()) return true;
return false;
}
final private boolean jj_3R_91() {
if (jj_scan_token(IMPORT)) return true;
return false;
}
final private boolean jj_3R_169() {
if (jj_scan_token(DOT)) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(120)) {
jj_scanpos = xsp;
if (jj_scan_token(100)) {
jj_scanpos = xsp;
if (jj_scan_token(101)) {
jj_scanpos = xsp;
if (jj_3R_176()) return true;
}
}
}
return false;
}
final private boolean jj_3R_24() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(68)) jj_scanpos = xsp;
xsp = jj_scanpos;
if (jj_3R_26()) {
jj_scanpos = xsp;
if (jj_3R_27()) return true;
}
if (jj_3R_28()) return true;
return false;
}
final private boolean jj_3_2() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(98)) {
jj_scanpos = xsp;
if (jj_scan_token(99)) return true;
}
return false;
}
final private boolean jj_3R_84() {
if (jj_scan_token(MINUS)) return true;
return false;
}
final private boolean jj_3R_83() {
if (jj_scan_token(PLUS)) return true;
return false;
}
final private boolean jj_3R_87() {
if (jj_scan_token(LIST)) return true;
return false;
}
final private boolean jj_3R_51() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_83()) {
jj_scanpos = xsp;
if (jj_3R_84()) return true;
}
if (jj_3R_50()) return true;
return false;
}
final private boolean jj_3R_44() {
if (jj_3R_50()) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_51()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_172() {
if (jj_scan_token(BUILT_IN)) return true;
if (jj_scan_token(ID)) return true;
return false;
}
final private boolean jj_3_15() {
if (jj_3R_24()) return true;
return false;
}
final private boolean jj_3R_90() {
if (jj_scan_token(_INCLUDE)) return true;
return false;
}
final private boolean jj_3R_136() {
if (jj_scan_token(MINUS)) return true;
return false;
}
final private boolean jj_3R_99() {
if (jj_scan_token(SWITCH)) return true;
return false;
}
final private boolean jj_3R_174() {
if (jj_scan_token(EXISTS)) return true;
return false;
}
final private boolean jj_3R_133() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(98)) {
jj_scanpos = xsp;
if (jj_3R_136()) return true;
}
if (jj_3R_135()) return true;
return false;
}
final private boolean jj_3_10() {
if (jj_3R_23()) return true;
return false;
}
final private boolean jj_3R_112() {
if (jj_scan_token(ATTEMPT)) return true;
return false;
}
final private boolean jj_3R_178() {
if (jj_3R_23()) return true;
return false;
}
final private boolean jj_3R_137() {
if (jj_scan_token(EXCLAM)) return true;
return false;
}
final private boolean jj_3R_177() {
if (jj_scan_token(EXCLAM)) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_178()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_134() {
Token xsp;
if (jj_3R_137()) return true;
while (true) {
xsp = jj_scanpos;
if (jj_3R_137()) { jj_scanpos = xsp; break; }
}
if (jj_3R_135()) return true;
return false;
}
final private boolean jj_3R_173() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(128)) {
jj_scanpos = xsp;
if (jj_3R_177()) return true;
}
return false;
}
final private boolean jj_3R_98() {
if (jj_scan_token(TRANSFORM)) return true;
return false;
}
final private boolean jj_3R_31() {
if (jj_3R_34()) return true;
return false;
}
final private boolean jj_3_11() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(108)) jj_scanpos = xsp;
xsp = jj_scanpos;
if (jj_scan_token(120)) {
jj_scanpos = xsp;
if (jj_scan_token(81)) return true;
}
if (jj_scan_token(EQUALS)) return true;
return false;
}
final private boolean jj_3R_28() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_31()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_166() {
if (jj_3R_174()) return true;
return false;
}
final private boolean jj_3R_165() {
if (jj_3R_173()) return true;
return false;
}
final private boolean jj_3R_164() {
if (jj_3R_172()) return true;
return false;
}
final private boolean jj_3R_163() {
if (jj_3R_171()) return true;
return false;
}
final private boolean jj_3R_162() {
if (jj_3R_170()) return true;
return false;
}
final private boolean jj_3R_161() {
if (jj_3R_169()) return true;
return false;
}
final private boolean jj_3R_97() {
if (jj_scan_token(NOPARSE)) return true;
return false;
}
final private boolean jj_3R_155() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_161()) {
jj_scanpos = xsp;
if (jj_3R_162()) {
jj_scanpos = xsp;
if (jj_3R_163()) {
jj_scanpos = xsp;
if (jj_3R_164()) {
jj_scanpos = xsp;
if (jj_3R_165()) {
jj_scanpos = xsp;
if (jj_3R_166()) return true;
}
}
}
}
}
return false;
}
final private boolean jj_3R_86() {
if (jj_scan_token(IF)) return true;
return false;
}
final private boolean jj_3R_115() {
if (jj_3R_135()) return true;
return false;
}
final private boolean jj_3R_114() {
if (jj_3R_134()) return true;
return false;
}
final private boolean jj_3R_113() {
if (jj_3R_133()) return true;
return false;
}
final private boolean jj_3R_81() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_113()) {
jj_scanpos = xsp;
if (jj_3R_114()) {
jj_scanpos = xsp;
if (jj_3R_115()) return true;
}
}
return false;
}
final private boolean jj_3R_96() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(28)) {
jj_scanpos = xsp;
if (jj_scan_token(29)) return true;
}
return false;
}
final private boolean jj_3R_121() {
if (jj_scan_token(LOCALASSIGN)) return true;
return false;
}
final private boolean jj_3R_120() {
if (jj_scan_token(GLOBALASSIGN)) return true;
return false;
}
final private boolean jj_3R_119() {
if (jj_scan_token(ASSIGN)) return true;
return false;
}
final private boolean jj_3R_154() {
if (jj_scan_token(DOT)) return true;
if (jj_scan_token(ID)) return true;
return false;
}
final private boolean jj_3R_89() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_119()) {
jj_scanpos = xsp;
if (jj_3R_120()) {
jj_scanpos = xsp;
if (jj_3R_121()) return true;
}
}
return false;
}
final private boolean jj_3R_175() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(108)) jj_scanpos = xsp;
if (jj_3R_23()) return true;
return false;
}
final private boolean jj_3R_168() {
if (jj_3R_23()) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_175()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_153() {
if (jj_scan_token(OPEN_PAREN)) return true;
if (jj_3R_23()) return true;
if (jj_scan_token(CLOSE_PAREN)) return true;
return false;
}
final private boolean jj_3R_160() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_168()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_43() {
if (jj_3R_49()) return true;
return false;
}
final private boolean jj_3R_42() {
if (jj_3R_48()) return true;
return false;
}
final private boolean jj_3_1() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(87)) {
jj_scanpos = xsp;
if (jj_scan_token(111)) {
jj_scanpos = xsp;
if (jj_scan_token(113)) {
jj_scanpos = xsp;
if (jj_scan_token(89)) {
jj_scanpos = xsp;
if (jj_scan_token(107)) {
jj_scanpos = xsp;
if (jj_scan_token(128)) {
jj_scanpos = xsp;
if (jj_scan_token(90)) return true;
}
}
}
}
}
}
return false;
}
final private boolean jj_3R_41() {
if (jj_3R_47()) return true;
return false;
}
final private boolean jj_3R_40() {
if (jj_3R_46()) return true;
return false;
}
final private boolean jj_3R_129() {
if (jj_scan_token(NOTRIM)) return true;
return false;
}
final private boolean jj_3R_37() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_40()) {
jj_scanpos = xsp;
if (jj_3R_41()) {
jj_scanpos = xsp;
if (jj_3R_42()) {
jj_scanpos = xsp;
if (jj_3R_43()) return true;
}
}
}
return false;
}
final private boolean jj_3R_128() {
if (jj_scan_token(RTRIM)) return true;
return false;
}
final private boolean jj_3R_127() {
if (jj_scan_token(LTRIM)) return true;
return false;
}
final private boolean jj_3R_146() {
if (jj_3R_155()) return true;
return false;
}
final private boolean jj_3R_34() {
Token xsp;
if (jj_3R_37()) return true;
while (true) {
xsp = jj_scanpos;
if (jj_3R_37()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_126() {
if (jj_scan_token(TRIM)) return true;
return false;
}
final private boolean jj_3R_152() {
if (jj_scan_token(ID)) return true;
return false;
}
final private boolean jj_3R_145() {
if (jj_3R_154()) return true;
return false;
}
final private boolean jj_3R_105() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_126()) {
jj_scanpos = xsp;
if (jj_3R_127()) {
jj_scanpos = xsp;
if (jj_3R_128()) {
jj_scanpos = xsp;
if (jj_3R_129()) return true;
}
}
}
return false;
}
final private boolean jj_3R_144() {
if (jj_3R_153()) return true;
return false;
}
final private boolean jj_3R_143() {
if (jj_3R_152()) return true;
return false;
}
final private boolean jj_3R_142() {
if (jj_3R_151()) return true;
return false;
}
final private boolean jj_3R_141() {
if (jj_3R_150()) return true;
return false;
}
final private boolean jj_3R_140() {
if (jj_3R_149()) return true;
return false;
}
final private boolean jj_3R_139() {
if (jj_3R_148()) return true;
return false;
}
final private boolean jj_3R_138() {
if (jj_3R_147()) return true;
return false;
}
final private boolean jj_3R_104() {
if (jj_scan_token(FLUSH)) return true;
return false;
}
final private boolean jj_3_13() {
if (jj_scan_token(OPEN_PAREN)) return true;
return false;
}
final private boolean jj_3R_135() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_138()) {
jj_scanpos = xsp;
if (jj_3R_139()) {
jj_scanpos = xsp;
if (jj_3R_140()) {
jj_scanpos = xsp;
if (jj_3R_141()) {
jj_scanpos = xsp;
if (jj_3R_142()) {
jj_scanpos = xsp;
if (jj_3R_143()) {
jj_scanpos = xsp;
if (jj_3R_144()) {
jj_scanpos = xsp;
if (jj_3R_145()) return true;
}
}
}
}
}
}
}
while (true) {
xsp = jj_scanpos;
if (jj_3R_146()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_147() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(85)) {
jj_scanpos = xsp;
if (jj_scan_token(86)) return true;
}
return false;
}
final private boolean jj_3_14() {
if (jj_scan_token(ID)) return true;
if (jj_scan_token(EQUALS)) return true;
return false;
}
final private boolean jj_3R_151() {
if (jj_scan_token(OPEN_BRACKET)) return true;
if (jj_3R_160()) return true;
if (jj_scan_token(CLOSE_BRACKET)) return true;
return false;
}
final private boolean jj_3R_23() {
if (jj_3R_25()) return true;
return false;
}
final private boolean jj_3R_131() {
if (jj_scan_token(NESTED)) return true;
return false;
}
final private boolean jj_3_16() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(68)) {
jj_scanpos = xsp;
if (jj_scan_token(69)) {
jj_scanpos = xsp;
if (jj_scan_token(70)) return true;
}
}
return false;
}
final private boolean jj_3R_48() {
if (jj_scan_token(NUMERICAL_ESCAPE)) return true;
return false;
}
final private boolean jj_3R_95() {
if (jj_scan_token(CALL)) return true;
return false;
}
final private boolean jj_3_9() {
if (jj_scan_token(OR)) return true;
return false;
}
final private boolean jj_3R_85() {
if (jj_scan_token(WHITESPACE)) return true;
return false;
}
final private boolean jj_3R_130() {
if (jj_scan_token(SIMPLE_NESTED)) return true;
return false;
}
final private boolean jj_3R_53() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_85()) {
jj_scanpos = xsp;
if (jj_scan_token(69)) {
jj_scanpos = xsp;
if (jj_scan_token(70)) return true;
}
}
return false;
}
final private boolean jj_3R_106() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_130()) {
jj_scanpos = xsp;
if (jj_3R_131()) return true;
}
return false;
}
final private boolean jj_3R_46() {
Token xsp;
if (jj_3R_53()) return true;
while (true) {
xsp = jj_scanpos;
if (jj_3R_53()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_30() {
if (jj_scan_token(OR)) return true;
if (jj_3R_29()) return true;
return false;
}
final private boolean jj_3R_25() {
if (jj_3R_29()) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_30()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_47() {
if (jj_scan_token(OUTPUT_ESCAPE)) return true;
return false;
}
final private boolean jj_3R_125() {
if (jj_scan_token(STOP)) return true;
return false;
}
final private boolean jj_3_8() {
if (jj_scan_token(AND)) return true;
return false;
}
final private boolean jj_3R_103() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(47)) {
jj_scanpos = xsp;
if (jj_3R_125()) return true;
}
return false;
}
final private boolean jj_3R_80() {
if (jj_3R_112()) return true;
return false;
}
final private boolean jj_3R_79() {
if (jj_3R_111()) return true;
return false;
}
final private boolean jj_3R_78() {
if (jj_3R_110()) return true;
return false;
}
final private boolean jj_3R_33() {
if (jj_scan_token(AND)) return true;
if (jj_3R_32()) return true;
return false;
}
final private boolean jj_3R_77() {
if (jj_3R_109()) return true;
return false;
}
final private boolean jj_3R_76() {
if (jj_3R_108()) return true;
return false;
}
final private boolean jj_3R_75() {
if (jj_3R_107()) return true;
return false;
}
final private boolean jj_3R_29() {
if (jj_3R_32()) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_33()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3_12() {
if (jj_scan_token(ID)) return true;
if (jj_scan_token(EQUALS)) return true;
return false;
}
final private boolean jj_3R_74() {
if (jj_3R_106()) return true;
return false;
}
final private boolean jj_3R_73() {
if (jj_3R_105()) return true;
return false;
}
final private boolean jj_3R_167() {
if (jj_scan_token(COMMA)) return true;
if (jj_3R_23()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(108)) {
jj_scanpos = xsp;
if (jj_scan_token(110)) return true;
}
if (jj_3R_23()) return true;
return false;
}
final private boolean jj_3R_72() {
if (jj_3R_104()) return true;
return false;
}
final private boolean jj_3R_71() {
if (jj_3R_103()) return true;
return false;
}
final private boolean jj_3R_70() {
if (jj_3R_102()) return true;
return false;
}
final private boolean jj_3R_69() {
if (jj_3R_101()) return true;
return false;
}
final private boolean jj_3R_68() {
if (jj_3R_100()) return true;
return false;
}
final private boolean jj_3_6() {
if (jj_3R_23()) return true;
return false;
}
final private boolean jj_3R_67() {
if (jj_3R_99()) return true;
return false;
}
final private boolean jj_3R_156() {
if (jj_3R_23()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(108)) {
jj_scanpos = xsp;
if (jj_scan_token(110)) return true;
}
if (jj_3R_23()) return true;
while (true) {
xsp = jj_scanpos;
if (jj_3R_167()) { jj_scanpos = xsp; break; }
}
return false;
}
final private boolean jj_3R_66() {
if (jj_3R_98()) return true;
return false;
}
final private boolean jj_3R_65() {
if (jj_3R_97()) return true;
return false;
}
final private boolean jj_3_7() {
if (jj_scan_token(DOT_DOT)) return true;
return false;
}
final private boolean jj_3R_64() {
if (jj_3R_96()) return true;
return false;
}
final private boolean jj_3R_148() {
if (jj_scan_token(OPEN_BRACE)) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_156()) jj_scanpos = xsp;
if (jj_scan_token(CLOSE_BRACE)) return true;
return false;
}
final private boolean jj_3R_124() {
if (jj_scan_token(RETURN)) return true;
return false;
}
final private boolean jj_3R_94() {
if (jj_scan_token(UNIFIED_CALL)) return true;
return false;
}
final private boolean jj_3R_63() {
if (jj_3R_95()) return true;
return false;
}
final private boolean jj_3R_123() {
if (jj_scan_token(SIMPLE_RETURN)) return true;
return false;
}
final private boolean jj_3R_52() {
if (jj_3R_44()) return true;
return false;
}
final private boolean jj_3R_62() {
if (jj_3R_94()) return true;
return false;
}
final private boolean jj_3R_61() {
if (jj_3R_93()) return true;
return false;
}
final private boolean jj_3R_102() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_123()) {
jj_scanpos = xsp;
if (jj_3R_124()) return true;
}
return false;
}
final private boolean jj_3R_60() {
if (jj_3R_92()) return true;
return false;
}
final private boolean jj_3R_45() {
if (jj_scan_token(DOT_DOT)) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_52()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_59() {
if (jj_3R_91()) return true;
return false;
}
final private boolean jj_3R_58() {
if (jj_3R_90()) return true;
return false;
}
final private boolean jj_3R_38() {
if (jj_3R_44()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_45()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_159() {
if (jj_scan_token(TRUE)) return true;
return false;
}
final private boolean jj_3R_57() {
if (jj_3R_89()) return true;
return false;
}
final private boolean jj_3R_158() {
if (jj_scan_token(FALSE)) return true;
return false;
}
final private boolean jj_3R_56() {
if (jj_3R_88()) return true;
return false;
}
final private boolean jj_3R_55() {
if (jj_3R_87()) return true;
return false;
}
final private boolean jj_3R_54() {
if (jj_3R_86()) return true;
return false;
}
final private boolean jj_3R_150() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_158()) {
jj_scanpos = xsp;
if (jj_3R_159()) return true;
}
return false;
}
final private boolean jj_3R_93() {
if (jj_scan_token(COMPRESS)) return true;
return false;
}
final private boolean jj_3R_49() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_54()) {
jj_scanpos = xsp;
if (jj_3R_55()) {
jj_scanpos = xsp;
if (jj_3R_56()) {
jj_scanpos = xsp;
if (jj_3R_57()) {
jj_scanpos = xsp;
if (jj_3R_58()) {
jj_scanpos = xsp;
if (jj_3R_59()) {
jj_scanpos = xsp;
if (jj_3R_60()) {
jj_scanpos = xsp;
if (jj_3R_61()) {
jj_scanpos = xsp;
if (jj_3R_62()) {
jj_scanpos = xsp;
if (jj_3R_63()) {
jj_scanpos = xsp;
if (jj_3R_64()) {
jj_scanpos = xsp;
if (jj_3R_65()) {
jj_scanpos = xsp;
if (jj_3R_66()) {
jj_scanpos = xsp;
if (jj_3R_67()) {
jj_scanpos = xsp;
if (jj_3R_68()) {
jj_scanpos = xsp;
if (jj_3R_69()) {
jj_scanpos = xsp;
if (jj_3R_70()) {
jj_scanpos = xsp;
if (jj_3R_71()) {
jj_scanpos = xsp;
if (jj_3R_72()) {
jj_scanpos = xsp;
if (jj_3R_73()) {
jj_scanpos = xsp;
if (jj_3R_74()) {
jj_scanpos = xsp;
if (jj_3R_75()) {
jj_scanpos = xsp;
if (jj_3R_76()) {
jj_scanpos = xsp;
if (jj_3R_77()) {
jj_scanpos = xsp;
if (jj_3R_78()) {
jj_scanpos = xsp;
if (jj_3R_79()) {
jj_scanpos = xsp;
if (jj_3R_80()) return true;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return false;
}
final private boolean jj_3R_101() {
if (jj_scan_token(BREAK)) return true;
return false;
}
final private boolean jj_3_5() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(126)) {
jj_scanpos = xsp;
if (jj_scan_token(97)) {
jj_scanpos = xsp;
if (jj_scan_token(125)) {
jj_scanpos = xsp;
if (jj_scan_token(96)) {
jj_scanpos = xsp;
if (jj_scan_token(95)) {
jj_scanpos = xsp;
if (jj_scan_token(95)) {
jj_scanpos = xsp;
if (jj_scan_token(94)) return true;
}
}
}
}
}
}
return false;
}
final private boolean jj_3R_100() {
if (jj_scan_token(SETTING)) return true;
return false;
}
final private boolean jj_3R_39() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(126)) {
jj_scanpos = xsp;
if (jj_scan_token(97)) {
jj_scanpos = xsp;
if (jj_scan_token(125)) {
jj_scanpos = xsp;
if (jj_scan_token(96)) {
jj_scanpos = xsp;
if (jj_scan_token(95)) {
jj_scanpos = xsp;
if (jj_scan_token(94)) return true;
}
}
}
}
}
if (jj_3R_38()) return true;
return false;
}
final private boolean jj_3R_157() {
if (jj_scan_token(RAW_STRING)) return true;
return false;
}
final private boolean jj_3R_35() {
if (jj_3R_38()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_39()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_111() {
if (jj_scan_token(FALLBACK)) return true;
return false;
}
final private boolean jj_3R_149() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(81)) {
jj_scanpos = xsp;
if (jj_3R_157()) return true;
}
return false;
}
final private boolean jj_3_17() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(68)) jj_scanpos = xsp;
xsp = jj_scanpos;
if (jj_scan_token(66)) {
jj_scanpos = xsp;
if (jj_scan_token(65)) return true;
}
return false;
}
final private boolean jj_3_4() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(93)) {
jj_scanpos = xsp;
if (jj_scan_token(91)) {
jj_scanpos = xsp;
if (jj_scan_token(92)) return true;
}
}
return false;
}
final private boolean jj_3R_171() {
if (jj_scan_token(OPEN_PAREN)) return true;
if (jj_3R_160()) return true;
if (jj_scan_token(CLOSE_PAREN)) return true;
return false;
}
final private boolean jj_3R_36() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(93)) {
jj_scanpos = xsp;
if (jj_scan_token(91)) {
jj_scanpos = xsp;
if (jj_scan_token(92)) return true;
}
}
if (jj_3R_35()) return true;
return false;
}
final private boolean jj_3R_132() {
if (jj_scan_token(RECURSE)) return true;
return false;
}
public FMParserTokenManager token_source;
SimpleCharStream jj_input_stream;
public Token token, jj_nt;
private int jj_ntk;
private Token jj_scanpos, jj_lastpos;
private int jj_la;
public boolean lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
final private int[] jj_la1 = new int[83];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static private int[] jj_la1_2;
static private int[] jj_la1_3;
static private int[] jj_la1_4;
static {
jj_la1_0();
jj_la1_1();
jj_la1_2();
jj_la1_3();
jj_la1_4();
}
private static void jj_la1_0() {
jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x800000,0x0,0x0,0x1c000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x7fffdd40,0x0,0x0,0x0,0x7fffdd40,0x7fffdd40,0x0,0x0,0x7fffdd40,0x0,0x0,0x0,0x0,0x0,};
}
private static void jj_la1_1() {
jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x6,0x0,0x0,0x0,0x3000000,0x4000,0x8000,0xc00000,0x1e0000,0x0,0x0,0x0,0x0,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0xafdfe000,0x0,0x0,0x0,0xafdfe000,0xafdfe000,0x0,0x0,0xafdfe000,0x0,0x0,0x0,0x0,0x0,};
}
private static void jj_la1_2() {
jj_la1_2 = new int[] {0xfe0000,0xfe0000,0x0,0x0,0x0,0x0,0x38000000,0xc0000000,0x600000,0x60000,0x6800000,0x0,0xc0180000,0xc0180000,0x60000,0x180000,0x0,0x0,0x0,0xfe0000,0x0,0x0,0x0,0x0,0x0,0xfe0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe0000,0x0,0xfe0000,0x0,0x0,0x0,0x0,0x10,0x10,0x0,0x0,0x0,0x70,0x0,0x0,0x1f0,0x1f0,0x1f0,0x1f0,0x1f0,0x10,0x0,0x6,0x0,0x0,};
}
private static void jj_la1_3() {
jj_la1_3 = new int[] {0x10a8000,0x10a880c,0x800,0xc,0xc,0x190,0x0,0x60000003,0x0,0x1000000,0x28800,0x800,0xe00003,0x1e00033,0x0,0x0,0x5000,0x1000,0x5000,0x10a880c,0x2000,0x0,0x0,0x0,0x800000,0x10a880c,0x800000,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x200000,0x200000,0x0,0x8200000,0x2000,0x1000000,0x0,0x20000,0x1000000,0x40,0x0,0x1000,0x40000,0x0,0x80000000,0x80000000,0x80001000,0x80000000,0x80000000,0x81000000,0x2000,0x18000000,0x40000,0x1000000,0x10a980c,0x1000,0x10a880c,0x0,0x2000,0x1000000,0x18000000,0x0,0x0,0x0,0x18000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x0,0x1000,0x1000000,};
}
private static void jj_la1_4() {
jj_la1_4 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e,0x1e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[17];
private boolean jj_rescan = false;
private int jj_gc = 0;
public FMParser(java.io.InputStream stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new FMParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 83; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
public void ReInit(java.io.InputStream stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 83; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
public FMParser(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new FMParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 83; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 83; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
public FMParser(FMParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 83; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
public void ReInit(FMParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 83; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
final private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
if (++jj_gc > 100) {
jj_gc = 0;
for (int i = 0; i < jj_2_rtns.length; i++) {
JJCalls c = jj_2_rtns[i];
while (c != null) {
if (c.gen < jj_gen) c.first = null;
c = c.next;
}
}
}
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
static private final class LookaheadSuccess extends java.lang.Error { }
final private LookaheadSuccess jj_ls = new LookaheadSuccess();
final private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_scanpos.next;
}
if (jj_rescan) {
int i = 0; Token tok = token;
while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
if (tok != null) jj_add_error_token(kind, i);
}
if (jj_scanpos.kind != kind) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
return false;
}
final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
final public Token getToken(int index) {
Token t = lookingAhead ? jj_scanpos : token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
final private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
private java.util.Vector jj_expentries = new java.util.Vector();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
private int jj_endpos;
private void jj_add_error_token(int kind, int pos) {
if (pos >= 100) return;
if (pos == jj_endpos + 1) {
jj_lasttokens[jj_endpos++] = kind;
} else if (jj_endpos != 0) {
jj_expentry = new int[jj_endpos];
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
boolean exists = false;
for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
int[] oldentry = (int[])(e.nextElement());
if (oldentry.length == jj_expentry.length) {
exists = true;
for (int i = 0; i < jj_expentry.length; i++) {
if (oldentry[i] != jj_expentry[i]) {
exists = false;
break;
}
}
if (exists) break;
}
}
if (!exists) jj_expentries.addElement(jj_expentry);
if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
}
}
public ParseException generateParseException() {
jj_expentries.removeAllElements();
boolean[] la1tokens = new boolean[133];
for (int i = 0; i < 133; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 83; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1< jj_gen) {
jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
switch (i) {
case 0: jj_3_1(); break;
case 1: jj_3_2(); break;
case 2: jj_3_3(); break;
case 3: jj_3_4(); break;
case 4: jj_3_5(); break;
case 5: jj_3_6(); break;
case 6: jj_3_7(); break;
case 7: jj_3_8(); break;
case 8: jj_3_9(); break;
case 9: jj_3_10(); break;
case 10: jj_3_11(); break;
case 11: jj_3_12(); break;
case 12: jj_3_13(); break;
case 13: jj_3_14(); break;
case 14: jj_3_15(); break;
case 15: jj_3_16(); break;
case 16: jj_3_17(); break;
}
}
p = p.next;
} while (p != null);
}
jj_rescan = false;
}
final private void jj_save(int index, int xla) {
JJCalls p = jj_2_rtns[index];
while (p.gen > jj_gen) {
if (p.next == null) { p = p.next = new JJCalls(); break; }
p = p.next;
}
p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
}
static final class JJCalls {
int gen;
Token first;
int arg;
JJCalls next;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/SequenceBuiltins.java 0000644 0001750 0001750 00000107646 11723544471 025643 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.Serializable;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import freemarker.ext.beans.CollectionModel;
import freemarker.template.SimpleNumber;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateDateModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateHashModel;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateModelListSequence;
import freemarker.template.TemplateNumberModel;
import freemarker.template.TemplateScalarModel;
import freemarker.template.TemplateSequenceModel;
import freemarker.template.TemplateCollectionModel;
import freemarker.template.TemplateModelIterator;
import freemarker.template.utility.Constants;
import freemarker.template.utility.StringUtil;
/**
* A holder for builtins that operate exclusively on TemplateSequenceModels.
*/
abstract class SequenceBuiltins {
abstract static class SequenceBuiltIn extends BuiltIn {
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException
{
TemplateModel model = target.getAsTemplateModel(env);
if (!(model instanceof TemplateSequenceModel)) {
throw invalidTypeException(model, target, env, "sequence");
}
return calculateResult((TemplateSequenceModel) model);
}
abstract TemplateModel calculateResult(TemplateSequenceModel tsm)
throws
TemplateModelException;
}
static class firstBI extends SequenceBuiltIn {
TemplateModel calculateResult(TemplateSequenceModel tsm)
throws
TemplateModelException
{
if (tsm.size() == 0) {
return null;
}
return tsm.get(0);
}
}
static class lastBI extends SequenceBuiltIn {
TemplateModel calculateResult(TemplateSequenceModel tsm)
throws
TemplateModelException
{
if (tsm.size() == 0) {
return null;
}
return tsm.get(tsm.size() -1);
}
}
static class reverseBI extends SequenceBuiltIn {
TemplateModel calculateResult(TemplateSequenceModel tsm) {
if (tsm instanceof ReverseSequence) {
return ((ReverseSequence) tsm).seq;
} else {
return new ReverseSequence(tsm);
}
}
private static class ReverseSequence implements TemplateSequenceModel
{
private final TemplateSequenceModel seq;
ReverseSequence(TemplateSequenceModel seq)
{
this.seq = seq;
}
public int size() throws TemplateModelException
{
return seq.size();
}
public TemplateModel get(int index) throws TemplateModelException
{
return seq.get(seq.size() - 1 - index);
}
}
}
static class sortBI extends SequenceBuiltIn {
static final int KEY_TYPE_NOT_YET_DETECTED = 0;
static final int KEY_TYPE_STRING = 1;
static final int KEY_TYPE_NUMBER = 2;
static final int KEY_TYPE_DATE = 3;
static final int KEY_TYPE_BOOLEAN = 4;
TemplateModel calculateResult(TemplateSequenceModel seq)
throws TemplateModelException {
return sort(seq, null);
}
static String startErrorMessage(int keyNamesLn) {
return (keyNamesLn == 0 ? "?sort" : "?sort_by(...)") + " failed: ";
}
static String startErrorMessage(int keyNamesLn, int index) {
return (keyNamesLn == 0 ? "?sort" : "?sort_by(...)")
+ " failed at sequence index " + index
+ (index == 0 ? ": " : " (0-based): ");
}
static TemplateModelException newInconsistentSortKeyTypeException(
int keyNamesLn, String firstType, String firstTypePlural, int index) {
String valueInMsg;
String valuesInMsg;
if (keyNamesLn == 0) {
valueInMsg = "value";
valuesInMsg = "values";
} else {
valueInMsg = "key value";
valuesInMsg = "key values";
}
return new TemplateModelException(
startErrorMessage(keyNamesLn, index)
+ "All " + valuesInMsg + " in the sequence must be "
+ firstTypePlural + ", because the first " + valueInMsg
+ " was that. However, the " + valueInMsg
+ " of the current item isn't a " + firstType + ".");
}
/**
* Sorts a sequence for the sort and sort_by
* built-ins.
*
* @param seq the sequence to sort.
* @param keyNames the name of the subvariable whose value is used for the
* sorting. If the sorting is done by a sub-subvaruable, then this
* will be of length 2, and so on. If the sorting is done by the
* sequene items directly, then this argument has to be 0 length
* array or null
.
* @return a new sorted sequence, or the original sequence if the
* sequence length was 0.
*/
static TemplateSequenceModel sort(TemplateSequenceModel seq, String[] keyNames)
throws TemplateModelException {
int ln = seq.size();
if (ln == 0) return seq;
ArrayList res = new ArrayList(ln);
int keyNamesLn = keyNames == null ? 0 : keyNames.length;
// Copy the Seq into a Java List[KVP] (also detects key type at the 1st item):
int keyType = KEY_TYPE_NOT_YET_DETECTED;
Comparator keyComparator = null;
for (int i = 0; i < ln; i++) {
TemplateModel item = seq.get(i);
Object key = item;
for (int keyNameI = 0; keyNameI < keyNamesLn; keyNameI++) {
try {
key = ((TemplateHashModel) key).get(keyNames[keyNameI]);
} catch (ClassCastException e) {
if (!(key instanceof TemplateHashModel)) {
throw new TemplateModelException(
startErrorMessage(keyNamesLn, i)
+ (keyNameI == 0
? "Sequence items must be hashes when using ?sort_by. "
: "The " + StringUtil.jQuote(keyNames[keyNameI - 1])
+ " subvariable is not a hash, so ?sort_by "
+ "can't proceed with getting the "
+ StringUtil.jQuote(keyNames[keyNameI])
+ " subvariable."));
} else {
throw e;
}
}
if (key == null) {
throw new TemplateModelException(
startErrorMessage(keyNamesLn, i)
+ "The " + StringUtil.jQuote(keyNames[keyNameI])
+ " subvariable was not found.");
}
} // for each key
if (keyType == KEY_TYPE_NOT_YET_DETECTED) {
if (key instanceof TemplateScalarModel) {
keyType = KEY_TYPE_STRING;
keyComparator = new LexicalKVPComparator(
Environment.getCurrentEnvironment().getCollator());
} else if (key instanceof TemplateNumberModel) {
keyType = KEY_TYPE_NUMBER;
keyComparator = new NumericalKVPComparator(
Environment.getCurrentEnvironment()
.getArithmeticEngine());
} else if (key instanceof TemplateDateModel) {
keyType = KEY_TYPE_DATE;
keyComparator = new DateKVPComparator();
} else if (key instanceof TemplateBooleanModel) {
keyType = KEY_TYPE_BOOLEAN;
keyComparator = new BooleanKVPComparator();
} else {
throw new TemplateModelException(
startErrorMessage(keyNamesLn, i)
+ "Values used for sorting must be numbers, strings, "
+ "date/times or booleans.");
}
}
switch(keyType) {
case KEY_TYPE_STRING:
try {
res.add(new KVP(
((TemplateScalarModel) key).getAsString(),
item));
} catch (ClassCastException e) {
if (!(key instanceof TemplateScalarModel)) {
throw newInconsistentSortKeyTypeException(
keyNamesLn, "string", "strings", i);
} else {
throw e;
}
}
break;
case KEY_TYPE_NUMBER:
try {
res.add(new KVP(
((TemplateNumberModel) key).getAsNumber(),
item));
} catch (ClassCastException e) {
if (!(key instanceof TemplateNumberModel)) {
throw newInconsistentSortKeyTypeException(
keyNamesLn, "number", "numbers", i);
}
}
break;
case KEY_TYPE_DATE:
try {
res.add(new KVP(
((TemplateDateModel) key).getAsDate(),
item));
} catch (ClassCastException e) {
if (!(key instanceof TemplateDateModel)) {
throw newInconsistentSortKeyTypeException(
keyNamesLn, "date/time", "date/times", i);
}
}
break;
case KEY_TYPE_BOOLEAN:
try {
res.add(new KVP(
((TemplateBooleanModel) key).getAsBoolean() ?
Boolean.TRUE : Boolean.FALSE,
item));
} catch (ClassCastException e) {
if (!(key instanceof TemplateBooleanModel)) {
throw newInconsistentSortKeyTypeException(
keyNamesLn, "boolean", "booleans", i);
}
}
break;
default:
throw new RuntimeException("FreeMarker bug: Unexpected key type");
}
}
// Sort tje List[KVP]:
try {
Collections.sort(res, keyComparator);
} catch (Exception exc) {
throw new TemplateModelException(
startErrorMessage(keyNamesLn)
+ "Unexpected error while sorting:" + exc, exc);
}
// Convert the List[KVP] to List[V]:
for (int i = 0; i < ln; i++) {
res.set(i, ((KVP) res.get(i)).value);
}
return new TemplateModelListSequence(res);
}
/**
* Stores a key-value pair.
*/
private static class KVP {
private KVP(Object key, Object value) {
this.key = key;
this.value = value;
}
private Object key;
private Object value;
}
private static class NumericalKVPComparator implements Comparator {
private ArithmeticEngine ae;
private NumericalKVPComparator(ArithmeticEngine ae) {
this.ae = ae;
}
public int compare(Object arg0, Object arg1) {
try {
return ae.compareNumbers(
(Number) ((KVP) arg0).key,
(Number) ((KVP) arg1).key);
} catch (TemplateException e) {
throw new ClassCastException(
"Failed to compare numbers: " + e);
}
}
}
private static class LexicalKVPComparator implements Comparator {
private Collator collator;
LexicalKVPComparator(Collator collator) {
this.collator = collator;
}
public int compare(Object arg0, Object arg1) {
return collator.compare(
((KVP) arg0).key, ((KVP) arg1).key);
}
}
private static class DateKVPComparator implements Comparator, Serializable {
public int compare(Object arg0, Object arg1) {
return ((Date) ((KVP) arg0).key).compareTo(
(Date) ((KVP) arg1).key);
}
}
private static class BooleanKVPComparator implements Comparator, Serializable {
public int compare(Object arg0, Object arg1) {
// JDK 1.2 doesn't have Boolean.compareTo
boolean b0 = ((Boolean) ((KVP) arg0).key).booleanValue();
boolean b1 = ((Boolean) ((KVP) arg1).key).booleanValue();
if (b0) {
return b1 ? 0 : 1;
} else {
return b1 ? -1 : 0;
}
}
}
}
static class sort_byBI extends sortBI {
TemplateModel calculateResult(TemplateSequenceModel seq) {
return new BIMethod(seq);
}
static class BIMethod implements TemplateMethodModelEx {
TemplateSequenceModel seq;
BIMethod(TemplateSequenceModel seq) {
this.seq = seq;
}
public Object exec(List params)
throws TemplateModelException {
if (params.size() == 0) {
throw new TemplateModelException(
"?sort_by(key) needs exactly 1 argument.");
}
String[] subvars;
Object obj = params.get(0);
if (obj instanceof TemplateScalarModel) {
subvars = new String[]{((TemplateScalarModel) obj).getAsString()};
} else if (obj instanceof TemplateSequenceModel) {
TemplateSequenceModel seq = (TemplateSequenceModel) obj;
int ln = seq.size();
subvars = new String[ln];
for (int i = 0; i < ln; i++) {
Object item = seq.get(i);
try {
subvars[i] = ((TemplateScalarModel) item)
.getAsString();
} catch (ClassCastException e) {
if (!(item instanceof TemplateScalarModel)) {
throw new TemplateModelException(
"The argument to ?sort_by(key), when it "
+ "is a sequence, must be a sequence of "
+ "strings, but the item at index " + i
+ " is not a string." );
}
}
}
} else {
throw new TemplateModelException(
"The argument to ?sort_by(key) must be a string "
+ "(the name of the subvariable), or a sequence of "
+ "strings (the \"path\" to the subvariable).");
}
return sort(seq, subvars);
}
}
}
private static boolean isBuggySeqButGoodCollection(
TemplateModel model) {
return model instanceof CollectionModel
? !((CollectionModel) model).getSupportsIndexedAccess()
: false;
}
static class seq_containsBI extends BuiltIn {
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException {
TemplateModel model = target.getAsTemplateModel(env);
// In 2.3.x only, we prefer TemplateSequenceModel for
// backward compatibility. In 2.4.x, we prefer TemplateCollectionModel.
if (model instanceof TemplateSequenceModel && !isBuggySeqButGoodCollection(model)) {
return new BIMethodForSequence((TemplateSequenceModel) model, env);
} else if (model instanceof TemplateCollectionModel) {
return new BIMethodForCollection((TemplateCollectionModel) model, env);
} else {
throw invalidTypeException(model, target, env, "sequence or collection");
}
}
private static class BIMethodForSequence implements TemplateMethodModelEx {
private TemplateSequenceModel m_seq;
private Environment m_env;
private BIMethodForSequence(TemplateSequenceModel seq, Environment env) {
m_seq = seq;
m_env = env;
}
public Object exec(List args)
throws TemplateModelException {
if (args.size() != 1)
throw new TemplateModelException("?seq_contains(...) expects one argument.");
TemplateModel arg = (TemplateModel) args.get(0);
int size = m_seq.size();
for (int i = 0; i < size; i++) {
if (modelsEqual(m_seq.get(i), arg, m_env))
return TemplateBooleanModel.TRUE;
}
return TemplateBooleanModel.FALSE;
}
}
private static class BIMethodForCollection implements TemplateMethodModelEx {
private TemplateCollectionModel m_coll;
private Environment m_env;
private BIMethodForCollection(TemplateCollectionModel coll, Environment env) {
m_coll = coll;
m_env = env;
}
public Object exec(List args)
throws TemplateModelException {
if (args.size() != 1)
throw new TemplateModelException("?seq_contains(...) expects one argument.");
TemplateModel arg = (TemplateModel) args.get(0);
TemplateModelIterator it = m_coll.iterator();
while (it.hasNext()) {
if (modelsEqual(it.next(), arg, m_env))
return TemplateBooleanModel.TRUE;
}
return TemplateBooleanModel.FALSE;
}
}
}
static class seq_index_ofBI extends BuiltIn {
private int m_dir;
public seq_index_ofBI(int dir) {
m_dir = dir;
}
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException {
return new BIMethod(env);
}
private class BIMethod implements TemplateMethodModelEx {
protected final TemplateSequenceModel m_seq;
protected final TemplateCollectionModel m_col;
protected final Environment m_env;
private BIMethod(Environment env)
throws TemplateException {
TemplateModel model = target.getAsTemplateModel(env);
m_seq = model instanceof TemplateSequenceModel
&& !isBuggySeqButGoodCollection(model)
? (TemplateSequenceModel) model
: null;
// In 2.3.x only, we deny the possibility of collection
// access if there's sequence access. This is so to minimize
// the change of compatibility issues; without this, objects
// that implement both the sequence and collection interfaces
// would suddenly start using the collection interface, and if
// that's buggy that would surface now, breaking the application
// that despite its bugs has worked earlier.
m_col = m_seq == null && model instanceof TemplateCollectionModel
? (TemplateCollectionModel) model
: null;
if (m_seq == null && m_col == null) {
throw invalidTypeException(
model, target, env, "sequence or collection");
}
m_env = env;
}
public final Object exec(List args)
throws TemplateModelException {
int argcnt = args.size();
if (argcnt != 1 && argcnt != 2) {
throw new TemplateModelException(
getBuiltinTemplate() + " expects 1 or 2 arguments.");
}
TemplateModel target = (TemplateModel) args.get(0);
int foundAtIdx;
if (argcnt > 1) {
Object obj = args.get(1);
if (!(obj instanceof TemplateNumberModel)) {
throw new TemplateModelException(
getBuiltinTemplate()
+ "expects a number as its second argument.");
}
int startIndex = ((TemplateNumberModel) obj).getAsNumber().intValue();
// In 2.3.x only, we prefer TemplateSequenceModel for
// backward compatibility:
foundAtIdx = m_seq != null
? findInSeq(target, startIndex)
: findInCol(target, startIndex);
} else {
// In 2.3.x only, we prefer TemplateSequenceModel for
// backward compatibility:
foundAtIdx = m_seq != null
? findInSeq(target)
: findInCol(target);
}
return foundAtIdx == -1 ? Constants.MINUS_ONE : new SimpleNumber(foundAtIdx);
}
private final String getBuiltinTemplate() {
return m_dir == 1 ? "?seq_index_of(...)" : "?seq_last_index_of(...)";
}
public int findInSeq(TemplateModel target)
throws TemplateModelException {
final int seqSize = m_seq.size();
final int actualStartIndex;
if (m_dir == 1) {
actualStartIndex = 0;
} else {
actualStartIndex = seqSize - 1;
}
return findInSeq(target, actualStartIndex, seqSize);
}
private int findInSeq(TemplateModel target, int startIndex)
throws TemplateModelException {
int seqSize = m_seq.size();
if (m_dir == 1) {
if (startIndex >= seqSize) {
return -1;
}
if (startIndex < 0) {
startIndex = 0;
}
} else {
if (startIndex >= seqSize) {
startIndex = seqSize - 1;
}
if (startIndex < 0) {
return -1;
}
}
return findInSeq(target, startIndex, seqSize);
}
private int findInSeq(
TemplateModel target, int scanStartIndex, int seqSize)
throws TemplateModelException {
if (m_dir == 1) {
for (int i = scanStartIndex; i < seqSize; i++) {
if (modelsEqual(m_seq.get(i), target, m_env)) return i;
}
} else {
for (int i = scanStartIndex; i >= 0; i--) {
if (modelsEqual(m_seq.get(i), target, m_env)) return i;
}
}
return -1;
}
public int findInCol(TemplateModel target) throws TemplateModelException {
return findInCol(target, 0, Integer.MAX_VALUE);
}
protected int findInCol(TemplateModel target, int startIndex)
throws TemplateModelException {
if (m_dir == 1) {
return findInCol(target, startIndex, Integer.MAX_VALUE);
} else {
return findInCol(target, 0, startIndex);
}
}
protected int findInCol(TemplateModel target,
final int allowedRangeStart, final int allowedRangeEnd)
throws TemplateModelException {
if (allowedRangeEnd < 0) return -1;
TemplateModelIterator it = m_col.iterator();
int foundAtIdx = -1; // -1 is the return value for "not found"
int idx = 0;
searchItem: while (it.hasNext()) {
if (idx > allowedRangeEnd) break searchItem;
TemplateModel current = it.next();
if (idx >= allowedRangeStart) {
if (modelsEqual(current, target, m_env)) {
foundAtIdx = idx;
if (m_dir == 1) break searchItem; // "find first"
// Otherwise it's "find last".
}
}
idx++;
}
return foundAtIdx;
}
}
}
static class chunkBI extends SequenceBuiltIn {
TemplateModel calculateResult(TemplateSequenceModel tsm) throws TemplateModelException {
return new BIMethod(tsm);
}
private static class BIMethod implements TemplateMethodModelEx {
private final TemplateSequenceModel tsm;
private BIMethod(TemplateSequenceModel tsm) {
this.tsm = tsm;
}
public Object exec(List args) throws TemplateModelException {
int numArgs = args.size();
if (numArgs != 1 && numArgs !=2) {
throw new TemplateModelException(
"?chunk(...) expects 1 or 2 arguments.");
}
Object chunkSize = args.get(0);
if (!(chunkSize instanceof TemplateNumberModel)) {
throw new TemplateModelException(
"?chunk(...) expects a number as "
+ "its 1st argument.");
}
return new ChunkedSequence(
tsm,
((TemplateNumberModel) chunkSize).getAsNumber().intValue(),
numArgs > 1 ? (TemplateModel) args.get(1) : null);
}
}
private static class ChunkedSequence implements TemplateSequenceModel {
private final TemplateSequenceModel wrappedTsm;
private final int chunkSize;
private final TemplateModel fillerItem;
private final int numberOfChunks;
private ChunkedSequence(
TemplateSequenceModel wrappedTsm, int chunkSize, TemplateModel fillerItem)
throws TemplateModelException {
if (chunkSize < 1) {
throw new TemplateModelException(
"The 1st argument to ?chunk(...) must be at least 1.");
}
this.wrappedTsm = wrappedTsm;
this.chunkSize = chunkSize;
this.fillerItem = fillerItem;
numberOfChunks = (wrappedTsm.size() + chunkSize - 1) / chunkSize;
}
public TemplateModel get(final int chunkIndex)
throws TemplateModelException {
if (chunkIndex >= numberOfChunks) {
return null;
}
return new TemplateSequenceModel() {
private final int baseIndex = chunkIndex * chunkSize;
public TemplateModel get(int relIndex)
throws TemplateModelException {
int absIndex = baseIndex + relIndex;
if (absIndex < wrappedTsm.size()) {
return wrappedTsm.get(absIndex);
} else {
return absIndex < numberOfChunks * chunkSize
? fillerItem
: null;
}
}
public int size() throws TemplateModelException {
return fillerItem != null || chunkIndex + 1 < numberOfChunks
? chunkSize
: wrappedTsm.size() - baseIndex;
}
};
}
public int size() throws TemplateModelException {
return numberOfChunks;
}
}
}
/*
* WARNING! This algorithm is duplication of ComparisonExpression.isTrue(...).
* Thus, if you update this method, then you have to update that too!
*/
public static boolean modelsEqual(TemplateModel model1, TemplateModel model2,
Environment env)
throws TemplateModelException {
if (env.isClassicCompatible()) {
if (model1 == null) {
model1 = TemplateScalarModel.EMPTY_STRING;
}
if (model2 == null) {
model2 = TemplateScalarModel.EMPTY_STRING;
}
}
int comp = -1;
if(model1 instanceof TemplateNumberModel && model2 instanceof TemplateNumberModel) {
Number first = ((TemplateNumberModel) model1).getAsNumber();
Number second = ((TemplateNumberModel) model2).getAsNumber();
ArithmeticEngine ae = env.getArithmeticEngine();
try {
comp = ae.compareNumbers(first, second);
} catch (TemplateException ex) {
throw new TemplateModelException(ex);
}
}
else if(model1 instanceof TemplateDateModel && model2 instanceof TemplateDateModel) {
TemplateDateModel ltdm = (TemplateDateModel)model1;
TemplateDateModel rtdm = (TemplateDateModel)model2;
int ltype = ltdm.getDateType();
int rtype = rtdm.getDateType();
if(ltype != rtype) {
throw new TemplateModelException(
"Can not compare dates of different type. Left date is of "
+ TemplateDateModel.TYPE_NAMES.get(ltype)
+ " type, right date is of "
+ TemplateDateModel.TYPE_NAMES.get(rtype) + " type.");
}
if(ltype == TemplateDateModel.UNKNOWN) {
throw new TemplateModelException(
"Left date is of UNKNOWN type, and can not be compared.");
}
if(rtype == TemplateDateModel.UNKNOWN) {
throw new TemplateModelException(
"Right date is of UNKNOWN type, and can not be compared.");
}
Date first = ltdm.getAsDate();
Date second = rtdm.getAsDate();
comp = first.compareTo(second);
}
else if(model1 instanceof TemplateScalarModel && model2 instanceof TemplateScalarModel) {
String first = ((TemplateScalarModel) model1).getAsString();
String second = ((TemplateScalarModel) model2).getAsString();
comp = env.getCollator().compare(first, second);
}
else if(model1 instanceof TemplateBooleanModel && model2 instanceof TemplateBooleanModel) {
boolean first = ((TemplateBooleanModel)model1).getAsBoolean();
boolean second = ((TemplateBooleanModel)model2).getAsBoolean();
comp = (first ? 1 : 0) - (second ? 1 : 0);
}
return (comp == 0);
}
} libfreemarker-java-2.3.19.orig/src/freemarker/core/PropertySetting.java 0000644 0001750 0001750 00000012143 11723544471 025526 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.Template;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateNumberModel;
import freemarker.template.TemplateScalarModel;
/**
* An instruction that sets a property of the template rendering
* environment.
*/
final class PropertySetting extends TemplateElement {
private final String key;
private final Expression value;
PropertySetting(String key, Expression value) {
this.key = key;
this.value = value;
}
void setLocation(Template template, int beginColumn, int beginLine, int endColumn, int endLine)
throws
ParseException
{
super.setLocation(template, beginColumn, beginLine, endColumn, endLine);
if (!key.equals(Configurable.LOCALE_KEY) &&
!key.equals(Configurable.NUMBER_FORMAT_KEY) &&
!key.equals(Configurable.TIME_FORMAT_KEY) &&
!key.equals(Configurable.DATE_FORMAT_KEY) &&
!key.equals(Configurable.DATETIME_FORMAT_KEY) &&
!key.equals(Configurable.TIME_ZONE_KEY) &&
!key.equals(Configurable.BOOLEAN_FORMAT_KEY) &&
!key.equals(Configurable.CLASSIC_COMPATIBLE_KEY) &&
!key.equals(Configurable.URL_ESCAPING_CHARSET_KEY))
{
throw new ParseException(
"Error " + getStartLocation()
+ "\nInvalid setting name, or it is not allowed to change "
+ "the value of the setting with FTL: "
+ key,
beginLine, beginColumn);
}
}
void accept(Environment env) throws TemplateException {
TemplateModel mval = value.getAsTemplateModel(env);
String strval;
if (mval instanceof TemplateScalarModel) {
strval = ((TemplateScalarModel) mval).getAsString();
} else if (mval instanceof TemplateBooleanModel) {
strval = ((TemplateBooleanModel) mval).getAsBoolean() ? "true" : "false";
} else if (mval instanceof TemplateNumberModel) {
strval = ((TemplateNumberModel) mval).getAsNumber().toString();
} else {
strval = value.getStringValue(env);
}
env.setSetting(key, strval);
}
public String getCanonicalForm() {
return "<#setting " + key + "=" + value.getCanonicalForm() + "/>";
}
public String getDescription() {
return "setting " + key + " set to " + "\"" + value + "\" "
+ "[" + getStartLocation() + "]";
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/IteratorBlock.java 0000644 0001750 0001750 00000020325 11723544467 025116 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import freemarker.template.SimpleNumber;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateCollectionModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelIterator;
import freemarker.template.TemplateSequenceModel;
/**
* An instruction that processes a list or foreach block
*/
final class IteratorBlock extends TemplateElement {
private Expression listExpression;
private String indexName;
private boolean isForEach;
/**
* @param listExpression a variable referring to a sequence or collection
* @param indexName an arbitrary index variable name
* @param nestedBlock the nestedBlock to iterate over
*/
IteratorBlock(Expression listExpression,
String indexName,
TemplateElement nestedBlock,
boolean isForEach)
{
this.listExpression = listExpression;
this.indexName = indexName;
this.isForEach = isForEach;
this.nestedBlock = nestedBlock;
}
void accept(Environment env) throws TemplateException, IOException
{
TemplateModel baseModel = listExpression.getAsTemplateModel(env);
if (baseModel == null) {
if (env.isClassicCompatible()) {
// Classic behavior of simply ignoring null references.
return;
}
assertNonNull(baseModel, listExpression, env);
}
env.visit(new Context(baseModel));
}
public String getCanonicalForm() {
if (isForEach) {
StringBuffer buf = new StringBuffer("<#foreach ");
buf.append(indexName);
buf.append(" in ");
buf.append(listExpression.getCanonicalForm());
buf.append(">");
if (nestedBlock != null) {
buf.append(nestedBlock.getCanonicalForm());
}
buf.append("#foreach>");
return buf.toString();
}
else {
StringBuffer buf = new StringBuffer("<#list ");
buf.append(listExpression.getCanonicalForm());
buf.append(" as ");
buf.append(indexName);
buf.append(">");
if (nestedBlock != null) {
buf.append(nestedBlock.getCanonicalForm());
}
buf.append("#list>");
return buf.toString();
}
}
public String getDescription() {
if (isForEach) {
return "foreach " + indexName + " in " + listExpression;
}
else {
return "list " + listExpression + " as " + indexName;
}
}
/**
* A helper class that holds the context of the loop.
*/
class Context implements LocalContext {
private boolean hasNext;
private TemplateModel loopVar;
private int index;
private Collection variableNames = null;
private TemplateModel list;
Context(TemplateModel list) {
this.list = list;
}
void runLoop(Environment env) throws TemplateException, IOException {
if (list instanceof TemplateCollectionModel) {
TemplateCollectionModel baseListModel = (TemplateCollectionModel)list;
TemplateModelIterator it = baseListModel.iterator();
hasNext = it.hasNext();
while (hasNext) {
loopVar = it.next();
hasNext = it.hasNext();
if (nestedBlock != null) {
env.visit(nestedBlock);
}
index++;
}
}
else if (list instanceof TemplateSequenceModel) {
TemplateSequenceModel tsm = (TemplateSequenceModel) list;
int size = tsm.size();
for (index =0; index index +1);
if (nestedBlock != null) {
env.visit(nestedBlock);
}
}
}
else if (env.isClassicCompatible()) {
loopVar = list;
if (nestedBlock != null) {
env.visit(nestedBlock);
}
}
else {
throw invalidTypeException(list, listExpression, env, "collection or sequence");
}
}
public TemplateModel getLocalVariable(String name) {
if (name.startsWith(indexName)) {
switch(name.length() - indexName.length()) {
case 0:
return loopVar;
case 6:
if(name.endsWith("_index")) {
return new SimpleNumber(index);
}
break;
case 9:
if(name.endsWith("_has_next")) {
return hasNext ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
}
break;
}
}
return null;
}
public Collection getLocalVariableNames() {
if(variableNames == null) {
variableNames = new ArrayList(3);
variableNames.add(indexName);
variableNames.add(indexName + "_index");
variableNames.add(indexName + "_has_next");
}
return variableNames;
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/AddConcatExpression.java 0000644 0001750 0001750 00000023260 11723544467 026253 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
import java.util.*;
/**
* An operator for the + operator. Note that this is treated
* separately from the other 4 arithmetic operators,
* since + is overloaded to mean string concatenation.
* @author Jonathan Revusky
*/
final class AddConcatExpression extends Expression {
private final Expression left;
private final Expression right;
AddConcatExpression(Expression left, Expression right) {
this.left = left;
this.right = right;
}
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException
{
TemplateModel leftModel = left.getAsTemplateModel(env);
TemplateModel rightModel = right.getAsTemplateModel(env);
if (leftModel instanceof TemplateNumberModel && rightModel instanceof TemplateNumberModel)
{
Number first = EvaluationUtil.getNumber((TemplateNumberModel) leftModel, left, env);
Number second = EvaluationUtil.getNumber((TemplateNumberModel) rightModel, right, env);
ArithmeticEngine ae =
env != null
? env.getArithmeticEngine()
: getTemplate().getArithmeticEngine();
return new SimpleNumber(ae.add(first, second));
}
else if(leftModel instanceof TemplateSequenceModel && rightModel instanceof TemplateSequenceModel)
{
return new ConcatenatedSequence((TemplateSequenceModel)leftModel, (TemplateSequenceModel)rightModel);
}
else
{
try {
String s1 = getStringValue(leftModel, left, env);
if(s1 == null) s1 = "null";
String s2 = getStringValue(rightModel, right, env);
if(s2 == null) s2 = "null";
return new SimpleScalar(s1.concat(s2));
} catch (NonStringException e) {
if (leftModel instanceof TemplateHashModel && rightModel instanceof TemplateHashModel) {
if (leftModel instanceof TemplateHashModelEx && rightModel instanceof TemplateHashModelEx) {
TemplateHashModelEx leftModelEx = (TemplateHashModelEx)leftModel;
TemplateHashModelEx rightModelEx = (TemplateHashModelEx)rightModel;
if (leftModelEx.size() == 0) {
return rightModelEx;
} else if (rightModelEx.size() == 0) {
return leftModelEx;
} else {
return new ConcatenatedHashEx(leftModelEx, rightModelEx);
}
} else {
return new ConcatenatedHash((TemplateHashModel)leftModel,
(TemplateHashModel)rightModel);
}
} else {
throw e;
}
}
}
}
boolean isLiteral() {
return constantValue != null || (left.isLiteral() && right.isLiteral());
}
Expression _deepClone(String name, Expression subst) {
return new AddConcatExpression(left.deepClone(name, subst), right.deepClone(name, subst));
}
public String getCanonicalForm() {
return left.getCanonicalForm() + " + " + right.getCanonicalForm();
}
private static final class ConcatenatedSequence
implements
TemplateSequenceModel
{
private final TemplateSequenceModel left;
private final TemplateSequenceModel right;
ConcatenatedSequence(TemplateSequenceModel left, TemplateSequenceModel right)
{
this.left = left;
this.right = right;
}
public int size()
throws
TemplateModelException
{
return left.size() + right.size();
}
public TemplateModel get(int i)
throws
TemplateModelException
{
int ls = left.size();
return i < ls ? left.get(i) : right.get(i - ls);
}
}
private static class ConcatenatedHash
implements TemplateHashModel
{
protected final TemplateHashModel left;
protected final TemplateHashModel right;
ConcatenatedHash(TemplateHashModel left, TemplateHashModel right)
{
this.left = left;
this.right = right;
}
public TemplateModel get(String key)
throws TemplateModelException
{
TemplateModel model = right.get(key);
return (model != null) ? model : left.get(key);
}
public boolean isEmpty()
throws TemplateModelException
{
return left.isEmpty() && right.isEmpty();
}
}
private static final class ConcatenatedHashEx
extends ConcatenatedHash
implements TemplateHashModelEx
{
private CollectionAndSequence keys;
private CollectionAndSequence values;
private int size;
ConcatenatedHashEx(TemplateHashModelEx left, TemplateHashModelEx right)
{
super(left, right);
}
public int size() throws TemplateModelException
{
initKeys();
return size;
}
public TemplateCollectionModel keys()
throws TemplateModelException
{
initKeys();
return keys;
}
public TemplateCollectionModel values()
throws TemplateModelException
{
initValues();
return values;
}
private void initKeys()
throws TemplateModelException
{
if (keys == null) {
HashSet keySet = new HashSet();
SimpleSequence keySeq = new SimpleSequence(32);
addKeys(keySet, keySeq, (TemplateHashModelEx)this.left);
addKeys(keySet, keySeq, (TemplateHashModelEx)this.right);
size = keySet.size();
keys = new CollectionAndSequence(keySeq);
}
}
private static void addKeys(Set set, SimpleSequence keySeq, TemplateHashModelEx hash)
throws TemplateModelException
{
TemplateModelIterator it = hash.keys().iterator();
while (it.hasNext()) {
TemplateScalarModel tsm = (TemplateScalarModel)it.next();
if (set.add(tsm.getAsString())) {
// The first occurence of the key decides the index;
// this is consisten with stuff like java.util.LinkedHashSet.
keySeq.add(tsm);
}
}
}
private void initValues()
throws TemplateModelException
{
if (values == null) {
SimpleSequence seq = new SimpleSequence(size());
// Note: size() invokes initKeys() if needed.
int ln = keys.size();
for (int i = 0; i < ln; i++) {
seq.add(get(((TemplateScalarModel)keys.get(i)).getAsString()));
}
values = new CollectionAndSequence(seq);
}
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Case.java 0000644 0001750 0001750 00000007526 11723544470 023227 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import freemarker.template.*;
/**
* Represents a case in a switch statement.
*/
final class Case extends TemplateElement {
// might as well just make these package-visible
// so the Switch can use them, no need to be too anal-retentive
boolean isDefault;
Expression expression;
Case(Expression expression, TemplateElement nestedBlock, boolean isDefault)
{
this.expression = expression;
this.nestedBlock = nestedBlock;
this.isDefault = isDefault;
}
void accept(Environment env)
throws TemplateException, IOException
{
if (nestedBlock != null) {
env.visit(nestedBlock);
}
}
public String getCanonicalForm() {
StringBuffer buf = new StringBuffer();
if (isDefault) {
buf.append("<#default>");
}
else {
buf.append("<#case ");
buf.append(expression.getCanonicalForm());
buf.append(">");
}
if (nestedBlock != null) {
buf.append(nestedBlock.getCanonicalForm());
}
return buf.toString();
}
public String getDescription() {
if (isDefault) {
return "default case";
}
return "case " + expression;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/DynamicKeyName.java 0000644 0001750 0001750 00000024253 11723544471 025207 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.util.ArrayList;
import freemarker.template.*;
/**
* A unary operator that uses the string value of an expression as a hash key.
* It associates with the Identifier or Dot to its left.
*/
final class DynamicKeyName extends Expression {
private final Expression nameExpression;
private final Expression target;
DynamicKeyName(Expression target, Expression nameExpression) {
this.target = target;
this.nameExpression = nameExpression;
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException
{
TemplateModel targetModel = target.getAsTemplateModel(env);
assertNonNull(targetModel, target, env);
if (nameExpression instanceof Range) {
return dealWithRangeKey(targetModel, (Range) nameExpression, env);
}
TemplateModel keyModel = nameExpression.getAsTemplateModel(env);
if(keyModel == null) {
if(env.isClassicCompatible()) {
keyModel = TemplateScalarModel.EMPTY_STRING;
}
else {
assertNonNull(keyModel, nameExpression, env);
}
}
if (keyModel instanceof TemplateNumberModel) {
int index = EvaluationUtil.getNumber(keyModel, nameExpression, env).intValue();
return dealWithNumericalKey(targetModel, index, env);
}
if (keyModel instanceof TemplateScalarModel) {
String key = EvaluationUtil.getString((TemplateScalarModel)keyModel, nameExpression, env);
return dealWithStringKey(targetModel, key, env);
}
throw invalidTypeException(keyModel, nameExpression, env, "number, range, or string");
}
private TemplateModel dealWithNumericalKey(TemplateModel targetModel,
int index,
Environment env)
throws TemplateException
{
if (targetModel instanceof TemplateSequenceModel) {
TemplateSequenceModel tsm = (TemplateSequenceModel) targetModel;
int size = Integer.MAX_VALUE;
try {
size = tsm.size();
} catch (Exception e) {}
return index= sequence.size()) {
String msg = range.left.getStartLocation()
+ "\nLeft side index of range out of bounds, is " + start
+ ", but the sequence has only " + sequence.size() + " element(s) "
+ "(note that indices are 0 based, and ranges are inclusive).";
throw new TemplateException(msg, env);
}
if (end >= sequence.size()) {
String msg = range.right.getStartLocation()
+ "\nRight side index of range out of bounds, is " + end
+ ", but the sequence has only " + sequence.size() + " element(s)."
+ "(note that indices are 0 based, and ranges are inclusive).";
throw new TemplateException(msg, env);
}
ArrayList list = new ArrayList(1+Math.abs(start-end));
if (start>end) {
for (int i = start; i>=end; i--) {
list.add(sequence.get(i));
}
}
else {
for (int i = start; i<=end; i++) {
list.add(sequence.get(i));
}
}
return new SimpleSequence(list);
}
try
{
String s = target.getStringValue(env);
if (!hasRhs) end = s.length() -1;
if (start < 0) {
String msg = range.left.getStartLocation() + "\nNegative starting index for range " + range + " : " + start;
throw new TemplateException(msg, env);
}
if (end < 0) {
String msg = range.left.getStartLocation() + "\nNegative ending index for range " + range + " : " + end;
throw new TemplateException(msg, env);
}
if (start > s.length()) {
String msg = range.left.getStartLocation()
+ "\nLeft side of range out of bounds, is: " + start
+ "\nbut string " + targetModel + " has " + s.length() + " elements.";
throw new TemplateException(msg, env);
}
if (end > s.length()) {
String msg = range.right.getStartLocation()
+ "\nRight side of range out of bounds, is: " + end
+ "\nbut string " + targetModel + " is only " + s.length() + " characters.";
throw new TemplateException(msg, env);
}
try {
return new SimpleScalar(s.substring(start, end+1));
} catch (RuntimeException re) {
String msg = "Error " + getStartLocation();
throw new TemplateException(msg, re, env);
}
}
catch(NonStringException e)
{
throw invalidTypeException(target.getAsTemplateModel(env), target, env, "number, scalar, or sequence");
}
}
public String getCanonicalForm() {
return target.getCanonicalForm()
+ "["
+ nameExpression.getCanonicalForm()
+ "]";
}
boolean isLiteral() {
return constantValue != null || (target.isLiteral() && nameExpression.isLiteral());
}
Expression _deepClone(String name, Expression subst) {
return new DynamicKeyName(target.deepClone(name, subst), nameExpression.deepClone(name, subst));
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/ParentheticalExpression.java 0000644 0001750 0001750 00000006507 11723544470 027215 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
final class ParentheticalExpression extends Expression {
private final Expression nested;
ParentheticalExpression(Expression nested) {
this.nested = nested;
}
boolean isTrue(Environment env) throws TemplateException {
return nested.isTrue(env);
}
public String getCanonicalForm() {
return "(" + nested.getCanonicalForm() + ")";
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException
{
return nested.getAsTemplateModel(env);
}
public boolean isLiteral() {
return nested.isLiteral();
}
Expression _deepClone(String name, Expression subst) {
return new ParentheticalExpression(nested.deepClone(name, subst));
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/FlushInstruction.java 0000644 0001750 0001750 00000006020 11723544471 025664 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
/**
* An instruction that flushes the output stream.
* @version $Id: FlushInstruction.java,v 1.2 2004/01/06 17:06:42 szegedia Exp $
*/
final class FlushInstruction extends TemplateElement {
void accept(Environment env) throws IOException {
env.getOut().flush();
}
public String getCanonicalForm() {
return "<#flush/>";
}
public String getDescription() {
return "flush instruction";
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/ArithmeticExpression.java 0000644 0001750 0001750 00000012611 11723544471 026515 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
/**
* An operator for arithmetic operations. Note that the + operator
* also does string concatenation for backward compatibility.
* @author Jonathan Revusky
*/
final class ArithmeticExpression extends Expression {
static final int SUBSTRACTION = 0;
static final int MULTIPLICATION = 1;
static final int DIVISION = 2;
static final int MODULUS = 3;
private static final char[] OPERATORS = new char[] {'-','*','/','%'};
private final Expression left;
private final Expression right;
private final int operation;
ArithmeticExpression(Expression left, Expression right, int operation) {
this.left = left;
this.right = right;
this.operation = operation;
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException
{
TemplateModel leftModel = left.getAsTemplateModel(env);
TemplateModel rightModel = right.getAsTemplateModel(env);
boolean leftIsNumber = (leftModel instanceof TemplateNumberModel);
boolean rightIsNumber = (rightModel instanceof TemplateNumberModel);
boolean bothNumbers = leftIsNumber && rightIsNumber;
if (!bothNumbers) {
String msg = "Error " + getStartLocation();
if (!leftIsNumber) {
msg += "\nExpression " + left + " is not numerical";
}
if (!rightIsNumber) {
msg += "\nExpression " + right + " is not numerical";
}
throw new NonNumericalException(msg, env);
}
Number first = EvaluationUtil.getNumber(leftModel, left, env);
Number second = EvaluationUtil.getNumber(rightModel, right, env);
ArithmeticEngine ae =
env != null
? env.getArithmeticEngine()
: getTemplate().getArithmeticEngine();
switch (operation) {
case SUBSTRACTION :
return new SimpleNumber(ae.subtract(first, second));
case MULTIPLICATION :
return new SimpleNumber(ae.multiply(first, second));
case DIVISION :
return new SimpleNumber(ae.divide(first, second));
case MODULUS :
return new SimpleNumber(ae.modulus(first, second));
default:
throw new TemplateException("unknown operation : " + operation, env);
}
}
public String getCanonicalForm() {
return left.getCanonicalForm() + ' ' + OPERATORS[operation] + ' ' + right.getCanonicalForm();
}
boolean isLiteral() {
return constantValue != null || (left.isLiteral() && right.isLiteral());
}
Expression _deepClone(String name, Expression subst) {
return new ArithmeticExpression(left.deepClone(name, subst), right.deepClone(name, subst), operation);
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/StopInstruction.java 0000644 0001750 0001750 00000006562 11723544470 025542 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.TemplateException;
/**
* Represents a <stop> instruction to abort template processing.
* @author Jonathan Revusky
*/
final class StopInstruction extends TemplateElement {
private Expression exp;
StopInstruction(Expression exp) {
this.exp = exp;
}
void accept(Environment env) throws TemplateException {
if (exp == null) {
throw new StopException(env);
}
throw new StopException(env, exp.getStringValue(env));
}
public String getCanonicalForm() {
String expString = exp == null ? "" : " " + exp.getCanonicalForm();
return "<#stop" + expString + "/>";
}
public String getDescription() {
return "stop" + " [" + getStartLocation() + "]";
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/TemplateClassResolver.java 0000644 0001750 0001750 00000013707 11723544470 026635 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.utility.ClassUtil;
import freemarker.template.utility.Execute;
import freemarker.template.utility.ObjectConstructor;
/**
* Used by built-ins and other template language features that get a class
* based on a string. This can be handy both for implementing security
* restrictions and for working around local class-loader issues.
*
* The implementation should be thread-safe, unless an
* instance is always only used in a single {@link Environment} object.
*
* @see Configurable#setNewBuiltinClassResolver(TemplateClassResolver)
*/
public interface TemplateClassResolver {
/**
* Simply calls {@link ClassUtil#forName(String)}.
*/
TemplateClassResolver UNRESTRICTED_RESOLVER = new TemplateClassResolver() {
public Class resolve(String className, Environment env, Template template)
throws TemplateException {
try {
return ClassUtil.forName(className);
} catch (ClassNotFoundException e) {
throw new TemplateException(e, env);
}
}
};
/**
* Same as {@link #UNRESTRICTED_RESOLVER}, except that it doesn't allow
* resolving {@link ObjectConstructor}.
*/
TemplateClassResolver SAFER_RESOLVER = new TemplateClassResolver() {
public Class resolve(String className, Environment env, Template template)
throws TemplateException {
if (className.equals(ObjectConstructor.class.getName())
|| className.equals(Execute.class.getName())
|| className.equals("freemarker.template.utility.JythonRuntime")) {
throw new TemplateException(
"Instantiating " + className + " is not allowed in the " +
"template for security reasons.",
env);
}
try {
return ClassUtil.forName(className);
} catch (ClassNotFoundException e) {
throw new TemplateException(e, env);
}
}
};
/**
* Doesn't allow resolving any classes.
*/
TemplateClassResolver ALLOWS_NOTHING_RESOLVER = new TemplateClassResolver() {
public Class resolve(String className, Environment env, Template template)
throws TemplateException {
throw new TemplateException(
"Instantiating " + className + " is not allowed in the " +
"template for security reasons.",
env);
}
};
/**
* Gets a {@link Class} based on the class name.
*
* @param className the full-qualified class name
* @param env the environment in which the template executes
* @param template the template where the operation that require the
* class resolution resides in. This is null
if the
* call doesn't come from a template.
*
* @throws TemplateException if the class can't be found or shouldn't be
* accessed from a template for security reasons.
*/
Class resolve(String className, Environment env, Template template) throws TemplateException;
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/NonDateException.java 0000644 0001750 0001750 00000006004 11723544471 025552 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.TemplateException;
/**
* Indicates that a date, time or date+time was expected.
*/
public class NonDateException extends TemplateException {
public NonDateException(Environment env) {
super("expecting date/time value here", env);
}
public NonDateException(String description, Environment env) {
super(description, env);
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Identifier.java 0000644 0001750 0001750 00000007235 11723544472 024435 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.*;
/**
* A reference to a top-level variable
*/
final class Identifier extends Expression {
private final String name;
Identifier(String name) {
this.name = name;
}
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
try {
return env.getVariable(name);
} catch (NullPointerException e) {
if (env == null) {
throw new TemplateException("Variables are not available "
+ "(certainly you are in a parse-time executed directive). The name of the variable "
+ "you tried to read: " + name, null);
} else {
throw e;
}
}
}
public String toString() {
return name;
}
public String getCanonicalForm() {
return name;
}
boolean isLiteral() {
return false;
}
Expression _deepClone(String name, Expression subst) {
if(this.name.equals(name)) {
return subst.deepClone(null, null);
}
return new Identifier(this.name);
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/AssignmentInstruction.java 0000644 0001750 0001750 00000011744 11723544470 026723 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.io.IOException;
import java.util.*;
import freemarker.template.TemplateException;
/**
* An instruction that contains one or more assignments
*/
final class AssignmentInstruction extends TemplateElement {
private int scope;
private Expression namespaceExp;
AssignmentInstruction(int scope) {
this.scope = scope;
nestedElements = new ArrayList(1);
}
void addAssignment(Assignment ass) {
nestedElements.add(ass);
}
void setNamespaceExp(Expression namespaceExp) {
this.namespaceExp = namespaceExp;
for (int i=0; i");
return buf.toString();
}
public String getDescription() {
String tag = "local ";
if (scope == Assignment.GLOBAL) {
tag = "global ";
}
else if (scope == Assignment.NAMESPACE) {
tag = "assign ";
}
tag += "assignment";
if (nestedElements.size() > 1) {
tag += "s";
}
return tag;
}
public TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException {
super.postParseCleanup(stripWhitespace);
if (nestedElements.size() == 1) {
Assignment ass = (Assignment) nestedElements.get(0);
ass.setLocation(getTemplate(), this, this);
return ass;
}
return this;
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/Token.java 0000644 0001750 0001750 00000005320 11723544470 023422 0 ustar ebourg ebourg /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
package freemarker.core;
/**
* Describes the input token stream.
*/
class Token implements java.io.Serializable {
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/**
* beginLine and beginColumn describe the position of the first character
* of this token; endLine and endColumn describe the position of the
* last character of this token.
*/
public int beginLine, beginColumn, endLine, endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* Returns the image.
*/
public String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simlpy add something like :
*
* case MyParserConstants.ID : return new IDToken();
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use it in your lexical actions.
*/
public static final Token newToken(int ofKind)
{
switch(ofKind)
{
default : return new Token();
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/BreakInstruction.java 0000644 0001750 0001750 00000006211 11723544470 025630 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
/**
* Represents a <break> instruction to break out of a loop.
* @author Jonathan Revusky
*/
final class BreakInstruction extends TemplateElement {
void accept(Environment env) {
throw Break.INSTANCE;
}
public String getCanonicalForm() {
return "<#break/>";
}
public String getDescription() {
return "break" + " [" + getStartLocation() + "]";
}
static class Break extends RuntimeException {
static final Break INSTANCE = new Break();
private Break() {
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/DateBuiltins.java 0000644 0001750 0001750 00000022767 11723544471 024750 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import freemarker.template.AdapterTemplateModel;
import freemarker.template.SimpleScalar;
import freemarker.template.TemplateDateModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateScalarModel;
import freemarker.template.utility.DateUtil;
import freemarker.template.utility.StringUtil;
import freemarker.template.utility.UnrecognizedTimeZoneException;
/**
* A holder for built-ins that operate exclusively on {@link TemplateDateModel}-a.
*/
abstract class DateBuiltins {
abstract static class DateBuiltin extends BuiltIn {
TemplateModel _getAsTemplateModel(Environment env)
throws TemplateException
{
TemplateModel model = target.getAsTemplateModel(env);
if (model instanceof TemplateDateModel) {
TemplateDateModel tdm = (TemplateDateModel) model;
return calculateResult(EvaluationUtil.getDate(tdm, target, env), tdm.getDateType(), env);
} else {
if(model == null) {
throw new InvalidReferenceException(target + " is undefined.", env);
}
throw new NonDateException(
target + " should be a date, time, or date+time, but it's a(n) "
+ model.getClass().getName(), env);
}
}
/** Override this to implement the built-in. */
protected abstract TemplateModel calculateResult(
Date date, int dateType, Environment env)
throws TemplateException;
}
static abstract class AbstractISOBI extends DateBuiltin {
protected final String biName;
protected final boolean showOffset;
protected final int accuracy;
protected AbstractISOBI(String biName,
boolean showOffset, int accuracy) {
this.biName = biName;
this.showOffset = showOffset;
this.accuracy = accuracy;
}
protected void checkDateTypeNotUnknown(int dateType, Environment env)
throws TemplateException {
if (dateType == TemplateDateModel.UNKNOWN) {
throw new TemplateException(
"Unknown date type: ?" + biName + " needs a date value "
+ "where it's known if it's a date-only, time-only, or "
+ "date+time value. Use ?time, ?date or ?datetime "
+ "before ? " + biName + " to estabilish that.",
env);
}
}
}
/**
* Implements {@code ?iso_utc} and {@code ?iso_local} variants, but not
* {@code ?iso(timeZone)}.
*/
static class iso_tz_BI extends AbstractISOBI {
private final boolean useUTC;
iso_tz_BI(String biName,
boolean showOffset, int accuracy, boolean useUTC) {
super(biName, showOffset, accuracy);
this.useUTC = useUTC;
}
protected TemplateModel calculateResult(
Date date, int dateType, Environment env)
throws TemplateException {
checkDateTypeNotUnknown(dateType, env);
return new SimpleScalar(DateUtil.dateToISO8601String(
date,
dateType != TemplateDateModel.TIME,
dateType != TemplateDateModel.DATE,
showOffset && dateType != TemplateDateModel.DATE,
accuracy,
useUTC ? DateUtil.UTC : env.getTimeZone(),
env.getISOBuiltInCalendar()));
}
}
/**
* Implements {@code ?iso(timeZone)}.
*/
static class iso_BI extends AbstractISOBI {
iso_BI(String biName,
boolean showOffset, int accuracy) {
super(biName, showOffset, accuracy);
}
protected TemplateModel calculateResult(
Date date, int dateType, Environment env)
throws TemplateException {
checkDateTypeNotUnknown(dateType, env);
return new Result(date, dateType, env);
}
class Result implements TemplateMethodModelEx {
private final Date date;
private final int dateType;
private final Environment env;
Result(Date date, int dateType, Environment env) {
this.date = date;
this.dateType = dateType;
this.env = env;
}
public Object exec(List args) throws TemplateModelException {
if (args.size() != 1) {
throw new TemplateModelException(
"?" + biName + "(...) expects exactly 1 argument, but had "
+ args.size() + ".");
}
TemplateModel tzArgTM = (TemplateModel) args.get(0);
TimeZone tzArg;
Object adaptedObj;
if (tzArgTM instanceof AdapterTemplateModel
&& (adaptedObj =
((AdapterTemplateModel) tzArgTM)
.getAdaptedObject(TimeZone.class))
instanceof TimeZone) {
tzArg = (TimeZone) adaptedObj;
} else if (tzArgTM instanceof TemplateScalarModel) {
String tzName = ((TemplateScalarModel) tzArgTM).getAsString();
try {
tzArg = DateUtil.getTimeZone(tzName);
} catch (UnrecognizedTimeZoneException e) {
throw new TemplateModelException(
"The time zone string specified for ?" + biName +
"(...) is not recognized as a valid time zone name: " +
StringUtil.jQuote(tzName));
}
} else {
throw new TemplateModelException(
"The argument to ?" + biName +
"(...) must be a String or a " +
"java.util.TimeZone but it was a " +
(tzArgTM != null ? tzArgTM.getClass().getName() : "null") +
".");
}
return new SimpleScalar(DateUtil.dateToISO8601String(
date,
dateType != TemplateDateModel.TIME,
dateType != TemplateDateModel.DATE,
showOffset && dateType != TemplateDateModel.DATE,
accuracy,
tzArg,
env.getISOBuiltInCalendar()));
}
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/FMParserTokenManager.java 0000644 0001750 0001750 00000740713 11723544471 026332 0 ustar ebourg ebourg /* Generated By:JavaCC: Do not edit this line. FMParserTokenManager.java */
package freemarker.core;
import freemarker.template.*;
import freemarker.template.utility.StringUtil;
import freemarker.template.utility.DeepUnwrap;
import java.io.*;
import java.util.*;
class FMParserTokenManager implements FMParserConstants
{
/**
The noparseTag is set when we enter
a block of text that the parser more or less ignores.
These are and . This variable
tells us what the closing tag should be, and when
we hit that, we resume parsing. Note that with this
scheme, and tags cannot nest
recursively, but it is not clear how important that is.
*/
String noparseTag;
/**
Keeps track of how deeply nested
we have the hash literals.
This is necessary since we need to be
able to distinguish the } used to close
a hash literal and the one used to
close a ${
*/
private int hashLiteralNesting;
private int parenthesisNesting;
private int bracketNesting;
private boolean inFTLHeader;
boolean strictEscapeSyntax,
onlyTextOutput,
altDirectiveSyntax,
autodetectTagSyntax,
directiveSyntaxEstablished,
inInvocation;
int incompatibleChanges;
String templateName;
// This method checks if we are in a strict mode where all
// FreeMarker directives must start with <#. It also handled
// tag syntax detection. If you update this logic, take a look
// at the UNKNOWN_DIRECTIVE token too.
private void strictSyntaxCheck(Token tok, int newLexState) {
if (onlyTextOutput) {
tok.kind = PRINTABLE_CHARS;
return;
}
char firstChar = tok.image.charAt(0);
if (autodetectTagSyntax && !directiveSyntaxEstablished) {
altDirectiveSyntax = (firstChar == '[');
}
if ((firstChar == '[' && !altDirectiveSyntax) || (firstChar == '<' && altDirectiveSyntax)) {
tok.kind = PRINTABLE_CHARS;
return;
}
if (!strictEscapeSyntax) {
SwitchTo(newLexState);
return;
}
if (!altDirectiveSyntax) {
if (!tok.image.startsWith("<#") && !tok.image.startsWith("#")) {
tok.kind = PRINTABLE_CHARS;
return;
}
}
directiveSyntaxEstablished = true;
SwitchTo(newLexState);
}
private void unifiedCall(Token tok) {
char firstChar = tok.image.charAt(0);
if (autodetectTagSyntax && !directiveSyntaxEstablished) {
altDirectiveSyntax = (firstChar == '[');
}
if (altDirectiveSyntax && firstChar == '<') {
tok.kind = PRINTABLE_CHARS;
return;
}
if (!altDirectiveSyntax && firstChar == '[') {
tok.kind = PRINTABLE_CHARS;
return;
}
directiveSyntaxEstablished = true;
SwitchTo(NO_SPACE_EXPRESSION);
}
private void unifiedCallEnd(Token tok) {
char firstChar = tok.image.charAt(0);
if (altDirectiveSyntax && firstChar == '<') {
tok.kind = PRINTABLE_CHARS;
return;
}
if (!altDirectiveSyntax && firstChar == '[') {
tok.kind = PRINTABLE_CHARS;
return;
}
}
private void closeBracket(Token tok) {
if (bracketNesting >0) {
--bracketNesting;
} else {
tok.kind=DIRECTIVE_END;
if (inFTLHeader) {
eatNewline();
inFTLHeader = false;
}
SwitchTo(DEFAULT);
}
}
private void eatNewline() {
int charsRead = 0;
try {
while (true) {
char c = input_stream.readChar();
++charsRead;
if (!Character.isWhitespace(c)) {
input_stream.backup(charsRead);
return;
} else if (c=='\r') {
char next = input_stream.readChar();
++charsRead;
if (next != '\n') {
input_stream.backup(1);
}
return;
} else if (c=='\n') {
return;
}
}
} catch (IOException ioe) {
input_stream.backup(charsRead);
}
}
private void ftlHeader(Token matchedToken) {
if (!directiveSyntaxEstablished) {
altDirectiveSyntax = matchedToken.image.charAt(0) == '[';
directiveSyntaxEstablished = true;
autodetectTagSyntax = false;
}
String img = matchedToken.image;
char firstChar = img.charAt(0);
char lastChar = img.charAt(img.length() -1);
if ((firstChar == '[' && !altDirectiveSyntax) || (firstChar == '<' && altDirectiveSyntax)) {
matchedToken.kind = PRINTABLE_CHARS;
}
if (matchedToken.kind != PRINTABLE_CHARS) {
if (lastChar != '>' && lastChar != ']') {
SwitchTo(FM_EXPRESSION);
inFTLHeader = true;
} else {
eatNewline();
}
}
}
public java.io.PrintStream debugStream = System.out;
public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
private final int jjMoveStringLiteralDfa0_7()
{
return jjMoveNfa_7(0, 0);
}
private final void jjCheckNAdd(int state)
{
if (jjrounds[state] != jjround)
{
jjstateSet[jjnewStateCnt++] = state;
jjrounds[state] = jjround;
}
}
private final void jjAddStates(int start, int end)
{
do {
jjstateSet[jjnewStateCnt++] = jjnextStates[start];
} while (start++ != end);
}
private final void jjCheckNAddTwoStates(int state1, int state2)
{
jjCheckNAdd(state1);
jjCheckNAdd(state2);
}
private final void jjCheckNAddStates(int start, int end)
{
do {
jjCheckNAdd(jjnextStates[start]);
} while (start++ != end);
}
private final void jjCheckNAddStates(int start)
{
jjCheckNAdd(jjnextStates[start]);
jjCheckNAdd(jjnextStates[start + 1]);
}
static final long[] jjbitVec0 = {
0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
};
static final long[] jjbitVec2 = {
0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
};
private final int jjMoveNfa_7(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 13;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
if ((0xefffdfffffffffffL & l) != 0L)
{
if (kind > 131)
kind = 131;
jjCheckNAdd(6);
}
else if ((0x1000200000000000L & l) != 0L)
{
if (kind > 132)
kind = 132;
}
if (curChar == 45)
jjAddStates(0, 1);
else if (curChar == 60)
jjstateSet[jjnewStateCnt++] = 1;
break;
case 1:
if (curChar == 47)
jjCheckNAddTwoStates(2, 3);
break;
case 2:
if (curChar == 35)
jjCheckNAdd(3);
break;
case 4:
if ((0x100002600L & l) != 0L)
jjAddStates(2, 3);
break;
case 5:
if (curChar == 62 && kind > 130)
kind = 130;
break;
case 6:
if ((0xefffdfffffffffffL & l) == 0L)
break;
if (kind > 131)
kind = 131;
jjCheckNAdd(6);
break;
case 7:
if ((0x1000200000000000L & l) != 0L && kind > 132)
kind = 132;
break;
case 8:
if (curChar == 45)
jjAddStates(0, 1);
break;
case 9:
if (curChar == 62 && kind > 129)
kind = 129;
break;
case 10:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 9;
break;
case 12:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 11;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
if ((0xfffffffff7ffffffL & l) != 0L)
{
if (kind > 131)
kind = 131;
jjCheckNAdd(6);
}
else if (curChar == 91)
{
if (kind > 132)
kind = 132;
}
if (curChar == 91)
jjstateSet[jjnewStateCnt++] = 1;
break;
case 3:
if ((0x7fffffe07fffffeL & l) != 0L)
jjAddStates(4, 6);
break;
case 5:
if (curChar == 93 && kind > 130)
kind = 130;
break;
case 6:
if ((0xfffffffff7ffffffL & l) == 0L)
break;
if (kind > 131)
kind = 131;
jjCheckNAdd(6);
break;
case 7:
if (curChar == 91 && kind > 132)
kind = 132;
break;
case 11:
if (curChar == 93 && kind > 129)
kind = 129;
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
case 6:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
if (kind > 131)
kind = 131;
jjCheckNAdd(6);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 13 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_1(int pos, long active0, long active1)
{
switch (pos)
{
case 0:
if ((active1 & 0x180L) != 0L)
{
jjmatchedKind = 70;
return -1;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_1(int pos, long active0, long active1)
{
return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0, active1), pos + 1);
}
private final int jjStopAtPos(int pos, int kind)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
return pos + 1;
}
private final int jjStartNfaWithStates_1(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_1(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_1()
{
switch(curChar)
{
case 35:
return jjMoveStringLiteralDfa1_1(0x100L);
case 36:
return jjMoveStringLiteralDfa1_1(0x80L);
default :
return jjMoveNfa_1(2, 0);
}
}
private final int jjMoveStringLiteralDfa1_1(long active1)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_1(0, 0L, active1);
return 1;
}
switch(curChar)
{
case 123:
if ((active1 & 0x80L) != 0L)
return jjStopAtPos(1, 71);
else if ((active1 & 0x100L) != 0L)
return jjStopAtPos(1, 72);
break;
default :
break;
}
return jjStartNfa_1(0, 0L, active1);
}
private final int jjMoveNfa_1(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 3;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 2:
if ((0xefffffe6ffffd9ffL & l) != 0L)
{
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
}
else if ((0x100002600L & l) != 0L)
{
if (kind > 68)
kind = 68;
jjCheckNAdd(0);
}
else if ((0x1000001800000000L & l) != 0L)
{
if (kind > 70)
kind = 70;
}
break;
case 0:
if ((0x100002600L & l) == 0L)
break;
kind = 68;
jjCheckNAdd(0);
break;
case 1:
if ((0xefffffe6ffffd9ffL & l) == 0L)
break;
kind = 69;
jjCheckNAdd(1);
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 2:
if ((0xf7fffffff7ffffffL & l) != 0L)
{
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
}
else if ((0x800000008000000L & l) != 0L)
{
if (kind > 70)
kind = 70;
}
break;
case 1:
if ((0xf7fffffff7ffffffL & l) == 0L)
break;
kind = 69;
jjCheckNAdd(1);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 2:
case 1:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
{
switch (pos)
{
case 0:
if ((active1 & 0x180L) != 0L)
{
jjmatchedKind = 70;
return -1;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_0(int pos, long active0, long active1)
{
return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);
}
private final int jjStartNfaWithStates_0(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_0(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
case 35:
return jjMoveStringLiteralDfa1_0(0x100L);
case 36:
return jjMoveStringLiteralDfa1_0(0x80L);
default :
return jjMoveNfa_0(2, 0);
}
}
private final int jjMoveStringLiteralDfa1_0(long active1)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(0, 0L, active1);
return 1;
}
switch(curChar)
{
case 123:
if ((active1 & 0x80L) != 0L)
return jjStopAtPos(1, 71);
else if ((active1 & 0x100L) != 0L)
return jjStopAtPos(1, 72);
break;
default :
break;
}
return jjStartNfa_0(0, 0L, active1);
}
static final long[] jjbitVec3 = {
0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
};
static final long[] jjbitVec4 = {
0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
};
static final long[] jjbitVec5 = {
0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
};
static final long[] jjbitVec6 = {
0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
};
static final long[] jjbitVec7 = {
0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
};
static final long[] jjbitVec8 = {
0x3fffffffffffL, 0x0L, 0x0L, 0x0L
};
private final int jjMoveNfa_0(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 567;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 2:
if ((0xefffffe6ffffd9ffL & l) != 0L)
{
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
}
else if ((0x100002600L & l) != 0L)
{
if (kind > 68)
kind = 68;
jjCheckNAdd(0);
}
else if ((0x1000001800000000L & l) != 0L)
{
if (kind > 70)
kind = 70;
}
if (curChar == 60)
jjAddStates(7, 8);
if (curChar == 60)
jjCheckNAddStates(9, 84);
if (curChar == 60)
jjCheckNAddStates(85, 125);
break;
case 0:
if ((0x100002600L & l) == 0L)
break;
if (kind > 68)
kind = 68;
jjCheckNAdd(0);
break;
case 1:
if ((0xefffffe6ffffd9ffL & l) == 0L)
break;
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
break;
case 3:
if (curChar == 60)
jjCheckNAddStates(85, 125);
break;
case 5:
if ((0x100002600L & l) != 0L)
jjAddStates(126, 127);
break;
case 6:
if (curChar == 62 && kind > 6)
kind = 6;
break;
case 14:
if ((0x100002600L & l) != 0L)
jjAddStates(128, 129);
break;
case 15:
if (curChar == 62 && kind > 7)
kind = 7;
break;
case 23:
if ((0x100002600L & l) != 0L && kind > 8)
kind = 8;
break;
case 26:
if ((0x100002600L & l) != 0L && kind > 9)
kind = 9;
break;
case 33:
if ((0x100002600L & l) != 0L && kind > 10)
kind = 10;
break;
case 38:
if ((0x100002600L & l) != 0L && kind > 11)
kind = 11;
break;
case 46:
if ((0x100002600L & l) != 0L && kind > 12)
kind = 12;
break;
case 53:
if ((0x100002600L & l) != 0L && kind > 13)
kind = 13;
break;
case 58:
if ((0x100002600L & l) != 0L && kind > 14)
kind = 14;
break;
case 65:
if ((0x100002600L & l) != 0L && kind > 15)
kind = 15;
break;
case 72:
if ((0x100002600L & l) != 0L && kind > 16)
kind = 16;
break;
case 78:
if ((0x100002600L & l) != 0L && kind > 17)
kind = 17;
break;
case 86:
if ((0x100002600L & l) != 0L && kind > 18)
kind = 18;
break;
case 93:
if ((0x100002600L & l) != 0L && kind > 19)
kind = 19;
break;
case 102:
if ((0x100002600L & l) != 0L && kind > 20)
kind = 20;
break;
case 108:
if ((0x100002600L & l) != 0L && kind > 21)
kind = 21;
break;
case 118:
if ((0x100002600L & l) != 0L && kind > 22)
kind = 22;
break;
case 124:
if ((0x100002600L & l) != 0L && kind > 23)
kind = 23;
break;
case 129:
if ((0x100002600L & l) != 0L && kind > 24)
kind = 24;
break;
case 136:
if ((0x100002600L & l) != 0L && kind > 25)
kind = 25;
break;
case 141:
if ((0x100002600L & l) != 0L && kind > 26)
kind = 26;
break;
case 149:
if ((0x100002600L & l) != 0L)
jjAddStates(130, 131);
break;
case 150:
if (curChar == 62 && kind > 27)
kind = 27;
break;
case 159:
if ((0x100002600L & l) != 0L)
jjAddStates(132, 133);
break;
case 160:
if (curChar == 62 && kind > 28)
kind = 28;
break;
case 168:
if ((0x100002600L & l) != 0L)
jjAddStates(134, 135);
break;
case 169:
if (curChar == 62 && kind > 30)
kind = 30;
break;
case 177:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(136, 138);
break;
case 178:
if (curChar == 47)
jjCheckNAdd(179);
break;
case 179:
if (curChar == 62 && kind > 44)
kind = 44;
break;
case 184:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(139, 141);
break;
case 185:
if (curChar == 47)
jjCheckNAdd(186);
break;
case 186:
if (curChar == 62 && kind > 45)
kind = 45;
break;
case 192:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(142, 144);
break;
case 193:
if (curChar == 47)
jjCheckNAdd(194);
break;
case 194:
if (curChar == 62 && kind > 46)
kind = 46;
break;
case 201:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(145, 147);
break;
case 202:
if (curChar == 47)
jjCheckNAdd(203);
break;
case 203:
if (curChar == 62 && kind > 47)
kind = 47;
break;
case 208:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(148, 150);
break;
case 209:
if (curChar == 47)
jjCheckNAdd(210);
break;
case 210:
if (curChar == 62 && kind > 48)
kind = 48;
break;
case 216:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(151, 153);
break;
case 217:
if (curChar == 47)
jjCheckNAdd(218);
break;
case 218:
if (curChar == 62 && kind > 49)
kind = 49;
break;
case 220:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(154, 156);
break;
case 221:
if (curChar == 47)
jjCheckNAdd(222);
break;
case 222:
if (curChar == 62 && kind > 50)
kind = 50;
break;
case 225:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(157, 159);
break;
case 226:
if (curChar == 47)
jjCheckNAdd(227);
break;
case 227:
if (curChar == 62 && kind > 51)
kind = 51;
break;
case 230:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(160, 162);
break;
case 231:
if (curChar == 47)
jjCheckNAdd(232);
break;
case 232:
if (curChar == 62 && kind > 52)
kind = 52;
break;
case 235:
if ((0x100002600L & l) != 0L)
jjAddStates(163, 164);
break;
case 236:
if (curChar == 62 && kind > 53)
kind = 53;
break;
case 244:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(165, 167);
break;
case 245:
if (curChar == 47)
jjCheckNAdd(246);
break;
case 246:
if (curChar == 62 && kind > 54)
kind = 54;
break;
case 253:
if ((0x100002600L & l) != 0L && kind > 55)
kind = 55;
break;
case 260:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(168, 170);
break;
case 261:
if (curChar == 47)
jjCheckNAdd(262);
break;
case 262:
if (curChar == 62 && kind > 56)
kind = 56;
break;
case 270:
if ((0x100002600L & l) != 0L && kind > 57)
kind = 57;
break;
case 278:
if ((0x100002600L & l) != 0L)
jjCheckNAddStates(171, 173);
break;
case 279:
if (curChar == 47)
jjCheckNAdd(280);
break;
case 280:
if (curChar == 62 && kind > 58)
kind = 58;
break;
case 289:
if ((0x100002600L & l) != 0L && kind > 59)
kind = 59;
break;
case 296:
if ((0x100002600L & l) != 0L)
jjAddStates(174, 175);
break;
case 297:
if (curChar == 62 && kind > 61)
kind = 61;
break;
case 305:
if (curChar == 60)
jjCheckNAddStates(9, 84);
break;
case 306:
if (curChar == 35)
jjCheckNAdd(12);
break;
case 307:
if (curChar == 35)
jjCheckNAdd(21);
break;
case 308:
if (curChar == 35)
jjCheckNAdd(24);
break;
case 309:
if (curChar == 35)
jjCheckNAdd(31);
break;
case 310:
if (curChar == 35)
jjCheckNAdd(36);
break;
case 311:
if (curChar == 35)
jjCheckNAdd(44);
break;
case 312:
if (curChar == 35)
jjCheckNAdd(51);
break;
case 313:
if (curChar == 35)
jjCheckNAdd(56);
break;
case 314:
if (curChar == 35)
jjCheckNAdd(63);
break;
case 315:
if (curChar == 35)
jjCheckNAdd(70);
break;
case 316:
if (curChar == 35)
jjCheckNAdd(76);
break;
case 317:
if (curChar == 35)
jjCheckNAdd(84);
break;
case 318:
if (curChar == 35)
jjCheckNAdd(91);
break;
case 319:
if (curChar == 35)
jjCheckNAdd(100);
break;
case 320:
if (curChar == 35)
jjCheckNAdd(106);
break;
case 321:
if (curChar == 35)
jjCheckNAdd(116);
break;
case 322:
if (curChar == 35)
jjCheckNAdd(122);
break;
case 323:
if (curChar == 35)
jjCheckNAdd(127);
break;
case 324:
if (curChar == 35)
jjCheckNAdd(134);
break;
case 325:
if (curChar == 35)
jjCheckNAdd(139);
break;
case 326:
if (curChar == 35)
jjCheckNAdd(147);
break;
case 327:
if (curChar == 35)
jjCheckNAdd(157);
break;
case 328:
if (curChar == 35)
jjCheckNAdd(166);
break;
case 329:
if (curChar == 35)
jjCheckNAdd(175);
break;
case 330:
if (curChar == 47)
jjCheckNAdd(334);
break;
case 332:
if ((0x100002600L & l) != 0L)
jjAddStates(176, 177);
break;
case 333:
if (curChar == 62 && kind > 31)
kind = 31;
break;
case 335:
if (curChar == 35)
jjCheckNAdd(334);
break;
case 336:
case 532:
if (curChar == 47)
jjCheckNAdd(335);
break;
case 337:
if (curChar == 47)
jjCheckNAdd(343);
break;
case 339:
if ((0x100002600L & l) != 0L)
jjAddStates(178, 179);
break;
case 340:
if (curChar == 62 && kind > 32)
kind = 32;
break;
case 344:
if (curChar == 35)
jjCheckNAdd(343);
break;
case 345:
case 533:
if (curChar == 47)
jjCheckNAdd(344);
break;
case 346:
if (curChar == 47)
jjCheckNAdd(355);
break;
case 348:
if ((0x100002600L & l) != 0L)
jjAddStates(180, 181);
break;
case 349:
if (curChar == 62 && kind > 33)
kind = 33;
break;
case 356:
if (curChar == 35)
jjCheckNAdd(355);
break;
case 357:
case 534:
if (curChar == 47)
jjCheckNAdd(356);
break;
case 358:
if (curChar == 47)
jjCheckNAdd(367);
break;
case 360:
if ((0x100002600L & l) != 0L)
jjAddStates(182, 183);
break;
case 361:
if (curChar == 62 && kind > 34)
kind = 34;
break;
case 368:
if (curChar == 35)
jjCheckNAdd(367);
break;
case 369:
case 535:
if (curChar == 47)
jjCheckNAdd(368);
break;
case 370:
if (curChar == 47)
jjCheckNAdd(379);
break;
case 372:
if ((0x100002600L & l) != 0L)
jjAddStates(184, 185);
break;
case 373:
if (curChar == 62 && kind > 35)
kind = 35;
break;
case 380:
if (curChar == 35)
jjCheckNAdd(379);
break;
case 381:
case 536:
if (curChar == 47)
jjCheckNAdd(380);
break;
case 382:
if (curChar == 47)
jjCheckNAdd(389);
break;
case 384:
if ((0x100002600L & l) != 0L)
jjAddStates(186, 187);
break;
case 385:
if (curChar == 62 && kind > 36)
kind = 36;
break;
case 390:
if (curChar == 35)
jjCheckNAdd(389);
break;
case 391:
case 537:
if (curChar == 47)
jjCheckNAdd(390);
break;
case 392:
if (curChar == 47)
jjCheckNAdd(400);
break;
case 394:
if ((0x100002600L & l) != 0L)
jjAddStates(188, 189);
break;
case 395:
if (curChar == 62 && kind > 37)
kind = 37;
break;
case 401:
if (curChar == 35)
jjCheckNAdd(400);
break;
case 402:
case 538:
if (curChar == 47)
jjCheckNAdd(401);
break;
case 403:
if (curChar == 47)
jjCheckNAdd(411);
break;
case 405:
if ((0x100002600L & l) != 0L)
jjAddStates(190, 191);
break;
case 406:
if (curChar == 62 && kind > 38)
kind = 38;
break;
case 412:
if (curChar == 35)
jjCheckNAdd(411);
break;
case 413:
case 539:
if (curChar == 47)
jjCheckNAdd(412);
break;
case 414:
if (curChar == 47)
jjCheckNAdd(424);
break;
case 416:
if ((0x100002600L & l) != 0L)
jjAddStates(192, 193);
break;
case 417:
if (curChar == 62 && kind > 39)
kind = 39;
break;
case 425:
if (curChar == 35)
jjCheckNAdd(424);
break;
case 426:
case 540:
if (curChar == 47)
jjCheckNAdd(425);
break;
case 427:
if (curChar == 47)
jjCheckNAdd(434);
break;
case 429:
if ((0x100002600L & l) != 0L)
jjAddStates(194, 195);
break;
case 430:
if (curChar == 62 && kind > 40)
kind = 40;
break;
case 435:
if (curChar == 35)
jjCheckNAdd(434);
break;
case 436:
case 541:
if (curChar == 47)
jjCheckNAdd(435);
break;
case 437:
if (curChar == 47)
jjCheckNAdd(447);
break;
case 439:
if ((0x100002600L & l) != 0L)
jjAddStates(196, 197);
break;
case 440:
if (curChar == 62 && kind > 41)
kind = 41;
break;
case 448:
if (curChar == 35)
jjCheckNAdd(447);
break;
case 449:
case 542:
if (curChar == 47)
jjCheckNAdd(448);
break;
case 450:
if (curChar == 47)
jjCheckNAdd(461);
break;
case 452:
if ((0x100002600L & l) != 0L)
jjAddStates(198, 199);
break;
case 453:
if (curChar == 62 && kind > 42)
kind = 42;
break;
case 462:
if (curChar == 35)
jjCheckNAdd(461);
break;
case 463:
case 543:
if (curChar == 47)
jjCheckNAdd(462);
break;
case 464:
if (curChar == 47)
jjCheckNAdd(472);
break;
case 466:
if ((0x100002600L & l) != 0L)
jjAddStates(200, 201);
break;
case 467:
if (curChar == 62 && kind > 43)
kind = 43;
break;
case 473:
if (curChar == 35)
jjCheckNAdd(472);
break;
case 474:
case 544:
if (curChar == 47)
jjCheckNAdd(473);
break;
case 475:
if (curChar == 35)
jjCheckNAdd(182);
break;
case 476:
if (curChar == 35)
jjCheckNAdd(190);
break;
case 477:
if (curChar == 35)
jjCheckNAdd(199);
break;
case 478:
if (curChar == 35)
jjCheckNAdd(206);
break;
case 479:
if (curChar == 35)
jjCheckNAdd(214);
break;
case 480:
if (curChar == 35)
jjCheckNAdd(215);
break;
case 481:
if (curChar == 35)
jjCheckNAdd(223);
break;
case 482:
if (curChar == 35)
jjCheckNAdd(228);
break;
case 483:
if (curChar == 35)
jjCheckNAdd(233);
break;
case 484:
if (curChar == 35)
jjCheckNAdd(242);
break;
case 485:
if (curChar == 35)
jjCheckNAdd(251);
break;
case 486:
if (curChar == 35)
jjCheckNAdd(258);
break;
case 487:
if (curChar == 35)
jjCheckNAdd(268);
break;
case 488:
if (curChar == 35)
jjCheckNAdd(276);
break;
case 489:
if (curChar == 35)
jjCheckNAdd(287);
break;
case 490:
if (curChar == 35)
jjCheckNAdd(294);
break;
case 491:
if (curChar == 47)
jjCheckNAdd(499);
break;
case 493:
if ((0x100002600L & l) != 0L)
jjAddStates(202, 203);
break;
case 494:
if (curChar == 62 && kind > 60)
kind = 60;
break;
case 500:
if (curChar == 35)
jjCheckNAdd(499);
break;
case 501:
case 545:
if (curChar == 47)
jjCheckNAdd(500);
break;
case 502:
if (curChar == 35)
jjCheckNAdd(304);
break;
case 503:
if (curChar == 47)
jjCheckNAdd(513);
break;
case 505:
if ((0x100002600L & l) != 0L)
jjAddStates(204, 205);
break;
case 506:
if (curChar == 62 && kind > 62)
kind = 62;
break;
case 514:
if (curChar == 35)
jjCheckNAdd(513);
break;
case 515:
case 546:
if (curChar == 47)
jjCheckNAdd(514);
break;
case 518:
if ((0x100002600L & l) != 0L && kind > 65)
kind = 65;
break;
case 521:
if (curChar == 35)
jjstateSet[jjnewStateCnt++] = 520;
break;
case 523:
if (curChar == 47)
jjstateSet[jjnewStateCnt++] = 524;
break;
case 524:
if (curChar == 62 && kind > 66)
kind = 66;
break;
case 527:
if (curChar == 35)
jjstateSet[jjnewStateCnt++] = 526;
break;
case 528:
if (curChar == 35)
jjstateSet[jjnewStateCnt++] = 529;
break;
case 530:
case 553:
if (curChar == 47)
jjCheckNAdd(528);
break;
case 549:
if (curChar == 35)
jjstateSet[jjnewStateCnt++] = 548;
break;
case 552:
if (curChar == 35)
jjstateSet[jjnewStateCnt++] = 551;
break;
case 554:
if (curChar == 60)
jjAddStates(7, 8);
break;
case 555:
if (curChar == 45 && kind > 29)
kind = 29;
break;
case 556:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 555;
break;
case 557:
if (curChar == 35)
jjstateSet[jjnewStateCnt++] = 556;
break;
case 559:
if (curChar == 36)
jjCheckNAddStates(206, 209);
break;
case 560:
if ((0x3ff001000000000L & l) != 0L)
jjCheckNAddStates(206, 209);
break;
case 561:
if (curChar == 46)
jjstateSet[jjnewStateCnt++] = 562;
break;
case 562:
if (curChar == 36)
jjCheckNAddStates(210, 213);
break;
case 563:
if ((0x3ff001000000000L & l) != 0L)
jjCheckNAddStates(210, 213);
break;
case 564:
if ((0x100002600L & l) != 0L)
jjCheckNAddTwoStates(564, 565);
break;
case 565:
if (curChar == 62 && kind > 64)
kind = 64;
break;
case 566:
if (curChar == 47)
jjstateSet[jjnewStateCnt++] = 558;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 2:
if ((0xf7fffffff7ffffffL & l) != 0L)
{
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
}
else if ((0x800000008000000L & l) != 0L)
{
if (kind > 70)
kind = 70;
}
if (curChar == 91)
jjAddStates(7, 8);
if (curChar == 91)
jjAddStates(214, 274);
break;
case 1:
if ((0xf7fffffff7ffffffL & l) == 0L)
break;
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
break;
case 4:
if (curChar == 116)
jjAddStates(126, 127);
break;
case 6:
if (curChar == 93 && kind > 6)
kind = 6;
break;
case 7:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 4;
break;
case 8:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 7;
break;
case 9:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 8;
break;
case 10:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 9;
break;
case 11:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 10;
break;
case 12:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 11;
break;
case 13:
if (curChar == 114)
jjAddStates(128, 129);
break;
case 15:
if (curChar == 93 && kind > 7)
kind = 7;
break;
case 16:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 13;
break;
case 17:
if (curChar == 118)
jjstateSet[jjnewStateCnt++] = 16;
break;
case 18:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 17;
break;
case 19:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 18;
break;
case 20:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 19;
break;
case 21:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 20;
break;
case 22:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 23;
break;
case 24:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 22;
break;
case 25:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 26;
break;
case 27:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 25;
break;
case 28:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 27;
break;
case 29:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 28;
break;
case 30:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 29;
break;
case 31:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 30;
break;
case 32:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 33;
break;
case 34:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 32;
break;
case 35:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 34;
break;
case 36:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 35;
break;
case 37:
if (curChar == 104)
jjstateSet[jjnewStateCnt++] = 38;
break;
case 39:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 37;
break;
case 40:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 39;
break;
case 41:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 40;
break;
case 42:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 41;
break;
case 43:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 42;
break;
case 44:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 43;
break;
case 45:
if (curChar == 104)
jjstateSet[jjnewStateCnt++] = 46;
break;
case 47:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 45;
break;
case 48:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 47;
break;
case 49:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 48;
break;
case 50:
if (curChar == 119)
jjstateSet[jjnewStateCnt++] = 49;
break;
case 51:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 50;
break;
case 52:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 53;
break;
case 54:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 52;
break;
case 55:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 54;
break;
case 56:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 55;
break;
case 57:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 58;
break;
case 59:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 57;
break;
case 60:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 59;
break;
case 61:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 60;
break;
case 62:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 61;
break;
case 63:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 62;
break;
case 64:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 65;
break;
case 66:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 64;
break;
case 67:
if (curChar == 98)
jjstateSet[jjnewStateCnt++] = 66;
break;
case 68:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 67;
break;
case 69:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 68;
break;
case 70:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 69;
break;
case 71:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 72;
break;
case 73:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 71;
break;
case 74:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 73;
break;
case 75:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 74;
break;
case 76:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 75;
break;
case 77:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 78;
break;
case 79:
if (curChar == 100)
jjstateSet[jjnewStateCnt++] = 77;
break;
case 80:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 79;
break;
case 81:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 80;
break;
case 82:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 81;
break;
case 83:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 82;
break;
case 84:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 83;
break;
case 85:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 86;
break;
case 87:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 85;
break;
case 88:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 87;
break;
case 89:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 88;
break;
case 90:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 89;
break;
case 91:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 90;
break;
case 92:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 93;
break;
case 94:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 92;
break;
case 95:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 94;
break;
case 96:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 95;
break;
case 97:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 96;
break;
case 98:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 97;
break;
case 99:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 98;
break;
case 100:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 99;
break;
case 101:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 102;
break;
case 103:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 101;
break;
case 104:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 103;
break;
case 105:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 104;
break;
case 106:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 105;
break;
case 107:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 108;
break;
case 109:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 107;
break;
case 110:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 109;
break;
case 111:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 110;
break;
case 112:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 111;
break;
case 113:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 112;
break;
case 114:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 113;
break;
case 115:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 114;
break;
case 116:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 115;
break;
case 117:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 118;
break;
case 119:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 117;
break;
case 120:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 119;
break;
case 121:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 120;
break;
case 122:
if (curChar == 118)
jjstateSet[jjnewStateCnt++] = 121;
break;
case 123:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 124;
break;
case 125:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 123;
break;
case 126:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 125;
break;
case 127:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 126;
break;
case 128:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 129;
break;
case 130:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 128;
break;
case 131:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 130;
break;
case 132:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 131;
break;
case 133:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 132;
break;
case 134:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 133;
break;
case 135:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 136;
break;
case 137:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 135;
break;
case 138:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 137;
break;
case 139:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 138;
break;
case 140:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 141;
break;
case 142:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 140;
break;
case 143:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 142;
break;
case 144:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 143;
break;
case 145:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 144;
break;
case 146:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 145;
break;
case 147:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 146;
break;
case 148:
if (curChar == 115)
jjAddStates(130, 131);
break;
case 150:
if (curChar == 93 && kind > 27)
kind = 27;
break;
case 151:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 148;
break;
case 152:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 151;
break;
case 153:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 152;
break;
case 154:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 153;
break;
case 155:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 154;
break;
case 156:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 155;
break;
case 157:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 156;
break;
case 158:
if (curChar == 116)
jjAddStates(132, 133);
break;
case 160:
if (curChar == 93 && kind > 28)
kind = 28;
break;
case 161:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 158;
break;
case 162:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 161;
break;
case 163:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 162;
break;
case 164:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 163;
break;
case 165:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 164;
break;
case 166:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 165;
break;
case 167:
if (curChar == 101)
jjAddStates(134, 135);
break;
case 169:
if (curChar == 93 && kind > 30)
kind = 30;
break;
case 170:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 167;
break;
case 171:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 170;
break;
case 172:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 171;
break;
case 173:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 172;
break;
case 174:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 173;
break;
case 175:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 174;
break;
case 176:
if (curChar == 101)
jjAddStates(136, 138);
break;
case 179:
if (curChar == 93 && kind > 44)
kind = 44;
break;
case 180:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 176;
break;
case 181:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 180;
break;
case 182:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 181;
break;
case 183:
if (curChar == 107)
jjAddStates(139, 141);
break;
case 186:
if (curChar == 93 && kind > 45)
kind = 45;
break;
case 187:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 183;
break;
case 188:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 187;
break;
case 189:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 188;
break;
case 190:
if (curChar == 98)
jjstateSet[jjnewStateCnt++] = 189;
break;
case 191:
if (curChar == 110)
jjAddStates(142, 144);
break;
case 194:
if (curChar == 93 && kind > 46)
kind = 46;
break;
case 195:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 191;
break;
case 196:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 195;
break;
case 197:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 196;
break;
case 198:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 197;
break;
case 199:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 198;
break;
case 200:
if (curChar == 112)
jjAddStates(145, 147);
break;
case 203:
if (curChar == 93 && kind > 47)
kind = 47;
break;
case 204:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 200;
break;
case 205:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 204;
break;
case 206:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 205;
break;
case 207:
if (curChar == 104)
jjAddStates(148, 150);
break;
case 210:
if (curChar == 93 && kind > 48)
kind = 48;
break;
case 211:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 207;
break;
case 212:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 211;
break;
case 213:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 212;
break;
case 214:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 213;
break;
case 215:
if (curChar == 116)
jjAddStates(151, 153);
break;
case 218:
if (curChar == 93 && kind > 49)
kind = 49;
break;
case 219:
if (curChar == 116)
jjAddStates(154, 156);
break;
case 222:
if (curChar == 93 && kind > 50)
kind = 50;
break;
case 223:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 219;
break;
case 224:
if (curChar == 116)
jjAddStates(157, 159);
break;
case 227:
if (curChar == 93 && kind > 51)
kind = 51;
break;
case 228:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 224;
break;
case 229:
if (curChar == 116)
jjAddStates(160, 162);
break;
case 232:
if (curChar == 93 && kind > 52)
kind = 52;
break;
case 233:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 229;
break;
case 234:
if (curChar == 116)
jjAddStates(163, 164);
break;
case 236:
if (curChar == 93 && kind > 53)
kind = 53;
break;
case 237:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 234;
break;
case 238:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 237;
break;
case 239:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 238;
break;
case 240:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 239;
break;
case 241:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 240;
break;
case 242:
if (curChar == 100)
jjstateSet[jjnewStateCnt++] = 241;
break;
case 243:
if (curChar == 100)
jjAddStates(165, 167);
break;
case 246:
if (curChar == 93 && kind > 54)
kind = 54;
break;
case 247:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 243;
break;
case 248:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 247;
break;
case 249:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 248;
break;
case 250:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 249;
break;
case 251:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 250;
break;
case 252:
if (curChar == 100)
jjstateSet[jjnewStateCnt++] = 253;
break;
case 254:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 252;
break;
case 255:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 254;
break;
case 256:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 255;
break;
case 257:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 256;
break;
case 258:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 257;
break;
case 259:
if (curChar == 101)
jjAddStates(168, 170);
break;
case 262:
if (curChar == 93 && kind > 56)
kind = 56;
break;
case 263:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 259;
break;
case 264:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 263;
break;
case 265:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 264;
break;
case 266:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 265;
break;
case 267:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 266;
break;
case 268:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 267;
break;
case 269:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 270;
break;
case 271:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 269;
break;
case 272:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 271;
break;
case 273:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 272;
break;
case 274:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 273;
break;
case 275:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 274;
break;
case 276:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 275;
break;
case 277:
if (curChar == 107)
jjAddStates(171, 173);
break;
case 280:
if (curChar == 93 && kind > 58)
kind = 58;
break;
case 281:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 277;
break;
case 282:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 281;
break;
case 283:
if (curChar == 98)
jjstateSet[jjnewStateCnt++] = 282;
break;
case 284:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 283;
break;
case 285:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 284;
break;
case 286:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 285;
break;
case 287:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 286;
break;
case 288:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 289;
break;
case 290:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 288;
break;
case 291:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 290;
break;
case 292:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 291;
break;
case 293:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 292;
break;
case 294:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 293;
break;
case 295:
if (curChar == 101)
jjAddStates(174, 175);
break;
case 297:
if (curChar == 93 && kind > 61)
kind = 61;
break;
case 298:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 295;
break;
case 299:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 298;
break;
case 300:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 299;
break;
case 301:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 300;
break;
case 302:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 301;
break;
case 303:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 302;
break;
case 304:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 303;
break;
case 331:
if (curChar == 102)
jjAddStates(176, 177);
break;
case 333:
if (curChar == 93 && kind > 31)
kind = 31;
break;
case 334:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 331;
break;
case 338:
if (curChar == 116)
jjAddStates(178, 179);
break;
case 340:
if (curChar == 93 && kind > 32)
kind = 32;
break;
case 341:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 338;
break;
case 342:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 341;
break;
case 343:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 342;
break;
case 347:
if (curChar == 114)
jjAddStates(180, 181);
break;
case 349:
if (curChar == 93 && kind > 33)
kind = 33;
break;
case 350:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 347;
break;
case 351:
if (curChar == 118)
jjstateSet[jjnewStateCnt++] = 350;
break;
case 352:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 351;
break;
case 353:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 352;
break;
case 354:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 353;
break;
case 355:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 354;
break;
case 359:
if (curChar == 116)
jjAddStates(182, 183);
break;
case 361:
if (curChar == 93 && kind > 34)
kind = 34;
break;
case 362:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 359;
break;
case 363:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 362;
break;
case 364:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 363;
break;
case 365:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 364;
break;
case 366:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 365;
break;
case 367:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 366;
break;
case 371:
if (curChar == 104)
jjAddStates(184, 185);
break;
case 373:
if (curChar == 93 && kind > 35)
kind = 35;
break;
case 374:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 371;
break;
case 375:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 374;
break;
case 376:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 375;
break;
case 377:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 376;
break;
case 378:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 377;
break;
case 379:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 378;
break;
case 383:
if (curChar == 108)
jjAddStates(186, 187);
break;
case 385:
if (curChar == 93 && kind > 36)
kind = 36;
break;
case 386:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 383;
break;
case 387:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 386;
break;
case 388:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 387;
break;
case 389:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 388;
break;
case 393:
if (curChar == 108)
jjAddStates(188, 189);
break;
case 395:
if (curChar == 93 && kind > 37)
kind = 37;
break;
case 396:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 393;
break;
case 397:
if (curChar == 98)
jjstateSet[jjnewStateCnt++] = 396;
break;
case 398:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 397;
break;
case 399:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 398;
break;
case 400:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 399;
break;
case 404:
if (curChar == 110)
jjAddStates(190, 191);
break;
case 406:
if (curChar == 93 && kind > 38)
kind = 38;
break;
case 407:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 404;
break;
case 408:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 407;
break;
case 409:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 408;
break;
case 410:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 409;
break;
case 411:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 410;
break;
case 415:
if (curChar == 110)
jjAddStates(192, 193);
break;
case 417:
if (curChar == 93 && kind > 39)
kind = 39;
break;
case 418:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 415;
break;
case 419:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 418;
break;
case 420:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 419;
break;
case 421:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 420;
break;
case 422:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 421;
break;
case 423:
if (curChar == 117)
jjstateSet[jjnewStateCnt++] = 422;
break;
case 424:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 423;
break;
case 428:
if (curChar == 111)
jjAddStates(194, 195);
break;
case 430:
if (curChar == 93 && kind > 40)
kind = 40;
break;
case 431:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 428;
break;
case 432:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 431;
break;
case 433:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 432;
break;
case 434:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 433;
break;
case 438:
if (curChar == 115)
jjAddStates(196, 197);
break;
case 440:
if (curChar == 93 && kind > 41)
kind = 41;
break;
case 441:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 438;
break;
case 442:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 441;
break;
case 443:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 442;
break;
case 444:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 443;
break;
case 445:
if (curChar == 109)
jjstateSet[jjnewStateCnt++] = 444;
break;
case 446:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 445;
break;
case 447:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 446;
break;
case 451:
if (curChar == 109)
jjAddStates(198, 199);
break;
case 453:
if (curChar == 93 && kind > 42)
kind = 42;
break;
case 454:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 451;
break;
case 455:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 454;
break;
case 456:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 455;
break;
case 457:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 456;
break;
case 458:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 457;
break;
case 459:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 458;
break;
case 460:
if (curChar == 114)
jjstateSet[jjnewStateCnt++] = 459;
break;
case 461:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 460;
break;
case 465:
if (curChar == 104)
jjAddStates(200, 201);
break;
case 467:
if (curChar == 93 && kind > 43)
kind = 43;
break;
case 468:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 465;
break;
case 469:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 468;
break;
case 470:
if (curChar == 105)
jjstateSet[jjnewStateCnt++] = 469;
break;
case 471:
if (curChar == 119)
jjstateSet[jjnewStateCnt++] = 470;
break;
case 472:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 471;
break;
case 492:
if (curChar == 101)
jjAddStates(202, 203);
break;
case 494:
if (curChar == 93 && kind > 60)
kind = 60;
break;
case 495:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 492;
break;
case 496:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 495;
break;
case 497:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 496;
break;
case 498:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 497;
break;
case 499:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 498;
break;
case 504:
if (curChar == 101)
jjAddStates(204, 205);
break;
case 506:
if (curChar == 93 && kind > 62)
kind = 62;
break;
case 507:
if (curChar == 112)
jjstateSet[jjnewStateCnt++] = 504;
break;
case 508:
if (curChar == 97)
jjstateSet[jjnewStateCnt++] = 507;
break;
case 509:
if (curChar == 99)
jjstateSet[jjnewStateCnt++] = 508;
break;
case 510:
if (curChar == 115)
jjstateSet[jjnewStateCnt++] = 509;
break;
case 511:
if (curChar == 101)
jjstateSet[jjnewStateCnt++] = 510;
break;
case 512:
if (curChar == 111)
jjstateSet[jjnewStateCnt++] = 511;
break;
case 513:
if (curChar == 110)
jjstateSet[jjnewStateCnt++] = 512;
break;
case 516:
if (curChar == 64 && kind > 63)
kind = 63;
break;
case 517:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 518;
break;
case 519:
case 547:
if (curChar == 116)
jjCheckNAdd(517);
break;
case 520:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 519;
break;
case 522:
if (curChar == 108)
jjAddStates(275, 276);
break;
case 524:
if (curChar == 93 && kind > 66)
kind = 66;
break;
case 525:
case 550:
if (curChar == 116)
jjCheckNAdd(522);
break;
case 526:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 525;
break;
case 529:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
if (kind > 67)
kind = 67;
jjstateSet[jjnewStateCnt++] = 529;
break;
case 531:
if (curChar == 91)
jjAddStates(214, 274);
break;
case 548:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 547;
break;
case 551:
if (curChar == 102)
jjstateSet[jjnewStateCnt++] = 550;
break;
case 554:
if (curChar == 91)
jjAddStates(7, 8);
break;
case 558:
if (curChar == 64)
jjCheckNAddStates(277, 279);
break;
case 559:
case 560:
if ((0x7fffffe87ffffffL & l) != 0L)
jjCheckNAddStates(206, 209);
break;
case 562:
case 563:
if ((0x7fffffe87ffffffL & l) != 0L)
jjCheckNAddStates(210, 213);
break;
case 565:
if (curChar == 93 && kind > 64)
kind = 64;
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 2:
case 1:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
if (kind > 69)
kind = 69;
jjCheckNAdd(1);
break;
case 559:
case 560:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(206, 209);
break;
case 562:
case 563:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(210, 213);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 567 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_2(int pos, long active0, long active1)
{
switch (pos)
{
case 0:
if ((active1 & 0x800000000000L) != 0L)
return 2;
if ((active1 & 0xe0000000180000L) != 0L)
{
jjmatchedKind = 120;
return 34;
}
if ((active1 & 0x8000000000L) != 0L)
return 36;
return -1;
case 1:
if ((active1 & 0x60000000000000L) != 0L)
return 34;
if ((active1 & 0x80000000180000L) != 0L)
{
if (jjmatchedPos != 1)
{
jjmatchedKind = 120;
jjmatchedPos = 1;
}
return 34;
}
return -1;
case 2:
if ((active1 & 0x80000000180000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 2;
return 34;
}
return -1;
case 3:
if ((active1 & 0x100000L) != 0L)
return 34;
if ((active1 & 0x80000000080000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 3;
return 34;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_2(int pos, long active0, long active1)
{
return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0, active1), pos + 1);
}
private final int jjStartNfaWithStates_2(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_2(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_2()
{
switch(curChar)
{
case 33:
jjmatchedKind = 107;
return jjMoveStringLiteralDfa1_2(0x20000000L);
case 37:
return jjStopAtPos(0, 104);
case 40:
return jjStopAtPos(0, 113);
case 41:
return jjStopAtPos(0, 114);
case 42:
jjmatchedKind = 100;
return jjMoveStringLiteralDfa1_2(0x2000000000L);
case 43:
return jjStopAtPos(0, 98);
case 44:
return jjStopAtPos(0, 108);
case 45:
return jjStopAtPos(0, 99);
case 46:
jjmatchedKind = 87;
return jjMoveStringLiteralDfa1_2(0x4001000000L);
case 47:
return jjStartNfaWithStates_2(0, 103, 36);
case 58:
return jjStopAtPos(0, 110);
case 59:
return jjStopAtPos(0, 109);
case 61:
jjmatchedKind = 91;
return jjMoveStringLiteralDfa1_2(0x10000000L);
case 62:
return jjStopAtPos(0, 123);
case 63:
jjmatchedKind = 89;
return jjMoveStringLiteralDfa1_2(0x4000000L);
case 91:
return jjStartNfaWithStates_2(0, 111, 2);
case 93:
return jjStopAtPos(0, 112);
case 97:
return jjMoveStringLiteralDfa1_2(0x40000000000000L);
case 102:
return jjMoveStringLiteralDfa1_2(0x80000L);
case 105:
return jjMoveStringLiteralDfa1_2(0x20000000000000L);
case 116:
return jjMoveStringLiteralDfa1_2(0x100000L);
case 117:
return jjMoveStringLiteralDfa1_2(0x80000000000000L);
case 123:
return jjStopAtPos(0, 115);
case 125:
return jjStopAtPos(0, 116);
default :
return jjMoveNfa_2(1, 0);
}
}
private final int jjMoveStringLiteralDfa1_2(long active1)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_2(0, 0L, active1);
return 1;
}
switch(curChar)
{
case 42:
if ((active1 & 0x2000000000L) != 0L)
return jjStopAtPos(1, 101);
break;
case 46:
if ((active1 & 0x1000000L) != 0L)
{
jjmatchedKind = 88;
jjmatchedPos = 1;
}
return jjMoveStringLiteralDfa2_2(active1, 0x4000000000L);
case 61:
if ((active1 & 0x10000000L) != 0L)
return jjStopAtPos(1, 92);
else if ((active1 & 0x20000000L) != 0L)
return jjStopAtPos(1, 93);
break;
case 63:
if ((active1 & 0x4000000L) != 0L)
return jjStopAtPos(1, 90);
break;
case 97:
return jjMoveStringLiteralDfa2_2(active1, 0x80000L);
case 110:
if ((active1 & 0x20000000000000L) != 0L)
return jjStartNfaWithStates_2(1, 117, 34);
break;
case 114:
return jjMoveStringLiteralDfa2_2(active1, 0x100000L);
case 115:
if ((active1 & 0x40000000000000L) != 0L)
return jjStartNfaWithStates_2(1, 118, 34);
return jjMoveStringLiteralDfa2_2(active1, 0x80000000000000L);
default :
break;
}
return jjStartNfa_2(0, 0L, active1);
}
private final int jjMoveStringLiteralDfa2_2(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_2(0, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_2(1, 0L, active1);
return 2;
}
switch(curChar)
{
case 46:
if ((active1 & 0x4000000000L) != 0L)
return jjStopAtPos(2, 102);
break;
case 105:
return jjMoveStringLiteralDfa3_2(active1, 0x80000000000000L);
case 108:
return jjMoveStringLiteralDfa3_2(active1, 0x80000L);
case 117:
return jjMoveStringLiteralDfa3_2(active1, 0x100000L);
default :
break;
}
return jjStartNfa_2(1, 0L, active1);
}
private final int jjMoveStringLiteralDfa3_2(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_2(1, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_2(2, 0L, active1);
return 3;
}
switch(curChar)
{
case 101:
if ((active1 & 0x100000L) != 0L)
return jjStartNfaWithStates_2(3, 84, 34);
break;
case 110:
return jjMoveStringLiteralDfa4_2(active1, 0x80000000000000L);
case 115:
return jjMoveStringLiteralDfa4_2(active1, 0x80000L);
default :
break;
}
return jjStartNfa_2(2, 0L, active1);
}
private final int jjMoveStringLiteralDfa4_2(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_2(2, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_2(3, 0L, active1);
return 4;
}
switch(curChar)
{
case 101:
if ((active1 & 0x80000L) != 0L)
return jjStartNfaWithStates_2(4, 83, 34);
break;
case 103:
if ((active1 & 0x80000000000000L) != 0L)
return jjStartNfaWithStates_2(4, 119, 34);
break;
default :
break;
}
return jjStartNfa_2(3, 0L, active1);
}
private final int jjMoveNfa_2(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 73;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 36:
if (curChar == 62 && kind > 124)
kind = 124;
break;
case 1:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 85)
kind = 85;
jjCheckNAddStates(280, 282);
}
else if ((0x100002600L & l) != 0L)
{
if (kind > 73)
kind = 73;
jjCheckNAdd(0);
}
else if (curChar == 38)
jjAddStates(283, 287);
else if (curChar == 47)
jjAddStates(288, 289);
else if (curChar == 36)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
}
else if (curChar == 60)
jjCheckNAdd(27);
else if (curChar == 39)
jjCheckNAddStates(290, 292);
else if (curChar == 34)
jjCheckNAddStates(293, 295);
if (curChar == 38)
{
if (kind > 105)
kind = 105;
}
else if (curChar == 60)
{
if (kind > 94)
kind = 94;
}
if (curChar == 60)
jjstateSet[jjnewStateCnt++] = 2;
break;
case 0:
if ((0x100002600L & l) == 0L)
break;
if (kind > 73)
kind = 73;
jjCheckNAdd(0);
break;
case 2:
if ((0xa00000000L & l) != 0L)
jjstateSet[jjnewStateCnt++] = 4;
break;
case 3:
if (curChar == 45 && kind > 74)
kind = 74;
break;
case 4:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 3;
break;
case 5:
if (curChar == 34)
jjCheckNAddStates(293, 295);
break;
case 6:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 8:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 9:
if (curChar == 34 && kind > 81)
kind = 81;
break;
case 11:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 12:
if (curChar == 39)
jjCheckNAddStates(290, 292);
break;
case 13:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 15:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 16:
if (curChar == 39 && kind > 81)
kind = 81;
break;
case 18:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 20:
if (curChar == 34)
jjCheckNAddTwoStates(21, 22);
break;
case 21:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddTwoStates(21, 22);
break;
case 22:
if (curChar == 34 && kind > 82)
kind = 82;
break;
case 23:
if (curChar == 39)
jjCheckNAddTwoStates(24, 25);
break;
case 24:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddTwoStates(24, 25);
break;
case 25:
if (curChar == 39 && kind > 82)
kind = 82;
break;
case 26:
if (curChar == 60 && kind > 94)
kind = 94;
break;
case 27:
if (curChar == 61 && kind > 95)
kind = 95;
break;
case 28:
if (curChar == 60)
jjCheckNAdd(27);
break;
case 29:
case 70:
if (curChar == 38 && kind > 105)
kind = 105;
break;
case 33:
if (curChar != 36)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 34:
if ((0x3ff001000000000L & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 35:
if (curChar == 47)
jjAddStates(288, 289);
break;
case 38:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAddStates(280, 282);
break;
case 39:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAdd(39);
break;
case 40:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(40, 41);
break;
case 41:
if (curChar == 46)
jjCheckNAdd(42);
break;
case 42:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 86)
kind = 86;
jjCheckNAdd(42);
break;
case 56:
if (curChar == 38)
jjAddStates(283, 287);
break;
case 57:
if (curChar == 59 && kind > 94)
kind = 94;
break;
case 60:
if (curChar == 59)
jjCheckNAdd(27);
break;
case 63:
if (curChar == 59 && kind > 96)
kind = 96;
break;
case 66:
if (curChar == 61 && kind > 97)
kind = 97;
break;
case 67:
if (curChar == 59)
jjstateSet[jjnewStateCnt++] = 66;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 36:
if (curChar == 93 && kind > 124)
kind = 124;
break;
case 1:
if ((0x7fffffe87ffffffL & l) != 0L)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
}
else if (curChar == 92)
jjAddStates(296, 299);
else if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 31;
else if (curChar == 91)
jjstateSet[jjnewStateCnt++] = 2;
if (curChar == 103)
jjCheckNAddTwoStates(51, 72);
else if (curChar == 108)
jjCheckNAddTwoStates(44, 46);
else if (curChar == 124)
{
if (kind > 106)
kind = 106;
}
else if (curChar == 114)
jjAddStates(300, 301);
break;
case 6:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 7:
if (curChar == 92)
jjAddStates(302, 303);
break;
case 8:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 10:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 11;
break;
case 11:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 13:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 14:
if (curChar == 92)
jjAddStates(304, 305);
break;
case 15:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 17:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 18;
break;
case 18:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 19:
if (curChar == 114)
jjAddStates(300, 301);
break;
case 21:
jjAddStates(306, 307);
break;
case 24:
jjAddStates(308, 309);
break;
case 30:
case 31:
if (curChar == 124 && kind > 106)
kind = 106;
break;
case 32:
if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 31;
break;
case 33:
case 34:
if ((0x7fffffe87ffffffL & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 43:
if (curChar == 108)
jjCheckNAddTwoStates(44, 46);
break;
case 44:
if (curChar == 116 && kind > 94)
kind = 94;
break;
case 45:
if (curChar == 101 && kind > 95)
kind = 95;
break;
case 46:
case 49:
if (curChar == 116)
jjCheckNAdd(45);
break;
case 47:
if (curChar == 92)
jjAddStates(296, 299);
break;
case 48:
if (curChar == 108)
jjCheckNAdd(44);
break;
case 50:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 49;
break;
case 51:
if (curChar == 116 && kind > 96)
kind = 96;
break;
case 52:
if (curChar == 103)
jjCheckNAdd(51);
break;
case 53:
if (curChar == 101 && kind > 97)
kind = 97;
break;
case 54:
case 72:
if (curChar == 116)
jjCheckNAdd(53);
break;
case 55:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 54;
break;
case 58:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 57;
break;
case 59:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 58;
break;
case 61:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 60;
break;
case 62:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 61;
break;
case 64:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 63;
break;
case 65:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 64;
break;
case 68:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 67;
break;
case 69:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 68;
break;
case 71:
if (curChar == 103)
jjCheckNAddTwoStates(51, 72);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
case 34:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 6:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(293, 295);
break;
case 13:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(290, 292);
break;
case 21:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(306, 307);
break;
case 24:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(308, 309);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 73 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_3(int pos, long active0, long active1)
{
switch (pos)
{
case 0:
if ((active1 & 0x800000000000L) != 0L)
return 2;
if ((active1 & 0xe0000000180000L) != 0L)
{
jjmatchedKind = 120;
return 34;
}
return -1;
case 1:
if ((active1 & 0x60000000000000L) != 0L)
return 34;
if ((active1 & 0x80000000180000L) != 0L)
{
if (jjmatchedPos != 1)
{
jjmatchedKind = 120;
jjmatchedPos = 1;
}
return 34;
}
return -1;
case 2:
if ((active1 & 0x80000000180000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 2;
return 34;
}
return -1;
case 3:
if ((active1 & 0x100000L) != 0L)
return 34;
if ((active1 & 0x80000000080000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 3;
return 34;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_3(int pos, long active0, long active1)
{
return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0, active1), pos + 1);
}
private final int jjStartNfaWithStates_3(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_3(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_3()
{
switch(curChar)
{
case 33:
jjmatchedKind = 107;
return jjMoveStringLiteralDfa1_3(0x20000000L);
case 37:
return jjStopAtPos(0, 104);
case 40:
return jjStopAtPos(0, 113);
case 41:
return jjStopAtPos(0, 114);
case 42:
jjmatchedKind = 100;
return jjMoveStringLiteralDfa1_3(0x2000000000L);
case 43:
return jjStopAtPos(0, 98);
case 44:
return jjStopAtPos(0, 108);
case 45:
return jjStopAtPos(0, 99);
case 46:
jjmatchedKind = 87;
return jjMoveStringLiteralDfa1_3(0x4001000000L);
case 47:
return jjStopAtPos(0, 103);
case 58:
return jjStopAtPos(0, 110);
case 59:
return jjStopAtPos(0, 109);
case 61:
jjmatchedKind = 91;
return jjMoveStringLiteralDfa1_3(0x10000000L);
case 62:
jjmatchedKind = 125;
return jjMoveStringLiteralDfa1_3(0x4000000000000000L);
case 63:
jjmatchedKind = 89;
return jjMoveStringLiteralDfa1_3(0x4000000L);
case 91:
return jjStartNfaWithStates_3(0, 111, 2);
case 93:
return jjStopAtPos(0, 112);
case 97:
return jjMoveStringLiteralDfa1_3(0x40000000000000L);
case 102:
return jjMoveStringLiteralDfa1_3(0x80000L);
case 105:
return jjMoveStringLiteralDfa1_3(0x20000000000000L);
case 116:
return jjMoveStringLiteralDfa1_3(0x100000L);
case 117:
return jjMoveStringLiteralDfa1_3(0x80000000000000L);
case 123:
return jjStopAtPos(0, 115);
case 125:
return jjStopAtPos(0, 116);
default :
return jjMoveNfa_3(1, 0);
}
}
private final int jjMoveStringLiteralDfa1_3(long active1)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_3(0, 0L, active1);
return 1;
}
switch(curChar)
{
case 42:
if ((active1 & 0x2000000000L) != 0L)
return jjStopAtPos(1, 101);
break;
case 46:
if ((active1 & 0x1000000L) != 0L)
{
jjmatchedKind = 88;
jjmatchedPos = 1;
}
return jjMoveStringLiteralDfa2_3(active1, 0x4000000000L);
case 61:
if ((active1 & 0x10000000L) != 0L)
return jjStopAtPos(1, 92);
else if ((active1 & 0x20000000L) != 0L)
return jjStopAtPos(1, 93);
else if ((active1 & 0x4000000000000000L) != 0L)
return jjStopAtPos(1, 126);
break;
case 63:
if ((active1 & 0x4000000L) != 0L)
return jjStopAtPos(1, 90);
break;
case 97:
return jjMoveStringLiteralDfa2_3(active1, 0x80000L);
case 110:
if ((active1 & 0x20000000000000L) != 0L)
return jjStartNfaWithStates_3(1, 117, 34);
break;
case 114:
return jjMoveStringLiteralDfa2_3(active1, 0x100000L);
case 115:
if ((active1 & 0x40000000000000L) != 0L)
return jjStartNfaWithStates_3(1, 118, 34);
return jjMoveStringLiteralDfa2_3(active1, 0x80000000000000L);
default :
break;
}
return jjStartNfa_3(0, 0L, active1);
}
private final int jjMoveStringLiteralDfa2_3(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_3(0, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_3(1, 0L, active1);
return 2;
}
switch(curChar)
{
case 46:
if ((active1 & 0x4000000000L) != 0L)
return jjStopAtPos(2, 102);
break;
case 105:
return jjMoveStringLiteralDfa3_3(active1, 0x80000000000000L);
case 108:
return jjMoveStringLiteralDfa3_3(active1, 0x80000L);
case 117:
return jjMoveStringLiteralDfa3_3(active1, 0x100000L);
default :
break;
}
return jjStartNfa_3(1, 0L, active1);
}
private final int jjMoveStringLiteralDfa3_3(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_3(1, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_3(2, 0L, active1);
return 3;
}
switch(curChar)
{
case 101:
if ((active1 & 0x100000L) != 0L)
return jjStartNfaWithStates_3(3, 84, 34);
break;
case 110:
return jjMoveStringLiteralDfa4_3(active1, 0x80000000000000L);
case 115:
return jjMoveStringLiteralDfa4_3(active1, 0x80000L);
default :
break;
}
return jjStartNfa_3(2, 0L, active1);
}
private final int jjMoveStringLiteralDfa4_3(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_3(2, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_3(3, 0L, active1);
return 4;
}
switch(curChar)
{
case 101:
if ((active1 & 0x80000L) != 0L)
return jjStartNfaWithStates_3(4, 83, 34);
break;
case 103:
if ((active1 & 0x80000000000000L) != 0L)
return jjStartNfaWithStates_3(4, 119, 34);
break;
default :
break;
}
return jjStartNfa_3(3, 0L, active1);
}
private final int jjMoveNfa_3(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 70;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 85)
kind = 85;
jjCheckNAddStates(310, 312);
}
else if ((0x100002600L & l) != 0L)
{
if (kind > 73)
kind = 73;
jjCheckNAdd(0);
}
else if (curChar == 38)
jjAddStates(313, 317);
else if (curChar == 36)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
}
else if (curChar == 60)
jjCheckNAdd(27);
else if (curChar == 39)
jjCheckNAddStates(290, 292);
else if (curChar == 34)
jjCheckNAddStates(293, 295);
if (curChar == 38)
{
if (kind > 105)
kind = 105;
}
else if (curChar == 60)
{
if (kind > 94)
kind = 94;
}
if (curChar == 60)
jjstateSet[jjnewStateCnt++] = 2;
break;
case 0:
if ((0x100002600L & l) == 0L)
break;
if (kind > 73)
kind = 73;
jjCheckNAdd(0);
break;
case 2:
if ((0xa00000000L & l) != 0L)
jjstateSet[jjnewStateCnt++] = 4;
break;
case 3:
if (curChar == 45 && kind > 74)
kind = 74;
break;
case 4:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 3;
break;
case 5:
if (curChar == 34)
jjCheckNAddStates(293, 295);
break;
case 6:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 8:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 9:
if (curChar == 34 && kind > 81)
kind = 81;
break;
case 11:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 12:
if (curChar == 39)
jjCheckNAddStates(290, 292);
break;
case 13:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 15:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 16:
if (curChar == 39 && kind > 81)
kind = 81;
break;
case 18:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 20:
if (curChar == 34)
jjCheckNAddTwoStates(21, 22);
break;
case 21:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddTwoStates(21, 22);
break;
case 22:
if (curChar == 34 && kind > 82)
kind = 82;
break;
case 23:
if (curChar == 39)
jjCheckNAddTwoStates(24, 25);
break;
case 24:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddTwoStates(24, 25);
break;
case 25:
if (curChar == 39 && kind > 82)
kind = 82;
break;
case 26:
if (curChar == 60 && kind > 94)
kind = 94;
break;
case 27:
if (curChar == 61 && kind > 95)
kind = 95;
break;
case 28:
if (curChar == 60)
jjCheckNAdd(27);
break;
case 29:
case 67:
if (curChar == 38 && kind > 105)
kind = 105;
break;
case 33:
if (curChar != 36)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 34:
if ((0x3ff001000000000L & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 35:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAddStates(310, 312);
break;
case 36:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAdd(36);
break;
case 37:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(37, 38);
break;
case 38:
if (curChar == 46)
jjCheckNAdd(39);
break;
case 39:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 86)
kind = 86;
jjCheckNAdd(39);
break;
case 53:
if (curChar == 38)
jjAddStates(313, 317);
break;
case 54:
if (curChar == 59 && kind > 94)
kind = 94;
break;
case 57:
if (curChar == 59)
jjCheckNAdd(27);
break;
case 60:
if (curChar == 59 && kind > 96)
kind = 96;
break;
case 63:
if (curChar == 61 && kind > 97)
kind = 97;
break;
case 64:
if (curChar == 59)
jjstateSet[jjnewStateCnt++] = 63;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
if ((0x7fffffe87ffffffL & l) != 0L)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
}
else if (curChar == 92)
jjAddStates(318, 321);
else if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 31;
else if (curChar == 91)
jjstateSet[jjnewStateCnt++] = 2;
if (curChar == 103)
jjCheckNAddTwoStates(48, 69);
else if (curChar == 108)
jjCheckNAddTwoStates(41, 43);
else if (curChar == 124)
{
if (kind > 106)
kind = 106;
}
else if (curChar == 114)
jjAddStates(300, 301);
break;
case 6:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 7:
if (curChar == 92)
jjAddStates(302, 303);
break;
case 8:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 10:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 11;
break;
case 11:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 13:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 14:
if (curChar == 92)
jjAddStates(304, 305);
break;
case 15:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 17:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 18;
break;
case 18:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 19:
if (curChar == 114)
jjAddStates(300, 301);
break;
case 21:
jjAddStates(306, 307);
break;
case 24:
jjAddStates(308, 309);
break;
case 30:
case 31:
if (curChar == 124 && kind > 106)
kind = 106;
break;
case 32:
if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 31;
break;
case 33:
case 34:
if ((0x7fffffe87ffffffL & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 40:
if (curChar == 108)
jjCheckNAddTwoStates(41, 43);
break;
case 41:
if (curChar == 116 && kind > 94)
kind = 94;
break;
case 42:
if (curChar == 101 && kind > 95)
kind = 95;
break;
case 43:
case 46:
if (curChar == 116)
jjCheckNAdd(42);
break;
case 44:
if (curChar == 92)
jjAddStates(318, 321);
break;
case 45:
if (curChar == 108)
jjCheckNAdd(41);
break;
case 47:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 46;
break;
case 48:
if (curChar == 116 && kind > 96)
kind = 96;
break;
case 49:
if (curChar == 103)
jjCheckNAdd(48);
break;
case 50:
if (curChar == 101 && kind > 97)
kind = 97;
break;
case 51:
case 69:
if (curChar == 116)
jjCheckNAdd(50);
break;
case 52:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 51;
break;
case 55:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 54;
break;
case 56:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 55;
break;
case 58:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 57;
break;
case 59:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 58;
break;
case 61:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 60;
break;
case 62:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 61;
break;
case 65:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 64;
break;
case 66:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 65;
break;
case 68:
if (curChar == 103)
jjCheckNAddTwoStates(48, 69);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
case 34:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 6:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(293, 295);
break;
case 13:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(290, 292);
break;
case 21:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(306, 307);
break;
case 24:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(308, 309);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 70 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_5(int pos, long active0, long active1)
{
switch (pos)
{
default :
return -1;
}
}
private final int jjStartNfa_5(int pos, long active0, long active1)
{
return jjMoveNfa_5(jjStopStringLiteralDfa_5(pos, active0, active1), pos + 1);
}
private final int jjStartNfaWithStates_5(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_5(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_5()
{
switch(curChar)
{
case 45:
return jjStartNfaWithStates_5(0, 78, 3);
default :
return jjMoveNfa_5(1, 0);
}
}
private final int jjMoveNfa_5(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 6;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 3:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 4;
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 2;
break;
case 1:
if ((0xbfffdfffffffffffL & l) != 0L)
{
if (kind > 75)
kind = 75;
jjCheckNAdd(0);
}
else if (curChar == 45)
jjAddStates(322, 323);
break;
case 0:
if ((0xbfffdfffffffffffL & l) == 0L)
break;
kind = 75;
jjCheckNAdd(0);
break;
case 2:
if (curChar == 62)
kind = 79;
break;
case 5:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 4;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
case 0:
if ((0xffffffffdfffffffL & l) == 0L)
break;
kind = 75;
jjCheckNAdd(0);
break;
case 4:
if (curChar == 93)
kind = 79;
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
case 0:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
if (kind > 75)
kind = 75;
jjCheckNAdd(0);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_6(int pos, long active0, long active1)
{
switch (pos)
{
case 0:
if ((active1 & 0x8000000000L) != 0L)
return 32;
if ((active1 & 0xe0000000180000L) != 0L)
{
jjmatchedKind = 120;
return 29;
}
return -1;
case 1:
if ((active1 & 0x80000000180000L) != 0L)
{
if (jjmatchedPos != 1)
{
jjmatchedKind = 120;
jjmatchedPos = 1;
}
return 29;
}
if ((active1 & 0x60000000000000L) != 0L)
return 29;
return -1;
case 2:
if ((active1 & 0x80000000180000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 2;
return 29;
}
return -1;
case 3:
if ((active1 & 0x100000L) != 0L)
return 29;
if ((active1 & 0x80000000080000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 3;
return 29;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_6(int pos, long active0, long active1)
{
return jjMoveNfa_6(jjStopStringLiteralDfa_6(pos, active0, active1), pos + 1);
}
private final int jjStartNfaWithStates_6(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_6(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_6()
{
switch(curChar)
{
case 33:
jjmatchedKind = 107;
return jjMoveStringLiteralDfa1_6(0x20000000L);
case 37:
return jjStopAtPos(0, 104);
case 40:
return jjStopAtPos(0, 113);
case 41:
return jjStopAtPos(0, 114);
case 42:
jjmatchedKind = 100;
return jjMoveStringLiteralDfa1_6(0x2000000000L);
case 43:
return jjStopAtPos(0, 98);
case 44:
return jjStopAtPos(0, 108);
case 45:
return jjStopAtPos(0, 99);
case 46:
jjmatchedKind = 87;
return jjMoveStringLiteralDfa1_6(0x4001000000L);
case 47:
return jjStartNfaWithStates_6(0, 103, 32);
case 58:
return jjStopAtPos(0, 110);
case 59:
return jjStopAtPos(0, 109);
case 61:
jjmatchedKind = 91;
return jjMoveStringLiteralDfa1_6(0x10000000L);
case 62:
return jjStopAtPos(0, 123);
case 63:
jjmatchedKind = 89;
return jjMoveStringLiteralDfa1_6(0x4000000L);
case 91:
return jjStopAtPos(0, 111);
case 93:
return jjStopAtPos(0, 112);
case 97:
return jjMoveStringLiteralDfa1_6(0x40000000000000L);
case 102:
return jjMoveStringLiteralDfa1_6(0x80000L);
case 105:
return jjMoveStringLiteralDfa1_6(0x20000000000000L);
case 116:
return jjMoveStringLiteralDfa1_6(0x100000L);
case 117:
return jjMoveStringLiteralDfa1_6(0x80000000000000L);
case 123:
return jjStopAtPos(0, 115);
case 125:
return jjStopAtPos(0, 116);
default :
return jjMoveNfa_6(0, 0);
}
}
private final int jjMoveStringLiteralDfa1_6(long active1)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_6(0, 0L, active1);
return 1;
}
switch(curChar)
{
case 42:
if ((active1 & 0x2000000000L) != 0L)
return jjStopAtPos(1, 101);
break;
case 46:
if ((active1 & 0x1000000L) != 0L)
{
jjmatchedKind = 88;
jjmatchedPos = 1;
}
return jjMoveStringLiteralDfa2_6(active1, 0x4000000000L);
case 61:
if ((active1 & 0x10000000L) != 0L)
return jjStopAtPos(1, 92);
else if ((active1 & 0x20000000L) != 0L)
return jjStopAtPos(1, 93);
break;
case 63:
if ((active1 & 0x4000000L) != 0L)
return jjStopAtPos(1, 90);
break;
case 97:
return jjMoveStringLiteralDfa2_6(active1, 0x80000L);
case 110:
if ((active1 & 0x20000000000000L) != 0L)
return jjStartNfaWithStates_6(1, 117, 29);
break;
case 114:
return jjMoveStringLiteralDfa2_6(active1, 0x100000L);
case 115:
if ((active1 & 0x40000000000000L) != 0L)
return jjStartNfaWithStates_6(1, 118, 29);
return jjMoveStringLiteralDfa2_6(active1, 0x80000000000000L);
default :
break;
}
return jjStartNfa_6(0, 0L, active1);
}
private final int jjMoveStringLiteralDfa2_6(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_6(0, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_6(1, 0L, active1);
return 2;
}
switch(curChar)
{
case 46:
if ((active1 & 0x4000000000L) != 0L)
return jjStopAtPos(2, 102);
break;
case 105:
return jjMoveStringLiteralDfa3_6(active1, 0x80000000000000L);
case 108:
return jjMoveStringLiteralDfa3_6(active1, 0x80000L);
case 117:
return jjMoveStringLiteralDfa3_6(active1, 0x100000L);
default :
break;
}
return jjStartNfa_6(1, 0L, active1);
}
private final int jjMoveStringLiteralDfa3_6(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_6(1, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_6(2, 0L, active1);
return 3;
}
switch(curChar)
{
case 101:
if ((active1 & 0x100000L) != 0L)
return jjStartNfaWithStates_6(3, 84, 29);
break;
case 110:
return jjMoveStringLiteralDfa4_6(active1, 0x80000000000000L);
case 115:
return jjMoveStringLiteralDfa4_6(active1, 0x80000L);
default :
break;
}
return jjStartNfa_6(2, 0L, active1);
}
private final int jjMoveStringLiteralDfa4_6(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_6(2, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_6(3, 0L, active1);
return 4;
}
switch(curChar)
{
case 101:
if ((active1 & 0x80000L) != 0L)
return jjStartNfaWithStates_6(4, 83, 29);
break;
case 103:
if ((active1 & 0x80000000000000L) != 0L)
return jjStartNfaWithStates_6(4, 119, 29);
break;
default :
break;
}
return jjStartNfa_6(3, 0L, active1);
}
private final int jjMoveNfa_6(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 69;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 32:
if (curChar == 62 && kind > 124)
kind = 124;
break;
case 0:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 85)
kind = 85;
jjCheckNAddStates(324, 326);
}
else if ((0x100002600L & l) != 0L)
{
if (kind > 127)
kind = 127;
jjCheckNAdd(30);
}
else if (curChar == 38)
jjAddStates(327, 331);
else if (curChar == 47)
jjAddStates(332, 333);
else if (curChar == 36)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(29);
}
else if (curChar == 60)
jjCheckNAdd(22);
else if (curChar == 39)
jjCheckNAddStates(334, 336);
else if (curChar == 34)
jjCheckNAddStates(337, 339);
if (curChar == 38)
{
if (kind > 105)
kind = 105;
}
else if (curChar == 60)
{
if (kind > 94)
kind = 94;
}
break;
case 1:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(337, 339);
break;
case 3:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(337, 339);
break;
case 4:
if (curChar == 34 && kind > 81)
kind = 81;
break;
case 6:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(337, 339);
break;
case 7:
if (curChar == 39)
jjCheckNAddStates(334, 336);
break;
case 8:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddStates(334, 336);
break;
case 10:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(334, 336);
break;
case 11:
if (curChar == 39 && kind > 81)
kind = 81;
break;
case 13:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(334, 336);
break;
case 15:
if (curChar == 34)
jjCheckNAddTwoStates(16, 17);
break;
case 16:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddTwoStates(16, 17);
break;
case 17:
if (curChar == 34 && kind > 82)
kind = 82;
break;
case 18:
if (curChar == 39)
jjCheckNAddTwoStates(19, 20);
break;
case 19:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddTwoStates(19, 20);
break;
case 20:
if (curChar == 39 && kind > 82)
kind = 82;
break;
case 21:
if (curChar == 60 && kind > 94)
kind = 94;
break;
case 22:
if (curChar == 61 && kind > 95)
kind = 95;
break;
case 23:
if (curChar == 60)
jjCheckNAdd(22);
break;
case 24:
case 66:
if (curChar == 38 && kind > 105)
kind = 105;
break;
case 28:
if (curChar != 36)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(29);
break;
case 29:
if ((0x3ff001000000000L & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(29);
break;
case 30:
if ((0x100002600L & l) == 0L)
break;
if (kind > 127)
kind = 127;
jjCheckNAdd(30);
break;
case 31:
if (curChar == 47)
jjAddStates(332, 333);
break;
case 34:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAddStates(324, 326);
break;
case 35:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAdd(35);
break;
case 36:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(36, 37);
break;
case 37:
if (curChar == 46)
jjCheckNAdd(38);
break;
case 38:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 86)
kind = 86;
jjCheckNAdd(38);
break;
case 52:
if (curChar == 38)
jjAddStates(327, 331);
break;
case 53:
if (curChar == 59 && kind > 94)
kind = 94;
break;
case 56:
if (curChar == 59)
jjCheckNAdd(22);
break;
case 59:
if (curChar == 59 && kind > 96)
kind = 96;
break;
case 62:
if (curChar == 61 && kind > 97)
kind = 97;
break;
case 63:
if (curChar == 59)
jjstateSet[jjnewStateCnt++] = 62;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 32:
if (curChar == 93 && kind > 124)
kind = 124;
break;
case 0:
if ((0x7fffffe87ffffffL & l) != 0L)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(29);
}
else if (curChar == 92)
jjAddStates(340, 343);
else if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 26;
if (curChar == 103)
jjCheckNAddTwoStates(47, 68);
else if (curChar == 108)
jjCheckNAddTwoStates(40, 42);
else if (curChar == 124)
{
if (kind > 106)
kind = 106;
}
else if (curChar == 114)
jjAddStates(344, 345);
break;
case 1:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(337, 339);
break;
case 2:
if (curChar == 92)
jjAddStates(322, 323);
break;
case 3:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(337, 339);
break;
case 5:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 6;
break;
case 6:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(337, 339);
break;
case 8:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(334, 336);
break;
case 9:
if (curChar == 92)
jjAddStates(0, 1);
break;
case 10:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(334, 336);
break;
case 12:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 13;
break;
case 13:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(334, 336);
break;
case 14:
if (curChar == 114)
jjAddStates(344, 345);
break;
case 16:
jjAddStates(346, 347);
break;
case 19:
jjAddStates(348, 349);
break;
case 25:
case 26:
if (curChar == 124 && kind > 106)
kind = 106;
break;
case 27:
if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 26;
break;
case 28:
case 29:
if ((0x7fffffe87ffffffL & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(29);
break;
case 39:
if (curChar == 108)
jjCheckNAddTwoStates(40, 42);
break;
case 40:
if (curChar == 116 && kind > 94)
kind = 94;
break;
case 41:
if (curChar == 101 && kind > 95)
kind = 95;
break;
case 42:
case 45:
if (curChar == 116)
jjCheckNAdd(41);
break;
case 43:
if (curChar == 92)
jjAddStates(340, 343);
break;
case 44:
if (curChar == 108)
jjCheckNAdd(40);
break;
case 46:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 45;
break;
case 47:
if (curChar == 116 && kind > 96)
kind = 96;
break;
case 48:
if (curChar == 103)
jjCheckNAdd(47);
break;
case 49:
if (curChar == 101 && kind > 97)
kind = 97;
break;
case 50:
case 68:
if (curChar == 116)
jjCheckNAdd(49);
break;
case 51:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 50;
break;
case 54:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 53;
break;
case 55:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 54;
break;
case 57:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 56;
break;
case 58:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 57;
break;
case 60:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 59;
break;
case 61:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 60;
break;
case 64:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 63;
break;
case 65:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 64;
break;
case 67:
if (curChar == 103)
jjCheckNAddTwoStates(47, 68);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 0:
case 29:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(29);
break;
case 1:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(337, 339);
break;
case 8:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(334, 336);
break;
case 16:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(346, 347);
break;
case 19:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(348, 349);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 69 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_4(int pos, long active0, long active1)
{
switch (pos)
{
case 0:
if ((active1 & 0x800000000000L) != 0L)
return 2;
if ((active1 & 0x80020000000L) != 0L)
return 36;
if ((active1 & 0xe0000000180000L) != 0L)
{
jjmatchedKind = 120;
return 34;
}
if ((active1 & 0x8000000000L) != 0L)
return 38;
return -1;
case 1:
if ((active1 & 0x60000000000000L) != 0L)
return 34;
if ((active1 & 0x80000000180000L) != 0L)
{
if (jjmatchedPos != 1)
{
jjmatchedKind = 120;
jjmatchedPos = 1;
}
return 34;
}
return -1;
case 2:
if ((active1 & 0x80000000180000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 2;
return 34;
}
return -1;
case 3:
if ((active1 & 0x100000L) != 0L)
return 34;
if ((active1 & 0x80000000080000L) != 0L)
{
jjmatchedKind = 120;
jjmatchedPos = 3;
return 34;
}
return -1;
default :
return -1;
}
}
private final int jjStartNfa_4(int pos, long active0, long active1)
{
return jjMoveNfa_4(jjStopStringLiteralDfa_4(pos, active0, active1), pos + 1);
}
private final int jjStartNfaWithStates_4(int pos, int kind, int state)
{
jjmatchedKind = kind;
jjmatchedPos = pos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return pos + 1; }
return jjMoveNfa_4(state, pos + 1);
}
private final int jjMoveStringLiteralDfa0_4()
{
switch(curChar)
{
case 33:
jjmatchedKind = 107;
return jjMoveStringLiteralDfa1_4(0x20000000L);
case 37:
return jjStopAtPos(0, 104);
case 40:
return jjStopAtPos(0, 113);
case 41:
return jjStopAtPos(0, 114);
case 42:
jjmatchedKind = 100;
return jjMoveStringLiteralDfa1_4(0x2000000000L);
case 43:
return jjStopAtPos(0, 98);
case 44:
return jjStopAtPos(0, 108);
case 45:
return jjStopAtPos(0, 99);
case 46:
jjmatchedKind = 87;
return jjMoveStringLiteralDfa1_4(0x4001000000L);
case 47:
return jjStartNfaWithStates_4(0, 103, 38);
case 58:
return jjStopAtPos(0, 110);
case 59:
return jjStopAtPos(0, 109);
case 61:
jjmatchedKind = 91;
return jjMoveStringLiteralDfa1_4(0x10000000L);
case 62:
return jjStopAtPos(0, 123);
case 63:
jjmatchedKind = 89;
return jjMoveStringLiteralDfa1_4(0x4000000L);
case 91:
return jjStartNfaWithStates_4(0, 111, 2);
case 93:
return jjStopAtPos(0, 112);
case 97:
return jjMoveStringLiteralDfa1_4(0x40000000000000L);
case 102:
return jjMoveStringLiteralDfa1_4(0x80000L);
case 105:
return jjMoveStringLiteralDfa1_4(0x20000000000000L);
case 116:
return jjMoveStringLiteralDfa1_4(0x100000L);
case 117:
return jjMoveStringLiteralDfa1_4(0x80000000000000L);
case 123:
return jjStopAtPos(0, 115);
case 125:
return jjStopAtPos(0, 116);
default :
return jjMoveNfa_4(1, 0);
}
}
private final int jjMoveStringLiteralDfa1_4(long active1)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_4(0, 0L, active1);
return 1;
}
switch(curChar)
{
case 42:
if ((active1 & 0x2000000000L) != 0L)
return jjStopAtPos(1, 101);
break;
case 46:
if ((active1 & 0x1000000L) != 0L)
{
jjmatchedKind = 88;
jjmatchedPos = 1;
}
return jjMoveStringLiteralDfa2_4(active1, 0x4000000000L);
case 61:
if ((active1 & 0x10000000L) != 0L)
return jjStopAtPos(1, 92);
else if ((active1 & 0x20000000L) != 0L)
return jjStopAtPos(1, 93);
break;
case 63:
if ((active1 & 0x4000000L) != 0L)
return jjStopAtPos(1, 90);
break;
case 97:
return jjMoveStringLiteralDfa2_4(active1, 0x80000L);
case 110:
if ((active1 & 0x20000000000000L) != 0L)
return jjStartNfaWithStates_4(1, 117, 34);
break;
case 114:
return jjMoveStringLiteralDfa2_4(active1, 0x100000L);
case 115:
if ((active1 & 0x40000000000000L) != 0L)
return jjStartNfaWithStates_4(1, 118, 34);
return jjMoveStringLiteralDfa2_4(active1, 0x80000000000000L);
default :
break;
}
return jjStartNfa_4(0, 0L, active1);
}
private final int jjMoveStringLiteralDfa2_4(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_4(0, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_4(1, 0L, active1);
return 2;
}
switch(curChar)
{
case 46:
if ((active1 & 0x4000000000L) != 0L)
return jjStopAtPos(2, 102);
break;
case 105:
return jjMoveStringLiteralDfa3_4(active1, 0x80000000000000L);
case 108:
return jjMoveStringLiteralDfa3_4(active1, 0x80000L);
case 117:
return jjMoveStringLiteralDfa3_4(active1, 0x100000L);
default :
break;
}
return jjStartNfa_4(1, 0L, active1);
}
private final int jjMoveStringLiteralDfa3_4(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_4(1, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_4(2, 0L, active1);
return 3;
}
switch(curChar)
{
case 101:
if ((active1 & 0x100000L) != 0L)
return jjStartNfaWithStates_4(3, 84, 34);
break;
case 110:
return jjMoveStringLiteralDfa4_4(active1, 0x80000000000000L);
case 115:
return jjMoveStringLiteralDfa4_4(active1, 0x80000L);
default :
break;
}
return jjStartNfa_4(2, 0L, active1);
}
private final int jjMoveStringLiteralDfa4_4(long old1, long active1)
{
if (((active1 &= old1)) == 0L)
return jjStartNfa_4(2, 0L, old1);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_4(3, 0L, active1);
return 4;
}
switch(curChar)
{
case 101:
if ((active1 & 0x80000L) != 0L)
return jjStartNfaWithStates_4(4, 83, 34);
break;
case 103:
if ((active1 & 0x80000000000000L) != 0L)
return jjStartNfaWithStates_4(4, 119, 34);
break;
default :
break;
}
return jjStartNfa_4(3, 0L, active1);
}
private final int jjMoveNfa_4(int startState, int curPos)
{
int[] nextStates;
int startsAt = 0;
jjnewStateCnt = 75;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
for (;;)
{
if (++jjround == 0x7fffffff)
ReInitRounds();
if (curChar < 64)
{
long l = 1L << curChar;
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 85)
kind = 85;
jjCheckNAddStates(350, 352);
}
else if ((0x100002600L & l) != 0L)
{
if (kind > 73)
kind = 73;
jjCheckNAdd(0);
}
else if (curChar == 38)
jjAddStates(353, 357);
else if (curChar == 47)
jjAddStates(358, 359);
else if (curChar == 33)
jjCheckNAdd(36);
else if (curChar == 36)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
}
else if (curChar == 60)
jjCheckNAdd(27);
else if (curChar == 39)
jjCheckNAddStates(290, 292);
else if (curChar == 34)
jjCheckNAddStates(293, 295);
if (curChar == 38)
{
if (kind > 105)
kind = 105;
}
else if (curChar == 60)
{
if (kind > 94)
kind = 94;
}
if (curChar == 60)
jjstateSet[jjnewStateCnt++] = 2;
break;
case 38:
if (curChar == 62 && kind > 124)
kind = 124;
break;
case 0:
if ((0x100002600L & l) == 0L)
break;
if (kind > 73)
kind = 73;
jjCheckNAdd(0);
break;
case 2:
if ((0xa00000000L & l) != 0L)
jjstateSet[jjnewStateCnt++] = 4;
break;
case 3:
if (curChar == 45 && kind > 74)
kind = 74;
break;
case 4:
if (curChar == 45)
jjstateSet[jjnewStateCnt++] = 3;
break;
case 5:
if (curChar == 34)
jjCheckNAddStates(293, 295);
break;
case 6:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 8:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 9:
if (curChar == 34 && kind > 81)
kind = 81;
break;
case 11:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 12:
if (curChar == 39)
jjCheckNAddStates(290, 292);
break;
case 13:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 15:
if ((0x9400000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 16:
if (curChar == 39 && kind > 81)
kind = 81;
break;
case 18:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 20:
if (curChar == 34)
jjCheckNAddTwoStates(21, 22);
break;
case 21:
if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddTwoStates(21, 22);
break;
case 22:
if (curChar == 34 && kind > 82)
kind = 82;
break;
case 23:
if (curChar == 39)
jjCheckNAddTwoStates(24, 25);
break;
case 24:
if ((0xffffff7fffffffffL & l) != 0L)
jjCheckNAddTwoStates(24, 25);
break;
case 25:
if (curChar == 39 && kind > 82)
kind = 82;
break;
case 26:
if (curChar == 60 && kind > 94)
kind = 94;
break;
case 27:
if (curChar == 61 && kind > 95)
kind = 95;
break;
case 28:
if (curChar == 60)
jjCheckNAdd(27);
break;
case 29:
case 72:
if (curChar == 38 && kind > 105)
kind = 105;
break;
case 33:
if (curChar != 36)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 34:
if ((0x3ff001000000000L & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 35:
if (curChar == 33)
jjCheckNAdd(36);
break;
case 36:
if ((0x100002600L & l) == 0L)
break;
if (kind > 128)
kind = 128;
jjCheckNAdd(36);
break;
case 37:
if (curChar == 47)
jjAddStates(358, 359);
break;
case 40:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAddStates(350, 352);
break;
case 41:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
jjCheckNAdd(41);
break;
case 42:
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(42, 43);
break;
case 43:
if (curChar == 46)
jjCheckNAdd(44);
break;
case 44:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 86)
kind = 86;
jjCheckNAdd(44);
break;
case 58:
if (curChar == 38)
jjAddStates(353, 357);
break;
case 59:
if (curChar == 59 && kind > 94)
kind = 94;
break;
case 62:
if (curChar == 59)
jjCheckNAdd(27);
break;
case 65:
if (curChar == 59 && kind > 96)
kind = 96;
break;
case 68:
if (curChar == 61 && kind > 97)
kind = 97;
break;
case 69:
if (curChar == 59)
jjstateSet[jjnewStateCnt++] = 68;
break;
default : break;
}
} while(i != startsAt);
}
else if (curChar < 128)
{
long l = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
if ((0x7fffffe87ffffffL & l) != 0L)
{
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
}
else if (curChar == 92)
jjAddStates(360, 363);
else if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 31;
else if (curChar == 91)
jjstateSet[jjnewStateCnt++] = 2;
if (curChar == 103)
jjCheckNAddTwoStates(53, 74);
else if (curChar == 108)
jjCheckNAddTwoStates(46, 48);
else if (curChar == 124)
{
if (kind > 106)
kind = 106;
}
else if (curChar == 114)
jjAddStates(300, 301);
break;
case 38:
if (curChar == 93 && kind > 124)
kind = 124;
break;
case 6:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 7:
if (curChar == 92)
jjAddStates(302, 303);
break;
case 8:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 10:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 11;
break;
case 11:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(293, 295);
break;
case 13:
if ((0xffffffffefffffffL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 14:
if (curChar == 92)
jjAddStates(304, 305);
break;
case 15:
if ((0x81450c610000000L & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 17:
if (curChar == 120)
jjstateSet[jjnewStateCnt++] = 18;
break;
case 18:
if ((0x7e0000007eL & l) != 0L)
jjCheckNAddStates(290, 292);
break;
case 19:
if (curChar == 114)
jjAddStates(300, 301);
break;
case 21:
jjAddStates(306, 307);
break;
case 24:
jjAddStates(308, 309);
break;
case 30:
case 31:
if (curChar == 124 && kind > 106)
kind = 106;
break;
case 32:
if (curChar == 124)
jjstateSet[jjnewStateCnt++] = 31;
break;
case 33:
case 34:
if ((0x7fffffe87ffffffL & l) == 0L)
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 45:
if (curChar == 108)
jjCheckNAddTwoStates(46, 48);
break;
case 46:
if (curChar == 116 && kind > 94)
kind = 94;
break;
case 47:
if (curChar == 101 && kind > 95)
kind = 95;
break;
case 48:
case 51:
if (curChar == 116)
jjCheckNAdd(47);
break;
case 49:
if (curChar == 92)
jjAddStates(360, 363);
break;
case 50:
if (curChar == 108)
jjCheckNAdd(46);
break;
case 52:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 51;
break;
case 53:
if (curChar == 116 && kind > 96)
kind = 96;
break;
case 54:
if (curChar == 103)
jjCheckNAdd(53);
break;
case 55:
if (curChar == 101 && kind > 97)
kind = 97;
break;
case 56:
case 74:
if (curChar == 116)
jjCheckNAdd(55);
break;
case 57:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 56;
break;
case 60:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 59;
break;
case 61:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 60;
break;
case 63:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 62;
break;
case 64:
if (curChar == 108)
jjstateSet[jjnewStateCnt++] = 63;
break;
case 66:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 65;
break;
case 67:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 66;
break;
case 70:
if (curChar == 116)
jjstateSet[jjnewStateCnt++] = 69;
break;
case 71:
if (curChar == 103)
jjstateSet[jjnewStateCnt++] = 70;
break;
case 73:
if (curChar == 103)
jjCheckNAddTwoStates(53, 74);
break;
default : break;
}
} while(i != startsAt);
}
else
{
int hiByte = (int)(curChar >> 8);
int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6;
long l2 = 1L << (curChar & 077);
MatchLoop: do
{
switch(jjstateSet[--i])
{
case 1:
case 34:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
if (kind > 120)
kind = 120;
jjCheckNAdd(34);
break;
case 6:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(293, 295);
break;
case 13:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(290, 292);
break;
case 21:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(306, 307);
break;
case 24:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(308, 309);
break;
default : break;
}
} while(i != startsAt);
}
if (kind != 0x7fffffff)
{
jjmatchedKind = kind;
jjmatchedPos = curPos;
kind = 0x7fffffff;
}
++curPos;
if ((i = jjnewStateCnt) == (startsAt = 75 - (jjnewStateCnt = startsAt)))
return curPos;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { return curPos; }
}
}
static final int[] jjnextStates = {
10, 12, 4, 5, 3, 4, 5, 557, 566, 306, 307, 308, 309, 310, 311, 312,
313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328,
329, 330, 336, 337, 345, 346, 357, 358, 369, 370, 381, 382, 391, 392, 402, 403,
413, 414, 426, 427, 436, 437, 449, 450, 463, 464, 474, 475, 476, 477, 478, 479,
480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 501, 502, 503, 515,
516, 521, 527, 528, 530, 12, 21, 24, 31, 36, 44, 51, 56, 63, 70, 76,
84, 91, 100, 106, 116, 122, 127, 134, 139, 147, 157, 166, 175, 182, 190, 199,
206, 214, 215, 223, 228, 233, 242, 251, 258, 268, 276, 287, 294, 304, 5, 6,
14, 15, 149, 150, 159, 160, 168, 169, 177, 178, 179, 184, 185, 186, 192, 193,
194, 201, 202, 203, 208, 209, 210, 216, 217, 218, 220, 221, 222, 225, 226, 227,
230, 231, 232, 235, 236, 244, 245, 246, 260, 261, 262, 278, 279, 280, 296, 297,
332, 333, 339, 340, 348, 349, 360, 361, 372, 373, 384, 385, 394, 395, 405, 406,
416, 417, 429, 430, 439, 440, 452, 453, 466, 467, 493, 494, 505, 506, 560, 561,
564, 565, 561, 563, 564, 565, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315,
316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 532, 533,
534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 475, 476, 477, 478, 479,
480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 545, 502, 546, 516, 549,
552, 528, 553, 523, 524, 559, 564, 565, 39, 40, 41, 59, 62, 65, 69, 70,
36, 37, 13, 14, 16, 6, 7, 9, 48, 50, 52, 55, 20, 23, 8, 10,
15, 17, 21, 22, 24, 25, 36, 37, 38, 56, 59, 62, 66, 67, 45, 47,
49, 52, 3, 5, 35, 36, 37, 55, 58, 61, 65, 66, 32, 33, 8, 9,
11, 1, 2, 4, 44, 46, 48, 51, 15, 18, 16, 17, 19, 20, 41, 42,
43, 61, 64, 67, 71, 72, 38, 39, 50, 52, 54, 57,
};
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
{
switch(hiByte)
{
case 0:
return ((jjbitVec2[i2] & l2) != 0L);
default :
if ((jjbitVec0[i1] & l1) != 0L)
return true;
return false;
}
}
private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
{
switch(hiByte)
{
case 0:
return ((jjbitVec4[i2] & l2) != 0L);
case 48:
return ((jjbitVec5[i2] & l2) != 0L);
case 49:
return ((jjbitVec6[i2] & l2) != 0L);
case 51:
return ((jjbitVec7[i2] & l2) != 0L);
case 61:
return ((jjbitVec8[i2] & l2) != 0L);
default :
if ((jjbitVec3[i1] & l1) != 0L)
return true;
return false;
}
}
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, "\44\173", "\43\173", null, null, null, null, null, null, null, null,
null, null, "\146\141\154\163\145", "\164\162\165\145", null, null, "\56", "\56\56",
"\77", "\77\77", "\75", "\75\75", "\41\75", null, null, null, null, "\53", "\55",
"\52", "\52\52", "\56\56\56", "\57", "\45", null, null, "\41", "\54", "\73", "\72",
"\133", "\135", "\50", "\51", "\173", "\175", "\151\156", "\141\163",
"\165\163\151\156\147", null, null, null, "\76", null, "\76", "\76\75", null, null, null, null, null,
null, };
public static final String[] lexStateNames = {
"DEFAULT",
"NODIRECTIVE",
"FM_EXPRESSION",
"IN_PAREN",
"NAMED_PARAMETER_EXPRESSION",
"EXPRESSION_COMMENT",
"NO_SPACE_EXPRESSION",
"NO_PARSE",
};
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, -1, 5,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 2, 2, -1, -1, -1, -1,
};
static final long[] jjtoToken = {
0xffffffffffffffc1L, 0xf9fffffffffe01ffL, 0x1fL,
};
static final long[] jjtoSkip = {
0x0L, 0xfe00L, 0x0L,
};
protected SimpleCharStream input_stream;
private final int[] jjrounds = new int[567];
private final int[] jjstateSet = new int[1134];
StringBuffer image;
int jjimageLen;
int lengthOfMatch;
protected char curChar;
public FMParserTokenManager(SimpleCharStream stream)
{
if (SimpleCharStream.staticFlag)
throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
input_stream = stream;
}
public FMParserTokenManager(SimpleCharStream stream, int lexState)
{
this(stream);
SwitchTo(lexState);
}
public void ReInit(SimpleCharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
input_stream = stream;
ReInitRounds();
}
private final void ReInitRounds()
{
int i;
jjround = 0x80000001;
for (i = 567; i-- > 0;)
jjrounds[i] = 0x80000000;
}
public void ReInit(SimpleCharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
}
public void SwitchTo(int lexState)
{
if (lexState >= 8 || lexState < 0)
throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
else
curLexState = lexState;
}
protected Token jjFillToken()
{
Token t = Token.newToken(jjmatchedKind);
t.kind = jjmatchedKind;
String im = jjstrLiteralImages[jjmatchedKind];
t.image = (im == null) ? input_stream.GetImage() : im;
t.beginLine = input_stream.getBeginLine();
t.beginColumn = input_stream.getBeginColumn();
t.endLine = input_stream.getEndLine();
t.endColumn = input_stream.getEndColumn();
return t;
}
int curLexState = 0;
int defaultLexState = 0;
int jjnewStateCnt;
int jjround;
int jjmatchedPos;
int jjmatchedKind;
public Token getNextToken()
{
int kind;
Token specialToken = null;
Token matchedToken;
int curPos = 0;
EOFLoop :
for (;;)
{
try
{
curChar = input_stream.BeginToken();
}
catch(java.io.IOException e)
{
jjmatchedKind = 0;
matchedToken = jjFillToken();
return matchedToken;
}
image = null;
jjimageLen = 0;
switch(curLexState)
{
case 0:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_0();
break;
case 1:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_1();
break;
case 2:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_2();
break;
case 3:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_3();
break;
case 4:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_4();
break;
case 5:
try { input_stream.backup(0);
while ((curChar < 64 && (0x4000000000000000L & (1L << curChar)) != 0L) ||
(curChar >> 6) == 1 && (0x20000000L & (1L << (curChar & 077))) != 0L)
curChar = input_stream.BeginToken();
}
catch (java.io.IOException e1) { continue EOFLoop; }
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_5();
break;
case 6:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_6();
break;
case 7:
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_7();
break;
}
if (jjmatchedKind != 0x7fffffff)
{
if (jjmatchedPos + 1 < curPos)
input_stream.backup(curPos - jjmatchedPos - 1);
if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
{
matchedToken = jjFillToken();
TokenLexicalActions(matchedToken);
if (jjnewLexState[jjmatchedKind] != -1)
curLexState = jjnewLexState[jjmatchedKind];
return matchedToken;
}
else
{
SkipLexicalActions(null);
if (jjnewLexState[jjmatchedKind] != -1)
curLexState = jjnewLexState[jjmatchedKind];
continue EOFLoop;
}
}
int error_line = input_stream.getEndLine();
int error_column = input_stream.getEndColumn();
String error_after = null;
boolean EOFSeen = false;
try { input_stream.readChar(); input_stream.backup(1); }
catch (java.io.IOException e1) {
EOFSeen = true;
error_after = curPos <= 1 ? "" : input_stream.GetImage();
if (curChar == '\n' || curChar == '\r') {
error_line++;
error_column = 0;
}
else
error_column++;
}
if (!EOFSeen) {
input_stream.backup(1);
error_after = curPos <= 1 ? "" : input_stream.GetImage();
}
throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
}
}
void SkipLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
case 79 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
if (parenthesisNesting >0) SwitchTo(IN_PAREN); else if (inInvocation) SwitchTo(NAMED_PARAMETER_EXPRESSION); else SwitchTo(FM_EXPRESSION);
break;
default :
break;
}
}
void TokenLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
case 6 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 7 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 8 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 9 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 10 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 11 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 12 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 13 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 14 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 15 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 16 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 17 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 18 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 19 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 20 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 21 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 22 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 23 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 24 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 25 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 26 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 27 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 28 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, NO_PARSE); noparseTag="comment";
break;
case 29 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
noparseTag = "-->"; strictSyntaxCheck(matchedToken, NO_PARSE);
break;
case 30 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, NO_PARSE); noparseTag="noparse";
break;
case 31 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 32 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 33 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 34 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 35 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 36 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 37 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 38 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 39 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 40 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 41 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 42 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 43 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 44 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 45 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 46 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 47 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 48 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 49 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 50 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 51 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 52 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 53 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 54 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 55 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 56 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 57 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 58 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 59 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, FM_EXPRESSION);
break;
case 60 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 61 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 62 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
strictSyntaxCheck(matchedToken, DEFAULT);
break;
case 63 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
unifiedCall(matchedToken);
break;
case 64 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
unifiedCallEnd(matchedToken);
break;
case 65 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
ftlHeader(matchedToken);
break;
case 66 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
ftlHeader(matchedToken);
break;
case 67 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
if (!directiveSyntaxEstablished && incompatibleChanges < 2003019) {
matchedToken.kind = PRINTABLE_CHARS;
} else {
char firstChar = matchedToken.image.charAt(0);
if (!directiveSyntaxEstablished && autodetectTagSyntax) {
altDirectiveSyntax = (firstChar == '[');
directiveSyntaxEstablished = true;
}
if (firstChar == '<' && altDirectiveSyntax) {
matchedToken.kind = PRINTABLE_CHARS;
} else if (firstChar == '[' && !altDirectiveSyntax) {
matchedToken.kind = PRINTABLE_CHARS;
} else if (strictEscapeSyntax) {
String s = matchedToken.image;
int index = s.indexOf('#');
s = s.substring(index);
String msg = "Unknown directive: "
+ s
+ " on line: " + matchedToken.beginLine
+ ", column: " + matchedToken.beginColumn +1
+ ", in template: " + templateName;
throw new TokenMgrError(msg, TokenMgrError.LEXICAL_ERROR);
}
}
break;
case 111 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[111]);
else
image.append(jjstrLiteralImages[111]);
++bracketNesting;
break;
case 112 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[112]);
else
image.append(jjstrLiteralImages[112]);
closeBracket(matchedToken);
break;
case 113 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[113]);
else
image.append(jjstrLiteralImages[113]);
++parenthesisNesting;
if (parenthesisNesting == 1)
SwitchTo(IN_PAREN);
break;
case 114 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[114]);
else
image.append(jjstrLiteralImages[114]);
--parenthesisNesting;
if (parenthesisNesting == 0) {
if (inInvocation) SwitchTo(NAMED_PARAMETER_EXPRESSION);
else SwitchTo(FM_EXPRESSION);
}
break;
case 115 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[115]);
else
image.append(jjstrLiteralImages[115]);
++hashLiteralNesting;
break;
case 116 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[116]);
else
image.append(jjstrLiteralImages[116]);
if (hashLiteralNesting == 0)
SwitchTo(DEFAULT);
else
--hashLiteralNesting;
break;
case 123 :
if (image == null)
image = new StringBuffer(jjstrLiteralImages[123]);
else
image.append(jjstrLiteralImages[123]);
if (inFTLHeader) eatNewline();
inFTLHeader = false;
if (altDirectiveSyntax) {
matchedToken.kind = NATURAL_GT;
} else {
SwitchTo(DEFAULT);
}
break;
case 124 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
if (inFTLHeader) eatNewline(); inFTLHeader = false; SwitchTo(DEFAULT);
break;
case 129 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
if (noparseTag.equals("-->")) {
boolean squareBracket = matchedToken.image.endsWith("]");
if ((altDirectiveSyntax && squareBracket) || (!altDirectiveSyntax && !squareBracket))
SwitchTo(DEFAULT);
}
break;
case 130 :
if (image == null)
image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
else
image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
StringTokenizer st = new StringTokenizer(image.toString(),
" \t\n\r<>[]/#",
false);
if (st.nextToken().equals(noparseTag)) {
SwitchTo(DEFAULT);
}
break;
default :
break;
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/ReturnInstruction.java 0000644 0001750 0001750 00000007503 11723544471 026071 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.TemplateException;
/**
* Represents a <return> instruction to jump out of a macro.
* @author Jonathan Revusky
*/
public final class ReturnInstruction extends TemplateElement {
private Expression exp;
ReturnInstruction(Expression exp) {
this.exp = exp;
}
void accept(Environment env) throws TemplateException {
if (exp != null) {
env.setLastReturnValue(exp.getAsTemplateModel(env));
}
if (nextSibling() != null) {
// We need to jump out using an exception.
throw Return.INSTANCE;
}
if (!(getParent() instanceof Macro || getParent().getParent() instanceof Macro)) {
// Here also, we need to jump out using an exception.
throw Return.INSTANCE;
}
}
public String getCanonicalForm() {
String expString = exp == null ? "" : " " + exp.getCanonicalForm();
return "<#return" + expString + "/>";
}
public String getDescription() {
return "return" + " [" + getStartLocation() + "]";
}
public static class Return extends RuntimeException {
static final Return INSTANCE = new Return();
private Return() {
}
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/NotExpression.java 0000644 0001750 0001750 00000006246 11723544471 025173 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
package freemarker.core;
import freemarker.template.TemplateException;
final class NotExpression extends BooleanExpression {
private final Expression target;
NotExpression(Expression target) {
this.target = target;
}
boolean isTrue(Environment env) throws TemplateException {
return (!target.isTrue(env));
}
public String getCanonicalForm() {
return "!" + target.getCanonicalForm();
}
boolean isLiteral() {
return target.isLiteral();
}
Expression _deepClone(String name, Expression subst) {
return new NotExpression(target.deepClone(name, subst));
}
}
libfreemarker-java-2.3.19.orig/src/freemarker/core/FMParser.jj 0000644 0001750 0001750 00000233446 11723544470 023517 0 ustar ebourg ebourg /*
* Copyright (c) 2003 The Visigoth Software Society. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Visigoth Software Society (http://www.visigoths.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. Neither the name "FreeMarker", "Visigoth", nor any of the names of the
* project contributors may be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact visigoths@visigoths.org.
*
* 5. Products derived from this software may not be called "FreeMarker" or "Visigoth"
* nor may "FreeMarker" or "Visigoth" appear in their names
* without prior written permission of the Visigoth Software Society.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE VISIGOTH SOFTWARE SOCIETY OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Visigoth Software Society. For more
* information on the Visigoth Software Society, please see
* http://www.visigoths.org/
*/
options
{
STATIC=false;
UNICODE_INPUT=true;
LEXER_CLASS="FMParserTokenManager";
CONSTANTS_CLASS="FMParserConstants";
// DEBUG_TOKEN_MANAGER=true;
// DEBUG_PARSER=true;
}
PARSER_BEGIN(FMParser)
package freemarker.core;
import freemarker.template.*;
import freemarker.template.utility.StringUtil;
import freemarker.template.utility.DeepUnwrap;
import java.io.*;
import java.util.*;
/**
* This class is generated by JavaCC from a grammar file.
*/
public class FMParser {
// Necessary for adding macros and setting location info.
Template template;
private String templateName;
// variables that keep track of whether we are in a loop or a switch.
private int loopNesting, switchNesting;
private boolean inMacro, inFunction, stripWhitespace, stripText;
private LinkedList escapes = new LinkedList();
private int contentNesting; // for stripText
/**
* Create an FM expression parser using a string.
*/
static public FMParser createExpressionParser(String s) {
SimpleCharStream scs = new SimpleCharStream(new StringReader(s), 1, 1, s.length());
FMParserTokenManager token_source = new FMParserTokenManager(scs);
token_source.SwitchTo(FMParserConstants.FM_EXPRESSION);
return new FMParser(token_source);
}
/**
* Constructs a new parser object.
* @param template The template associated with this parser.
* @param reader The character stream to use as input
* @param strictEscapeSyntax Whether FreeMarker directives must start with a #
*/
public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace) {
this(reader);
this.template = template;
token_source.strictEscapeSyntax = strictEscapeSyntax;
this.templateName = template != null ? template.getName() : "";
token_source.templateName = templateName;
this.stripWhitespace = stripWhitespace;
}
public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace, int tagSyntax) {
this(template, reader, strictEscapeSyntax, stripWhitespace, tagSyntax, Configuration.PARSED_DEFAULT_INCOMPATIBLE_ENHANCEMENTS);
}
public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace, int tagSyntax, int incompatibleChanges) {
this(template, reader, strictEscapeSyntax, stripWhitespace);
switch (tagSyntax) {
case Configuration.AUTO_DETECT_TAG_SYNTAX :
token_source.autodetectTagSyntax = true;
break;
case Configuration.ANGLE_BRACKET_TAG_SYNTAX :
token_source.altDirectiveSyntax = false;
break;
case Configuration.SQUARE_BRACKET_TAG_SYNTAX :
token_source.altDirectiveSyntax = true;
break;
default : throw new IllegalArgumentException("Illegal argument for tagSyntax");
}
token_source.incompatibleChanges = incompatibleChanges;
}
public FMParser(String template) {
this(null, new StringReader(template), true, true);
}
private String getErrorStart(Token t) {
return "Error in template: " + template.getName()
+ "\non line " + t.beginLine + ", column " + t.beginColumn;
}
/**
* Throw an exception if the expression passed in is a String
* Literal
*/
private void notStringLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof StringLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound string literal: " + exp
+ "\nExpecting: " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a Number
* Literal
*/
private void notNumberLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof NumberLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound number literal: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a boolean
* Literal
*/
private void notBooleanLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof BooleanLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a Hash
* Literal
*/
private void notHashLiteral(Expression exp, String expected) throws ParseException {
if (exp instanceof HashLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound hash literal: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a List
* Literal
*/
private void notListLiteral(Expression exp, String expected)
throws ParseException
{
if (exp instanceof ListLiteral) {
String msg = "Error " + exp.getStartLocation()
+ "\nFound list literal: " + exp.getCanonicalForm()
+ "\nExpecting " + expected;
throw new ParseException(msg, exp);
}
}
/**
* Throw an exception if the expression passed in is a literal
* other than of the numerical type
*/
private void numberLiteralOnly(Expression exp) throws ParseException {
notStringLiteral(exp, "number");
notListLiteral(exp, "number");
notHashLiteral(exp, "number");
notBooleanLiteral(exp, "number");
}
/**
* Throw an exception if the expression passed in is
* not a string.
*/
private void stringLiteralOnly(Expression exp) throws ParseException {
notNumberLiteral(exp, "number");
notListLiteral(exp, "number");
notHashLiteral(exp, "number");
notBooleanLiteral(exp, "number");
}
/**
* Throw an exception if the expression passed in is a literal
* other than of the boolean type
*/
private void booleanLiteralOnly(Expression exp) throws ParseException {
notStringLiteral(exp, "boolean (true/false)");
notListLiteral(exp, "boolean (true/false)");
notHashLiteral(exp, "boolean (true/false)");
notNumberLiteral(exp, "boolean (true/false)");
}
private Expression escapedExpression(Expression exp) {
if(!escapes.isEmpty()) {
return ((EscapeBlock)escapes.getFirst()).doEscape(exp);
}
return exp;
}
private boolean getBoolean(Expression exp) throws ParseException {
TemplateModel tm = null;
try {
tm = exp.getAsTemplateModel(null);
} catch (Exception e) {
throw new ParseException(e.getMessage()
+ "\nCould not evaluate expression: "
+ exp.getCanonicalForm()
+ exp.getStartLocation(), exp);
}
if (tm instanceof TemplateBooleanModel) {
try {
return ((TemplateBooleanModel) tm).getAsBoolean();
} catch (TemplateModelException tme) {
}
}
if (tm instanceof TemplateScalarModel) {
try {
return StringUtil.getYesNo(((TemplateScalarModel) tm).getAsString());
} catch (Exception e) {
throw new ParseException(e.getMessage()
+ "\nExpecting yes/no, found: " + exp.getCanonicalForm()
+ exp.getStartLocation(), exp);
}
}
throw new ParseException("Expecting boolean (yes/no) parameter" + exp.getStartLocation(), exp);
}
}
PARSER_END(FMParser)
/**
* The lexer portion defines 5 lexical states:
* DEFAULT, FM_EXPRESSION, IN_PAREN, NO_PARSE, and EXPRESSION_COMMENT.
* The DEFAULT state is when you are parsing
* text but are not inside a FreeMarker expression.
* FM_EXPRESSION is the state you are in
* when the parser wants a FreeMarker expression.
* IN_PAREN is almost identical really. The difference
* is that you are in this state when you are within
* FreeMarker expression and also within (...).
* This is a necessary subtlety because the
* ">" and ">=" symbols can only be used
* within parentheses because otherwise, it would
* be ambiguous with the end of a directive.
* So, for example, you enter the FM_EXPRESSION state
* right after a ${ and leave it after the matching }.
* Or, you enter the FM_EXPRESSION state right after
* an ""
* that ends the if directive,
* you go back to DEFAULT lexical state.
* If, within the FM_EXPRESSION state, you enter a
* parenthetical expression, you enter the IN_PAREN
* state.
* Note that whitespace is ignored in the
* FM_EXPRESSION and IN_PAREN states
* but is passed through to the parser as PCDATA in the DEFAULT state.
* NO_PARSE and EXPRESSION_COMMENT are extremely simple
* lexical states. NO_PARSE is when you are in a comment
* block and EXPRESSION_COMMENT is when you are in a comment
* that is within an FTL expression.
*/
TOKEN_MGR_DECLS :
{
/**
The noparseTag is set when we enter
a block of text that the parser more or less ignores.
These are and . This variable
tells us what the closing tag should be, and when
we hit that, we resume parsing. Note that with this
scheme, and tags cannot nest
recursively, but it is not clear how important that is.
*/
String noparseTag;
/**
Keeps track of how deeply nested
we have the hash literals.
This is necessary since we need to be
able to distinguish the } used to close
a hash literal and the one used to
close a ${
*/
private int hashLiteralNesting;
private int parenthesisNesting;
private int bracketNesting;
private boolean inFTLHeader;
boolean strictEscapeSyntax,
onlyTextOutput,
altDirectiveSyntax,
autodetectTagSyntax,
directiveSyntaxEstablished,
inInvocation;
int incompatibleChanges;
String templateName;
// This method checks if we are in a strict mode where all
// FreeMarker directives must start with <#. It also handled
// tag syntax detection. If you update this logic, take a look
// at the UNKNOWN_DIRECTIVE token too.
private void strictSyntaxCheck(Token tok, int newLexState) {
if (onlyTextOutput) {
tok.kind = PRINTABLE_CHARS;
return;
}
char firstChar = tok.image.charAt(0);
if (autodetectTagSyntax && !directiveSyntaxEstablished) {
altDirectiveSyntax = (firstChar == '[');
}
if ((firstChar == '[' && !altDirectiveSyntax) || (firstChar == '<' && altDirectiveSyntax)) {
tok.kind = PRINTABLE_CHARS;
return;
}
if (!strictEscapeSyntax) {
SwitchTo(newLexState);
return;
}
if (!altDirectiveSyntax) {
if (!tok.image.startsWith("<#") && !tok.image.startsWith("#")) {
tok.kind = PRINTABLE_CHARS;
return;
}
}
directiveSyntaxEstablished = true;
SwitchTo(newLexState);
}
private void unifiedCall(Token tok) {
char firstChar = tok.image.charAt(0);
if (autodetectTagSyntax && !directiveSyntaxEstablished) {
altDirectiveSyntax = (firstChar == '[');
}
if (altDirectiveSyntax && firstChar == '<') {
tok.kind = PRINTABLE_CHARS;
return;
}
if (!altDirectiveSyntax && firstChar == '[') {
tok.kind = PRINTABLE_CHARS;
return;
}
directiveSyntaxEstablished = true;
SwitchTo(NO_SPACE_EXPRESSION);
}
private void unifiedCallEnd(Token tok) {
char firstChar = tok.image.charAt(0);
if (altDirectiveSyntax && firstChar == '<') {
tok.kind = PRINTABLE_CHARS;
return;
}
if (!altDirectiveSyntax && firstChar == '[') {
tok.kind = PRINTABLE_CHARS;
return;
}
}
private void closeBracket(Token tok) {
if (bracketNesting >0) {
--bracketNesting;
} else {
tok.kind=DIRECTIVE_END;
if (inFTLHeader) {
eatNewline();
inFTLHeader = false;
}
SwitchTo(DEFAULT);
}
}
private void eatNewline() {
int charsRead = 0;
try {
while (true) {
char c = input_stream.readChar();
++charsRead;
if (!Character.isWhitespace(c)) {
input_stream.backup(charsRead);
return;
} else if (c=='\r') {
char next = input_stream.readChar();
++charsRead;
if (next != '\n') {
input_stream.backup(1);
}
return;
} else if (c=='\n') {
return;
}
}
} catch (IOException ioe) {
input_stream.backup(charsRead);
}
}
private void ftlHeader(Token matchedToken) {
if (!directiveSyntaxEstablished) {
altDirectiveSyntax = matchedToken.image.charAt(0) == '[';
directiveSyntaxEstablished = true;
autodetectTagSyntax = false;
}
String img = matchedToken.image;
char firstChar = img.charAt(0);
char lastChar = img.charAt(img.length() -1);
if ((firstChar == '[' && !altDirectiveSyntax) || (firstChar == '<' && altDirectiveSyntax)) {
matchedToken.kind = PRINTABLE_CHARS;
}
if (matchedToken.kind != PRINTABLE_CHARS) {
if (lastChar != '>' && lastChar != ']') {
SwitchTo(FM_EXPRESSION);
inFTLHeader = true;
} else {
eatNewline();
}
}
}
}
TOKEN:
{
<#BLANK : [" ", "\t", "\n", "\r"]>
|
<#START_TAG : "<" | "<#" | "[#">
|
<#END_TAG : "" | "#" | "[/#">
|
<#CLOSE_TAG1 : ()* (">" | "]")>
|
<#CLOSE_TAG2 : ()* ("/")? (">" | "]")>
|
"attempt" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"recover" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"if" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"elseif" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"list" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"foreach" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"switch" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"case" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"assign" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"global" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"local" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
<_INCLUDE : "include" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"import" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"function" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"macro" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"transform" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"visit" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"stop" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"return" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"call" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"setting" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"compress" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"comment" > {strictSyntaxCheck(matchedToken, NO_PARSE); noparseTag="comment";}
|
{noparseTag = "-->"; strictSyntaxCheck(matchedToken, NO_PARSE); }
|
"noparse" > {strictSyntaxCheck(matchedToken, NO_PARSE); noparseTag="noparse";}
|
"if" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"list" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"recover" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"attempt" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"foreach" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"local" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"global" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"assign" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"function" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"macro" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"compress" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"transform" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"switch" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"else" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"break" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"return" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"stop" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"flush" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"t" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"lt" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"rt" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"nt" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"default" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"nested" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"nested" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"recurse" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"recurse" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"fallback" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"escape" > {strictSyntaxCheck(matchedToken, FM_EXPRESSION);}
|
"escape" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"noescape" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
"noescape" > {strictSyntaxCheck(matchedToken, DEFAULT);}
|
{unifiedCall(matchedToken);}
|
) (".")*)? > {unifiedCallEnd(matchedToken);}
|
> {ftlHeader(matchedToken);}
|
" | "]")> {ftlHeader(matchedToken);}
|
{
if (!directiveSyntaxEstablished && incompatibleChanges < 2003019) {
matchedToken.kind = PRINTABLE_CHARS;
} else {
char firstChar = matchedToken.image.charAt(0);
if (!directiveSyntaxEstablished && autodetectTagSyntax) {
altDirectiveSyntax = (firstChar == '[');
directiveSyntaxEstablished = true;
}
if (firstChar == '<' && altDirectiveSyntax) {
matchedToken.kind = PRINTABLE_CHARS;
} else if (firstChar == '[' && !altDirectiveSyntax) {
matchedToken.kind = PRINTABLE_CHARS;
} else if (strictEscapeSyntax) {
String s = matchedToken.image;
int index = s.indexOf('#');
s = s.substring(index);
String msg = "Unknown directive: "
+ s
+ " on line: " + matchedToken.beginLine
+ ", column: " + matchedToken.beginColumn +1
+ ", in template: " + templateName;
throw new TokenMgrError(msg, TokenMgrError.LEXICAL_ERROR);
}
}
}
}
TOKEN :
{
|
|
// to handle a lone dollar sign or "<" or "# or <@ with whitespace after"
|
: FM_EXPRESSION
|
: FM_EXPRESSION
}
SKIP :
{
< ( " " | "\t" | "\n" | "\r" )+ >
|
< ["<", "["] ["#", "!"] "--"> : EXPRESSION_COMMENT
}
SKIP:
{
< (~["-", ">", "]"])+ >
|
< ">">
|
< "]">
|
< "-">
|
< "-->" | "--]"> {if (parenthesisNesting >0) SwitchTo(IN_PAREN); else if (inInvocation) SwitchTo(NAMED_PARAMETER_EXPRESSION); else SwitchTo(FM_EXPRESSION);}
}
TOKEN :
{
<#ESCAPED_CHAR : "\\"
(
["n","t","r","f","b","g","l","a","\\","'","\"","$","{"]
|
("x" ["0"-"9","A"-"F","a"-"f"])
)
>
|
)*
"\"")
|
("'"
((~["'","\\"]) | )*
"'"
)
>
|
|