Package org.rythmengine.internal.parser

Examples of org.rythmengine.internal.parser.Directive


                        params.addParameterDeclaration(r.stringMatched(4), r.stringMatched(5), ctx());
                    }
                }


                return new Directive(s, ctx()) {
                    @Override
                    public void call() {
                        try {
                            builder().setExtended(sExtend, params, lineNo);
                        } catch (NoClassDefFoundError e) {
View Full Code Here


                    String defVal = r.stringMatched(7);
                    if (null != defVal) defVal = neu + " " + defVal;
                    name = ExpressionParser.processPositionPlaceHolder(name);
                    ral.add(new F.T4(line, type, name, defVal));
                }
                return new Directive("", ctx()) {
                    @Override
                    public void call() {
                        for (F.T4<Integer, String, String, String> rd : ral) {
                            builder().addRenderArgs(rd._1, rd._2, rd._3, rd._4);
                        }
                    }
                };
            }

            /*
             * 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);
                    s = S.strip(s, "{", "}");
                    step(matched.length());
                    return go2(s);
                }
                boolean startWithLineBreak = remain.startsWith("\n");
                if (startWithLineBreak) {
                    remain = remain.substring(1);
                }
                String space = "";
                Regex r0 = new Regex("^(\\s+).*");
                if (r0.search(remain)) {
                    space = r0.stringMatched(1);
                }
                //space = startWithLineBreak ? "\n" + space : space;
                step(space.length());
                remain = remain.replaceFirst("^\\s+", "");
                String key = String.format("%s%s ", a(), keyword());
                if (!remain.startsWith(key)) {
                    raiseParseException("No argument declaration found");
                }
                step(key.length() + (startWithLineBreak ? 1 : 0));
                remain = remain();
                r = reg(dialect());
                int step = 0;
                //final List<CodeBuilder.RenderArgDeclaration> ral = new ArrayList<CodeBuilder.RenderArgDeclaration>();
                while (r.search(remain)) {
                    String matched = r.stringMatched();
                    if (matched.startsWith("\n") || matched.startsWith("\r")) {
                        break;
                    }
                    step += matched.length();
                    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 = "";
                    String defVal = r.stringMatched(7);
                    if (null != defVal) defVal = neu + " " + defVal;
                    name = ExpressionParser.processPositionPlaceHolder(name);
                    //ral.add(new CodeBuilder.RenderArgDeclaration(ctx().currentLine(), name, type, defVal));
                    ctx().getCodeBuilder().addRenderArgs(ctx().currentLine(), type, name, defVal);
                }
                step(step);
                // strip off the following ";" symbol and line breaks
                char c;
                while (true) {
                    c = peek();
                    if ((' ' == c || ';' == c || '\n' == c) && ctx.hasRemain()) {
                        step(1);
                        if (space.length() > 0) {
                            ctx.getCodeBuilder().addBuilder(new Token.StringToken(space, ctx));
                        }
                        if ('\n' == c && startWithLineBreak) {
                            ctx.getCodeBuilder().addBuilder(new Token.StringToken("\n", ctx));
                        }
                    } else {
                        break;
                    }
                }
                return new Directive("", ctx()) {
                    @Override
                    public void call() {
//                        for (CodeBuilder.RenderArgDeclaration rd: ral) {
//                            builder().addRenderArgs(rd);
//                        }
View Full Code Here

                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

                    step(matched.length());
                    String s0 = r.stringMatched(3);
                    s0 = s0.substring(1); // strip '{'
                    s0 = s0.substring(0, s0.length() - 1); // strip '}'
                    String s = s0;
                    return new Directive(s, ctx) {
                        @Override
                        public void call() {
                            ctx.getCodeBuilder().setInitCode(s);
                        }
                    };
View Full Code Here

TOP

Related Classes of org.rythmengine.internal.parser.Directive

Copyright © 2018 www.massapicom. 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.