/** @see jaskell.compiler.JaskellVisitor#visit(Variable) */ public Object visit(Variable a) { Type ret = null; String vname = a.getName(); Expression def = a.lookup(vname); if (def == null) // unknown symbol throw new CompilerException("Unknown variable " + vname); else ret = (Type) def.visit(this); a.setType(ret); return ret; }
public StartupPageTemplateHolder(final String template) { ParamCheck.notNull(template, "template"); replacementIndices = new HashMap(); StringTokenizer tokenizer = new StringTokenizer(template, "${}", true); int countTokens = tokenizer.countTokens(); tokens = new String[countTokens]; boolean ignoreNextToken = false; for (int i = 0; i < tokens.length; i++) { String nextToken = tokenizer.nextToken(); if (ignoreNextToken) { ignoreNextToken = false; } else if (!isVariableToken(nextToken)) { tokens[i] = nextToken; } else { Variable variable = Variable.lookup(nextToken); addReplacementIndex(variable, i); tokens[i - 1] = ""; tokens[i - 2] = ""; tokens[i + 1] = ""; ignoreNextToken = true; } } }