예제 #1
0
        /// <summary>
        /// Reads the next expression statement from the file and returns it.
        /// </summary>
        /// <param name="unsafeCode">
        /// Indicates whether the code being parsed resides in an unsafe code block.
        /// </param>
        /// <returns>
        /// Returns the statement.
        /// </returns>
        private ExpressionStatement ParseExpressionStatement(bool unsafeCode)
        {
            Param.Ignore(unsafeCode);

            Reference<ICodePart> statementReference = new Reference<ICodePart>();

            // Get the expression.
            Expression expression = this.GetNextExpression(ExpressionPrecedence.None, statementReference, unsafeCode);
            if (expression == null || expression.Tokens.First == null)
            {
                throw this.CreateSyntaxException();
            }

            // Read up to the semicolon.
            this.tokens.Add(this.GetToken(CsTokenType.Semicolon, SymbolType.Semicolon, statementReference));

            // Create the token list for the statement.
            CsTokenList partialTokens = new CsTokenList(this.tokens, expression.Tokens.First, this.tokens.Last);

            // Create and return the statement.
            ExpressionStatement statement = new ExpressionStatement(partialTokens, expression);
            statementReference.Target = statement;

            return statement;
        }
 /// <summary>
 /// The save.
 /// </summary>
 /// <param name="expressionStatement">
 /// The expression statement.
 /// </param>
 private void Save(ExpressionStatement expressionStatement)
 {
     @switch(expressionStatement.Expression);
 }