/// <summary> /// Reads the next goto statement from the file and returns it. /// </summary> /// <param name="parentReference"> /// The parent code unit. /// </param> /// <param name="unsafeCode"> /// Indicates whether the code being parsed resides in an unsafe code block. /// </param> /// <returns> /// Returns the statement. /// </returns> private GotoStatement ParseGotoStatement(Reference<ICodePart> parentReference, bool unsafeCode) { Param.AssertNotNull(parentReference, "parentReference"); Param.Ignore(unsafeCode); Reference<ICodePart> statementReference = new Reference<ICodePart>(); // Move past the goto keyword. CsToken firstToken = this.GetToken(CsTokenType.Goto, SymbolType.Goto, parentReference, statementReference); Node<CsToken> firstTokenNode = this.tokens.InsertLast(firstToken); // Get the next symbol. Symbol symbol = this.GetNextSymbol(statementReference); Expression identifier = null; if (symbol.SymbolType == SymbolType.Default) { Node<CsToken> tokenNode = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Default, statementReference)); identifier = new LiteralExpression(new CsTokenList(this.tokens, tokenNode, tokenNode), tokenNode); } else if (symbol.SymbolType == SymbolType.Case) { this.tokens.Add(this.GetToken(CsTokenType.Other, SymbolType.Case, statementReference)); identifier = this.GetNextExpression(ExpressionPrecedence.None, statementReference, unsafeCode); } else { identifier = this.GetNextExpression(ExpressionPrecedence.None, statementReference, unsafeCode); } // Get the closing semicolon. this.tokens.Add(this.GetToken(CsTokenType.Semicolon, SymbolType.Semicolon, statementReference)); // Create the token list for the statement. CsTokenList partialTokens = new CsTokenList(this.tokens, firstTokenNode, firstTokenNode); // Create and return the goto-statement. GotoStatement statement = new GotoStatement(partialTokens, identifier); statementReference.Target = statement; return statement; }
/// <summary> /// The save. /// </summary> /// <param name="gotoStatement"> /// The goto statement. /// </param> private void Save(GotoStatement gotoStatement) { this.cppWriter.Write("goto "); @switch(gotoStatement.Identifier); }