Examples of CodeToken


Examples of org.rythmengine.internal.parser.CodeToken

                IContext.Break b = ctx().peekBreak();
                if (null == b) raiseParseException("Bad @break statement: No loop context");
                if (S.notEmpty(condition)) {
                    return new IfThenToken(condition, "break", ctx());
                } else {
                    return new CodeToken(b.getStatement(), ctx());
                }
            }
        };
    }
View Full Code Here

Examples of org.rythmengine.internal.parser.CodeToken

                    IContext.Continue c = ctx().peekContinue();
                    if (null == c) raiseParseException("Bad @continue statement: No loop context");
                    if (S.notEmpty(condition)) {
                        return new IfThenToken(condition, "continue", ctx());
                    } else {
                        return new CodeToken(c.getStatement(), ctx());
                    }
                }
                raiseParseException("Bad @continue statement. Correct usage: @continue()");
                return null;
            }
View Full Code Here

Examples of org.rythmengine.internal.parser.CodeToken

                Regex r = reg(dialect());
                if (r.search(remain())) {
                    String s = r.stringMatched();
                    step(s.length());
                }
                return new CodeToken("", ctx());
            }
        };
    }
View Full Code Here

Examples of org.rythmengine.internal.parser.CodeToken

                    } else {
                        s = s.replaceAll("(\\r?\\n)+", "\\\\n").replaceAll("\"", "\\\\\"");
                       
                        s = String.format("p(\"%s\");__ctx.pushCodeType(%s);", s, type.newInstanceStr());
                    }
                    return new CodeToken(s, ctx);
                }
            }
        }
        return null;
    }
View Full Code Here

Examples of org.rythmengine.internal.parser.CodeToken

                                return Token.EMPTY_TOKEN;
                            } else {
                                return new Token.StringToken(s, ctx());
                            }
                        } else {
                            CodeToken ct = new CodeToken(s, ctx());
                            String bhCls = bh.getClass().getName();
                            if (bhCls.contains("For")) {
                                ctx.getCodeBuilder().removeSpaceTillLastLineBreak(ctx);
                                ct.removeNextLineBreak = true;
                            } else if (bhCls.contains("Assign")) {
                                remain = ctx.getRemain();
                                Matcher m = Pattern.compile("(^[ \\t\\x0B\\f]*\\n).*", Pattern.DOTALL).matcher(remain);
                                if (m.matches()) {
                                    String space = m.group(1);
                                    step(space.length());
                                }
                            } else {
                                ctx.getCodeBuilder().removeSpaceToLastLineBreak(ctx);
                            }
                            if (S.isEmpty(s)) {
                                return Token.EMPTY_TOKEN;
                            } else {
                                return ct;
                            }
                        }
                    } else if (null != bh && !isLiteral) {
                        Matcher m = P.matcher(remain);
                        if (m.matches()) {
                            CodeBuilder cb = ctx.getCodeBuilder();
                            String bhCls = bh.getClass().getName();
                            String s = m.group(2);
                            if (bhCls.contains("For")) {
                                cb.addBuilder(new Token.StringToken("\n", ctx));
                                cb.removeNextLF = true;
                            } else if (bhCls.contains("Assign") || bhCls.contains("DefTag")) {
                                if (m.group(1).endsWith("\n")) {
                                    cb.removeNextLF = true;
                                }
                            }
                            ctx.step(s.length());
                            CodeToken ct = new CodeToken(ctx.closeBlock(), ctx);
                            return ct;
                        }
                    }
                }
                return null;
View Full Code Here

Examples of org.rythmengine.internal.parser.CodeToken

                //exp = exp.replaceAll("\\?", "");
                //exp = exp.replaceAll("(\".*?\"|\\?)", "$1§").replaceAll("\\??§", "");
                //see http://stackoverflow.com/questions/20466535
                String regex = "(?s)(\"(?>[^\\\\\"]++|\\\\{2}|\\\\.)*\")|\\?";
                exp = exp.replaceAll(regex, "$1");
                return new CodeToken(exp, ctx()) {
                    @Override
                    public void output() {
                        outputExpression(statements);
                    }
                };
View Full Code Here

Examples of org.rythmengine.internal.parser.CodeToken

                    String code = !isSection ? "__pLayoutContent();" : "__pLayoutSection(\"" + section + "\");";
                    if (lineBreak && isSection) {
                        //layout content often come from a file which always gets one additional line break
                        code = code + ";\npn();\n";
                    }
                    return new CodeToken(code, ctx());
                }
            }
        };
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.