Example #1
0
        public static ElseHeader Else(MatchIterator iterator)
        {
            iterator.AssertKeyword(Keywords.Else, out Token elseToken);
            iterator.AssertEnd();

            ElseHeader result = new ElseHeader(elseToken);

            return(result);
        }
Example #2
0
        public static void GenerateCode(ElseHeader header, GeneratorContext builder)
        {
            foreach (Expression statement in header.ParentBlockHint.Statements)
            {
                builder.AddCode(statement);
            }

            string conditionalEndLabel = header.EndLabelHint;

            if (conditionalEndLabel == null)
            {
                throw new Exception("Encountered Else Header without an end label!");
            }

            builder.SetLabelToNext(conditionalEndLabel);

            if (header.RequiresScopeHint)
            {
                builder.AddOp(new ScopeEnd(), header.ParentBlockHint.EndToken);
            }
        }