Add Terse syntax to C#, making the last semicolon optional
authorMiguel de Icaza <miguel@gnome.org>
Thu, 29 Sep 2011 14:33:11 +0000 (10:33 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Sun, 16 Oct 2011 15:45:58 +0000 (11:45 -0400)
mcs/mcs/eval.cs

index d7624367f14effb4230da6b000f1645591fdd0fa..0e3bd7146815e20b1c6dacd0602d8bdfbbf4724b 100644 (file)
@@ -136,6 +136,11 @@ namespace Mono.CSharp
                /// </summary>
                public bool DescribeTypeExpressions;
 
+               /// <summary>
+               ///   Whether the evaluator will use terse syntax, and the semicolons at the end are optional
+               /// </summary>
+               public bool Terse = true;
+
                /// <summary>
                ///   The base class for the classes that host the user generated code
                /// </summary>
@@ -202,7 +207,7 @@ namespace Mono.CSharp
                ///   compiled parameter will be set to the delegate
                ///   that can be invoked to execute the code.
                ///
-           /// </remarks>
+               /// </remarks>
                public string Compile (string input, out CompiledMethod compiled)
                {
                        if (input == null || input.Length == 0){
@@ -220,6 +225,10 @@ namespace Mono.CSharp
 
                                bool partial_input;
                                CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input);
+                               if (parser == null && Terse && partial_input){
+                                       bool ignore;
+                                       parser = ParseString (ParseMode.Silent, input + ";", out ignore);
+                               }
                                if (parser == null){
                                        compiled = null;
                                        if (partial_input)