/// <summary> /// Reads a label statement. /// </summary> /// <param name="parentReference"> /// The parent code unit. /// </param> /// <param name="unsafeCode"> /// Indicates whether the code is marked as unsafe. /// </param> /// <returns> /// Returns the statement. /// </returns> private LabelStatement ParseLabelStatement(Reference<ICodePart> parentReference, bool unsafeCode) { Param.AssertNotNull(parentReference, "parentReference"); Param.Ignore(unsafeCode); // The first symbol must be an unknown word. this.GetNextSymbol(SymbolType.Other, parentReference); Reference<ICodePart> statementReference = new Reference<ICodePart>(); // Get the literal expression for this symbol. LiteralExpression identifier = this.GetLiteralExpression(statementReference, unsafeCode); if (identifier == null || identifier.Tokens.First == null) { throw this.CreateSyntaxException(); } // The next symbol must be the colon. this.tokens.Add(this.GetToken(CsTokenType.LabelColon, SymbolType.Colon, statementReference)); // Create the token list for the statement. CsTokenList partialTokens = new CsTokenList(this.tokens, identifier.Tokens.First, this.tokens.Last); LabelStatement statement = new LabelStatement(partialTokens, identifier); statementReference.Target = statement; return statement; }
/// <summary> /// The save. /// </summary> /// <param name="labelStatement"> /// The label statement. /// </param> private void Save(LabelStatement labelStatement) { @switch(labelStatement.Identifier); this.cppWriter.WriteLine(":"); }