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(); } }
public UnifiedElement VisitGotoStatement( GotoStatement gotoStatement, object data) { return(UnifiedGoto.Create(gotoStatement.Label)); }
public UnifiedElement VisitGotoDefaultStatement( GotoDefaultStatement gotoDefaultStatement, object data) { return(UnifiedGoto.Create(UnifiedCase.CreateDefault())); }
public UnifiedElement VisitGotoCaseStatement( GotoCaseStatement gotoCaseStatement, object data) { return(UnifiedGoto.Create(UnifiedCase.Create(gotoCaseStatement.LabelExpression.TryAcceptForExpression(this)))); }