Ejemplo n.º 1
0
        private void buildRule(BuildState state, p_Rule pRule)
        {
            state.PushBadLocation("bad");
            state.PushGoodLocation("good");
            checkBuilder.AppendFormat("public bool check{0}() {{", pRule.ruleName);
            obtainBuilder.AppendFormat("public p_{0} obtain{0}() {{", pRule.ruleName);
            classesBuilder.AppendFormat("public class p_{0} {{", pRule.ruleName);

            buildRuleExpression(state, pRule.RuleExpression);

            checkBuilder.Append(@"good:  

                                    symbolGenerator.RestoreState();
                                    return true;");
            checkBuilder.Append(@"bad:  

                                    symbolGenerator.PopState();
                                    return false;");


            checkBuilder.AppendLine("}\r\n\r\n\r\n\r\n");
            obtainBuilder.AppendLine("}\r\n\r\n\r\n\r\n");
            classesBuilder.AppendLine("}\r\n\r\n\r\n\r\n");

            state.PopGoodLocation();
            state.PopBadLocation();
        }
Ejemplo n.º 2
0
        private void buildOrPiece(BuildState state, p_OrPiece orPiece)
        {
            var curState = state.nextGoodState++;

            state.PushGoodLocation("endOfOr" + curState);
            state.PushBadLocation("curBad" + curState);

            var itms = Helper.CombineArray(orPiece.RuleExpression1, orPiece.RuleExpressions).ToArray();
            int ind = 0;
            foreach (p_RuleExpression expression in itms)
            {
                var j = state.nextGoodState;
                state.PushBadLocation(string.Format("bottomPiece{0}", j));

                buildRuleExpression(state, expression);

                state.PopBadLocation();
                checkBuilder.AppendLine(string.Format("bottomPiece{0}:", j));

                if (ind++ == itms.Length-1)
                    checkBuilder.AppendLine("goto " + state.BadLocation() + ";");
                else
                    checkBuilder.AppendLine("goto nextPiece" + state.nextGoodState + ";");

            }
            state.PopBadLocation();
            state.PopGoodLocation();

            checkBuilder.AppendLine("curBad" + curState + ": goto " + state.BadLocation(state.nextGoodState) + ";");

            checkBuilder.AppendLine("endOfOr" + curState + ":");
            checkBuilder.AppendLine(string.Format("goto {0};", state.GoodLocation));
        }
Ejemplo n.º 3
0
        private void buildOrPiece(BuildState state, p_OrPiece orPiece)
        {
            var curState = state.nextGoodState++;

            state.PushGoodLocation("endOfOr" + curState);
            state.PushBadLocation("curBad" + curState);

            var itms = Helper.CombineArray(orPiece.RuleExpression1, orPiece.RuleExpressions).ToArray();
            int ind  = 0;

            foreach (p_RuleExpression expression in itms)
            {
                var j = state.nextGoodState;
                state.PushBadLocation(string.Format("bottomPiece{0}", j));

                buildRuleExpression(state, expression);

                state.PopBadLocation();
                checkBuilder.AppendLine(string.Format("bottomPiece{0}:", j));

                if (ind++ == itms.Length - 1)
                {
                    checkBuilder.AppendLine("goto " + state.BadLocation() + ";");
                }
                else
                {
                    checkBuilder.AppendLine("goto nextPiece" + state.nextGoodState + ";");
                }
            }
            state.PopBadLocation();
            state.PopGoodLocation();

            checkBuilder.AppendLine("curBad" + curState + ": goto " + state.BadLocation(state.nextGoodState) + ";");



            checkBuilder.AppendLine("endOfOr" + curState + ":");
            checkBuilder.AppendLine(string.Format("goto {0};", state.GoodLocation));
        }
Ejemplo n.º 4
0
        private void buildRule(BuildState state, p_Rule pRule)
        {
            state.PushBadLocation("bad");
            state.PushGoodLocation("good");
            checkBuilder.AppendFormat("public bool check{0}() {{", pRule.ruleName);
            obtainBuilder.AppendFormat("public p_{0} obtain{0}() {{", pRule.ruleName);
            classesBuilder.AppendFormat("public class p_{0} {{", pRule.ruleName);

            buildRuleExpression(state, pRule.RuleExpression);

            checkBuilder.Append(@"good:

                                    symbolGenerator.RestoreState();
                                    return true;");
            checkBuilder.Append(@"bad:

                                    symbolGenerator.PopState();
                                    return false;");

            checkBuilder.AppendLine("}\r\n\r\n\r\n\r\n");
            obtainBuilder.AppendLine("}\r\n\r\n\r\n\r\n");
            classesBuilder.AppendLine("}\r\n\r\n\r\n\r\n");

            state.PopGoodLocation();
            state.PopBadLocation();
        }