Package com.stevesoft.pat

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


                boolean afterLB = matched.endsWith("\n");
                if (leadingLB) {
                    ctx.getCodeBuilder().addBuilder(new Token.StringToken("\n", ctx));
                    if (leadingLB ^ afterLB) {
                        Regex r0 = new Regex("\\n([ \\t\\x0B\\f]*).*");
                        if (r0.search(matched)) {
                            String blank = r0.stringMatched(1);
                            if (blank.length() > 0) {
                                ctx.getCodeBuilder().addBuilder(new Token.StringToken(blank, ctx));
                            }
                        }
View Full Code Here


                            }
                        }
                    }
                } else {
                    Regex r0 = new Regex("([ \\t\\x0B\\f]*).*");
                    if (r0.search(matched)) {
                        String blank = r0.stringMatched(1);
                        if (blank.length() > 0) {
                            ctx.getCodeBuilder().addBuilder(new Token.StringToken(blank, ctx));
                        }
                    }
View Full Code Here

    public IParser create(IContext c) {
        return new RemoveLeadingLineBreakAndSpacesParser(c) {
            public Token go() {
                Regex r = reg(dialect());
                if (!r.search(remain())) {
                    raiseParseException("Bad @break statement. Correct usage: @break()");
                }
                String matched = r.stringMatched();
                String condition = r.stringMatched(2);
                if (null != condition) {
View Full Code Here

    public IParser create(final IContext ctx) {
        return new ParserBase(ctx) {
            public Token go() {
                Regex r = reg(dialect());
                if (!r.search(remain()))
                    raiseParseException("bad @assign statement. Correct usage: @assign(myVariable){...}");
                String matched = r.stringMatched();
                step(matched.length());
                String s = r.stringMatched(1);
                s = S.stripBrace(s);
View Full Code Here

                String s = r.stringMatched(1);
                s = S.stripBrace(s);
                if (matched.startsWith("\n") || matched.endsWith("\n")) {
                    ctx.getCodeBuilder().addBuilder(new Token.StringToken("\n", ctx));
                    Regex r0 = new Regex("\\n([ \\t\\x0B\\f]*).*");
                    if (r0.search(matched)) {
                        String blank = r0.stringMatched(1);
                        if (blank.length() > 0) {
                            ctx.getCodeBuilder().addBuilder(new Token.StringToken(blank, ctx));
                        }
                    }
View Full Code Here

                            ctx.getCodeBuilder().addBuilder(new Token.StringToken(blank, ctx));
                        }
                    }
                } else {
                    Regex r0 = new Regex("([ \\t\\x0B\\f]*).*");
                    if (r0.search(matched)) {
                        String blank = r0.stringMatched(1);
                        if (blank.length() > 0) {
                            ctx.getCodeBuilder().addBuilder(new Token.StringToken(blank, ctx));
                        }
                    }
View Full Code Here

    public IParser create(IContext c) {
        return new RemoveLeadingLineBreakAndSpacesParser(c) {
            public Token go() {
                Regex r = reg(dialect());
                if (!r.search(remain())) {
                    raiseParseException("Error parsing @expand statement. Correct usage: @expand(\"my-macro\")");
                }
                final int curLine = ctx().currentLine();
                step(r.stringMatched().length());
                String s = r.stringMatched(3);
View Full Code Here

    public static void main(String[] args) {
        ExpandParser p = new ExpandParser();
        Regex r = p.reg(Rythm.INSTANCE);
        String s = "@expand(\"x.y.z\") \n@sayHi(\"green\")";
        if (r.search(s)) {
            p(r);
        }
    }
}
View Full Code Here

            public Token go2(String s) {
                Regex r = reg(dialect());
                final List<F.T4<Integer, String, String, String>> ral = new ArrayList();
                s = s.replaceAll("[\\n\\r]+", ",").replaceAll("[,]+", ",");
                int line = ctx.currentLine();
                while (r.search(s)) {
                    String type = r.stringMatched(2);
                    checkRestrictedClass(type);
                    String name = r.stringMatched(4);
                    String neu = r.stringMatched(6); // check the 'new' keyword
                    if (null == neu) neu = "";
View Full Code Here

             * parse @args String s...
             */
            public Token go() {
                String remain = remain();
                Regex r = new Regex(String.format("\\n?[ \\t\\x0B\\f]*%s%s(\\([ \t\f]*\\))?[ \t\f]*((?@{}))\\n?", a(), keyword()));
                if (r.search(remain)) {
                    String matched = r.stringMatched();
                    if (matched.startsWith("\n") || matched.endsWith("\n")) {
                        ctx.getCodeBuilder().addBuilder(new Token.StringToken("\n", ctx));
                    }
                    String s = r.stringMatched(2);
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.