Esempio n. 1
0
 private static UnifiedExpression CreateBreak(XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "break");
     return(UnifiedBreak.Create(
                CreateSmartExpresion(node.FirstElementOrDefault())));
 }
Esempio n. 2
0
        public static UnifiedExpression CreateJumpStatement(XElement node)
        {
            Contract.Requires(node != null);
            Contract.Requires(node.Name() == "jump_statement");

            /* jump_statement
             * : 'goto' IDENTIFIER ';'
             * | 'continue' ';'
             * | 'break' ';'
             * | 'return' ';'
             * | 'return' expression ';'
             */
            var firstElement = node.FirstElement();

            switch (firstElement.Value)
            {
            case "goto":
                return
                    (UnifiedGoto.Create(
                         UnifiedLabelIdentifier.Create(
                             node.NthElement(1).Value)));

            case "continue":
                return(UnifiedContinue.Create());

            case "break":
                return(UnifiedBreak.Create());

            case "return":
                var expression = node.Element("expression");
                if (expression != null)
                {
                    return
                        (UnifiedReturn.Create(
                             CreateExpression(expression).First()));
                }
                return(UnifiedReturn.Create());

            default:
                throw new InvalidOperationException();
            }
        }
Esempio n. 3
0
 public override bool Visit(UnifiedBreak element, VisitorArgument arg)
 {
     Writer.Write("break ");
     return(true);
 }
Esempio n. 4
0
 public override bool Visit(UnifiedBreak element, VisitorArgument arg)
 {
     Writer.Write("break ");
     element.Value.TryAccept(this, arg);
     return(true);
 }
 public override bool Visit(UnifiedBreak element, VisitorArgument arg)
 {
     Writer.Write("break ");
     element.Value.TryAccept(this, arg);
     return true;
 }
 public override bool Visit(UnifiedBreak element, VisitorArgument arg)
 {
     Writer.Write("break ");
     return true;
 }
Esempio n. 7
0
 public UnifiedElement VisitBreakStatement(
     BreakStatement stmt, object data)
 {
     return(UnifiedBreak.Create());
 }