Example #1
0
        private void GenChoose(AegisChoose aegisChoose)
        {
            if (aegisChoose.Exp.GetType() == typeof(ComposExpr))
            {
                WriteNew("switch ");

                Write(TranslateExpr(aegisChoose.Exp));

                WriteLine("");
            }
            else
            {
                WriteNew("switch (");

                Write(TranslateExpr(aegisChoose.Exp));

                WriteLine(")");
            }
            WriteNewLine("{0}", "{");
            tabLevel++;

            foreach (AegisCase ac in aegisChoose.Items)
            {
                GenCase(ac);
            }

            tabLevel--;
            WriteNewLine("{0}", "}");
        }
Example #2
0
        private AegisChoose MatchChoose()
        {
            Match(TokenType.Choose);

            Expr exp = MatchExpr();

            MatchNewline();

            var ac = new AegisChoose();

            ac.Exp = exp;

            while (tk.Type == TokenType.NewLine)
            {
                MatchNewline();
            }
            PushNode(ac);
            while (tk.Type == TokenType.Case)
            {
                curNode.Items.Add(MatchCase());
                while (tk.Type == TokenType.NewLine)
                {
                    MatchNewline();
                }
            }
            ac = (AegisChoose)PopNode();

            while (tk.Type == TokenType.NewLine)
            {
                MatchNewline();
            }
            Match(TokenType.EndChoose);

            return(ac);
        }