public static AST.Statement ParseStatement(Queue <Token> tokens) { Token token = tokens.Dequeue(); if (!Match(token, Token.TokenType.Keyword, Syntax.GetKeyword(Syntax.Keyword.Return))) { Fail(token); } AST.Expression expression = ParseExpression(tokens); AST.Statement statement = new AST.Return(expression); token = tokens.Dequeue(); if (token.Type != Token.TokenType.Semicolon) { Fail(token); } return(statement); }
static void WriteReturn(StreamWriter writer, AST.Return ret) { WriteExpression(writer, ret.Expression); writer.Write(Assembly.format_return); }