// Add code to this case clause. public void AddCode(ast.Statement statement) { // First time? if (Code == null) { Code = new ast.CodeBlock(statement.Bookmark, TriState.No); } Code.AddStatement(statement); }
// Parse a single statement ast.CodeBlock ParseStatement() { if (t.token == Token.openBrace) { return(ParseStatementBlock(TriState.Maybe)); } else { var stmt = new ast.CodeBlock(t.GetBookmark(), TriState.Maybe); stmt.AddStatement(ParseSingleStatement()); return(stmt); } }
// Parse series of statements into a statement block public void ParseStatements(ast.CodeBlock block) { while (t.token != Token.closeBrace && t.token != Token.eof) { // Skip redundant semicolons if (t.token == Token.semicolon) { t.Next(); continue; } // Add the next statement block.AddStatement(ParseSingleStatement()); } }
// Parse a single statement ast.CodeBlock ParseStatement() { if (t.token == Token.openBrace) { return ParseStatementBlock(TriState.Maybe); } else { var stmt = new ast.CodeBlock(t.GetBookmark(), TriState.Maybe); stmt.AddStatement(ParseSingleStatement()); return stmt; } }