Package com.stevesoft.pat

Examples of com.stevesoft.pat.Regex.stringMatched()


            @Override
            public Token go() {
                Regex r = new Regex(String.format(patternStr(), dialect().a()));
                if (!r.search(remain())) return null;
                String macro = r.stringMatched(2);
                if (!ctx().getCodeBuilder().hasMacro(macro)) return null;
                int curLine = currentLine();
                step(r.stringMatched().length());
                return new ExecMacroToken(macro, ctx(), curLine);
            }
View Full Code Here


                Regex r = new Regex(String.format(patternStr(), dialect().a()));
                if (!r.search(remain())) return null;
                String macro = r.stringMatched(2);
                if (!ctx().getCodeBuilder().hasMacro(macro)) return null;
                int curLine = currentLine();
                step(r.stringMatched().length());
                return new ExecMacroToken(macro, ctx(), curLine);
            }
        };
    }
View Full Code Here

    public static List<CodeBuilder.RenderArgDeclaration> parseArgDeclaration(int lineNo, String s) {
        final List<CodeBuilder.RenderArgDeclaration> ral = new ArrayList<CodeBuilder.RenderArgDeclaration>();
        Regex r = new ArgsParser().reg(DialectManager.current());
        while (r.search(s)) {
            String matched = r.stringMatched();
            if (matched.startsWith("\n") || matched.startsWith("\r")) {
                break;
            }
            String name = r.stringMatched(4);
            String type = r.stringMatched(2);
View Full Code Here

        while (r.search(s)) {
            String matched = r.stringMatched();
            if (matched.startsWith("\n") || matched.startsWith("\r")) {
                break;
            }
            String name = r.stringMatched(4);
            String type = r.stringMatched(2);
            String defVal = r.stringMatched(5);
            name = ExpressionParser.processPositionPlaceHolder(name);
            ral.add(new CodeBuilder.RenderArgDeclaration(lineNo, type, name, defVal));
        }
View Full Code Here

            String matched = r.stringMatched();
            if (matched.startsWith("\n") || matched.startsWith("\r")) {
                break;
            }
            String name = r.stringMatched(4);
            String type = r.stringMatched(2);
            String defVal = r.stringMatched(5);
            name = ExpressionParser.processPositionPlaceHolder(name);
            ral.add(new CodeBuilder.RenderArgDeclaration(lineNo, type, name, defVal));
        }
        return ral;
View Full Code Here

            if (matched.startsWith("\n") || matched.startsWith("\r")) {
                break;
            }
            String name = r.stringMatched(4);
            String type = r.stringMatched(2);
            String defVal = r.stringMatched(5);
            name = ExpressionParser.processPositionPlaceHolder(name);
            ral.add(new CodeBuilder.RenderArgDeclaration(lineNo, type, name, defVal));
        }
        return ral;
    }
View Full Code Here

            public Token go() {
                Regex r = reg(dialect());
                if (!r.search(remain())) {
                    raiseParseException("error parsing @__logTime__, correct usage: @__logTime__()");
                }
                step(r.stringMatched().length());
                return new Directive("", ctx()) {
                    @Override
                    public void call() {
                        ctx().getCodeBuilder().setLogTime();
                    }
View Full Code Here

        if (S.isEmpty(type) || "Object".equals(type)) {
            String itrType = cb.getRenderArgType(iterable);
            if (null != itrType) {
                Regex r = new Regex(".*((?@<>))");
                if (r.search(itrType)) {
                    type = r.stringMatched(1);
                    this.type = S.strip(type, "<", ">");
                    boolean key = iterable.endsWith("keySet()");
                    boolean val = iterable.endsWith("values()");
                    if (key || val) {
                        r = new Regex("([a-zA-Z0-9\\[\\]_]+(?@<>)?)\\s*\\,\\s*([a-zA-Z0-9\\[\\]_]+(?@<>)?)");
 
View Full Code Here

                    boolean key = iterable.endsWith("keySet()");
                    boolean val = iterable.endsWith("values()");
                    if (key || val) {
                        r = new Regex("([a-zA-Z0-9\\[\\]_]+(?@<>)?)\\s*\\,\\s*([a-zA-Z0-9\\[\\]_]+(?@<>)?)");
                        if (r.search(this.type)) {
                            if (key) this.type = r.stringMatched(1);
                            else this.type = r.stringMatched(2);
                        } else {
                            throw new ParseException(ctx.getEngine(), ctx.getTemplateClass(), line, "Invalid for loop iterator type declaration: %s", itrType);
                        }
                    }
View Full Code Here

                    boolean val = iterable.endsWith("values()");
                    if (key || val) {
                        r = new Regex("([a-zA-Z0-9\\[\\]_]+(?@<>)?)\\s*\\,\\s*([a-zA-Z0-9\\[\\]_]+(?@<>)?)");
                        if (r.search(this.type)) {
                            if (key) this.type = r.stringMatched(1);
                            else this.type = r.stringMatched(2);
                        } else {
                            throw new ParseException(ctx.getEngine(), ctx.getTemplateClass(), line, "Invalid for loop iterator type declaration: %s", itrType);
                        }
                    }
                } else {
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.