private void endInterpolation(Token closingTk) { SwitchTo(postInterpolationLexState); postInterpolationLexState = -1; }
private void unifiedCall(Token tok) { char firstChar = tok.image.charAt(0); if (autodetectTagSyntax && !tagSyntaxEstablished) { squBracTagSyntax = (firstChar == '['); } if (squBracTagSyntax && firstChar == '<') { tok.kind = STATIC_TEXT_NON_WS; return; } if (!squBracTagSyntax && firstChar == '[') { tok.kind = STATIC_TEXT_NON_WS; return; } tagSyntaxEstablished = true; SwitchTo(NO_SPACE_EXPRESSION); }
void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) { case 91 : image.append(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)
/** Constructor. */ public FMParserTokenManager (SimpleCharStream stream, int lexState){ ReInit(stream); SwitchTo(lexState); }
/** Reinitialise parser. */ public void ReInit( SimpleCharStream stream, int lexState) { ReInit( stream); SwitchTo(lexState); }
void setupStringLiteralMode(FMParser parentParser, OutputFormat outputFormat) { FMParserTokenManager parentTokenSource = parentParser.token_source; token_source.initialNamingConvention = parentTokenSource.initialNamingConvention; token_source.namingConvention = parentTokenSource.namingConvention; token_source.namingConventionEstabilisher = parentTokenSource.namingConventionEstabilisher; token_source.SwitchTo(NO_DIRECTIVE); this.outputFormat = outputFormat; recalculateAutoEscapingField(); if (incompatibleImprovements < _TemplateAPI.VERSION_INT_2_3_24) { // Emulate bug, where the string literal parser haven't inherited the IcI: incompatibleImprovements = _TemplateAPI.VERSION_INT_2_3_0; } // So that loop variable built-ins, like ?index, works inside the interpolations in the string literal: iteratorBlockContexts = parentParser.iteratorBlockContexts; }
private void ftlHeader(Token matchedToken) { if (!tagSyntaxEstablished) { squBracTagSyntax = matchedToken.image.charAt(0) == '['; tagSyntaxEstablished = true; autodetectTagSyntax = false; } String img = matchedToken.image; char firstChar = img.charAt(0); char lastChar = img.charAt(img.length() - 1); if ((firstChar == '[' && !squBracTagSyntax) || (firstChar == '<' && squBracTagSyntax)) { matchedToken.kind = STATIC_TEXT_NON_WS; } if (matchedToken.kind != STATIC_TEXT_NON_WS) { if (lastChar != '>' && lastChar != ']') { SwitchTo(FM_EXPRESSION); inFTLHeader = true; } else { eatNewline(); } } }
private void startInterpolation(Token tok) { if ( interpolationSyntax == LEGACY_INTERPOLATION_SYNTAX && tok.kind == SQUARE_BRACKET_INTERPOLATION_OPENING || interpolationSyntax == DOLLAR_INTERPOLATION_SYNTAX && tok.kind != DOLLAR_INTERPOLATION_OPENING || interpolationSyntax == SQUARE_BRACKET_INTERPOLATION_SYNTAX && tok.kind != SQUARE_BRACKET_INTERPOLATION_OPENING) { tok.kind = STATIC_TEXT_NON_WS; return; } if (postInterpolationLexState != -1) { // This certainly never occurs, as starting an interpolation in expression mode fails earlier. char c = tok.image.charAt(0); throw new TokenMgrError( "You can't start an interpolation (" + tok.image + "..." + (interpolationSyntax == SQUARE_BRACKET_INTERPOLATION_SYNTAX ? "]" : "}") + ") here as you are inside another interpolation.)", TokenMgrError.LEXICAL_ERROR, tok.beginLine, tok.beginColumn, tok.endLine, tok.endColumn); } postInterpolationLexState = curLexState; SwitchTo(FM_EXPRESSION); }
/** * Create an FM expression parser using a string. * * @Deprecated This is an internal API of FreeMarker; can be removed any time. */ 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); FMParser parser = new FMParser(token_source); token_source.setParser(parser); return parser; }
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_f():jj_ntk) { case ID:{ ; break; } default: jj_la1[73] = jj_gen; break label_13; } } token_source.inInvocation = false; {if ("" != null) return result;} throw new Error("Missing return statement in function"); }
SwitchTo(DEFAULT); lengthOfMatch = jjstrLiteralImages[134].length(); ++parenthesisNesting; if (parenthesisNesting == 1) SwitchTo(IN_PAREN); break; case 135 : --parenthesisNesting; if (parenthesisNesting == 0) { if (inInvocation) SwitchTo(NAMED_PARAMETER_EXPRESSION); else SwitchTo(FM_EXPRESSION); matchedToken.kind = NATURAL_GT; } else { SwitchTo(DEFAULT); SwitchTo(DEFAULT); break; case 153 : if ((squBracTagSyntax && squareBracket) || (!squBracTagSyntax && !squareBracket)) { matchedToken.image = matchedToken.image + ";"; SwitchTo(DEFAULT); if (st.nextToken().equals(noparseTag)) { matchedToken.image = matchedToken.image + ";"; SwitchTo(DEFAULT);
FMParserTokenManager tkMan = new FMParserTokenManager( simpleCharStream); tkMan.SwitchTo(FMParserConstants.FM_EXPRESSION);
public FMParserTokenManager(SimpleCharStream stream, int lexState) { this(stream); SwitchTo(lexState); } public void ReInit(SimpleCharStream stream)
/** Reinitialise parser. */ public void ReInit( SimpleCharStream stream, int lexState) { ReInit( stream); SwitchTo(lexState); }
public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } public void SwitchTo(int lexState)
private void closeBracket(Token tok) { if (bracketNesting >0) { --bracketNesting; } else { tok.kind=DIRECTIVE_END; if (inFTLHeader) { eatNewline(); inFTLHeader = false; } SwitchTo(DEFAULT); } }
/** Constructor. */ public FMParserTokenManager (SimpleCharStream stream, int lexState){ ReInit(stream); SwitchTo(lexState); }
/** * 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); }
/** * Create an FM expression parser using a string. * * @Deprecated This is an internal API of FreeMarker; can be removed any time. */ 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); FMParser parser = new FMParser(token_source); token_source.setParser(parser); return parser; }