 		private static const INDEX_TRUE:int = 1;
 		private static const INDEX_FALSE:int = 2;
 		
-		private static const STATEMENT_IF:String = 'if';
-		private static const STATEMENT_ELSE:String = 'else';
-		private static const STATEMENT_FOR:String = 'for';
-		private static const STATEMENT_EACH:String = 'each';
-		private static const STATEMENT_DO:String = 'do';
-		private static const STATEMENT_WHILE:String = 'while';
-		private static const STATEMENT_RETURN:String = 'return';
-		private static const STATEMENT_BREAK:String = 'break';
-		private static const STATEMENT_CONTINUE:String = 'continue';
-		private static const STATEMENT_SWITCH:String = 'switch';
-		private static const STATEMENT_CASE:String = 'case';
-		private static const STATEMENT_DEFAULT:String = 'default';
-		private static const STATEMENT_THROW:String = 'throw';
-		private static const STATEMENT_TRY:String = 'try';
-		private static const STATEMENT_CATCH:String = 'catch';
-		private static const STATEMENT_FINALLY:String = 'finally';
+		private static const ST_IF:String = 'if';
+		private static const ST_ELSE:String = 'else';
+		
+		private static const ST_FOR:String = 'for';
+		private static const ST_EACH:String = 'each';
+		private static const ST_FOR_EACH:String = 'for each';
+		
+		private static const ST_DO:String = 'do';
+		private static const ST_WHILE:String = 'while';
+		
+		private static const ST_SWITCH:String = 'switch';
+		private static const ST_CASE:String = 'case';
+		private static const ST_DEFAULT:String = 'default';
+		
+		private static const ST_TRY:String = 'try';
+		private static const ST_CATCH:String = 'catch';
+		private static const ST_FINALLY:String = 'finally';
+		
+		private static const ST_BREAK:String = 'break';
+		private static const ST_CONTINUE:String = 'continue';
+		
+		private static const ST_RETURN:String = 'return';
+		private static const ST_THROW:String = 'finally';
 		
 		private static const _statementsWithoutParams:Array = [
-			STATEMENT_ELSE, STATEMENT_DO, STATEMENT_RETURN, STATEMENT_BREAK, STATEMENT_CONTINUE,
-			STATEMENT_CASE, STATEMENT_DEFAULT, STATEMENT_THROW, STATEMENT_TRY, STATEMENT_FINALLY
+			ST_ELSE, ST_DO, ST_BREAK, ST_CONTINUE, ST_CASE, ST_DEFAULT,
+			ST_TRY, ST_FINALLY, ST_RETURN, ST_THROW
 		];
 		private static const _statementsWithParams:Array = [
-			STATEMENT_IF, STATEMENT_FOR, STATEMENT_EACH, STATEMENT_WHILE, STATEMENT_SWITCH, STATEMENT_CATCH
+			ST_IF, ST_FOR, ST_FOR_EACH, ST_WHILE, ST_SWITCH, ST_CATCH
 		];
-		
+
+		private static const _PARAMS:String = 'PARAMS'; // must be enclosed in ()
+		private static const _STMT:String = 'STMT'; // may contain multiple statements enclosed in {}
+		private static const _EXPR:String = 'EXPR'; // may only contain one expression, optionally enclosed in (), no statements
+		// longer patterns appear earlier so they will match before shorter patterns when checked in order
+		private static const _validStatementPatterns:Array = [
+			[ST_IF, _PARAMS, _STMT, ST_ELSE, _STMT],
+			[ST_IF, _PARAMS, _STMT],
+			[ST_FOR_EACH, _PARAMS, _STMT],
+			[ST_FOR, _PARAMS, _STMT],
+			[ST_DO, _STMT, ST_WHILE, _PARAMS],
+			[ST_WHILE, _PARAMS, _STMT],
+			[ST_TRY, _STMT, ST_CATCH, _PARAMS, _STMT, ST_FINALLY, _STMT],
+			[ST_TRY, _STMT, ST_FINALLY, _STMT],
+			[ST_TRY, _STMT, ST_CATCH, _PARAMS, _STMT],
+			[ST_BREAK],
+			[ST_CONTINUE],
+			[ST_RETURN, _EXPR],
+			[ST_RETURN],
+			[ST_THROW, _EXPR]
+		];
+
 		/**
 		 * (statement name):String -> (true if requires parentheses):Boolean
 		 */
 		private static var statements:Object = null;
-		
-		/**
-		 * String->Array.  Examples: "else"->["if"], "while"->["do"], "finally"->["try", "catch"], "catch"->["try"]
-		 */
-		private static var statementSiblingsLookup:Object = null;
 		
 		/**
 		 * This is the prefix used for the function notation of infix operators.

					//replace code between brackets with an int like {0} so the resulting string can be passed to StringUtil.substitute() with compiledObject as the next parameter
					output += input.substring(searchIndex, bracketIndex) + '{' + compiledObjects.length + '}';
					searchIndex = escapeIndex + 1;
					compiledObjects.push(compileTokens(tokens, false));
				}
			}
			throw new Error("unreachable");

				throw new Error("Missing operator between " + leftToken + ' and ' + rightToken);
			}

			if (allowSemicolons)
				return compileOperator(';', tokens);
			
			throw new Error("Empty expression");
