The terse syntax added a semicolon automatically, but that also meant
that things lik:
csharp> for (int i = 0; i < 10; i++)
Would never get a continuation for partial input, since the semicolon
woudl make that a valid block.
Fix that by first trying to add a block at the end, if that works, then
we know we want to continue, otherwise we insert the semicolon.
bool partial_input;
CSharpParser parser = ParseString (ParseMode.Silent, input, out partial_input);
+
+ // Terse mode, try to provide the trailing semicolon automatically.
if (parser == null && Terse && partial_input){
bool ignore;
- parser = ParseString (ParseMode.Silent, input + ";", out ignore);
+
+ // check if the source would compile with a block, if so, we should not
+ // add the semicolon.
+ var needs_block = ParseString (ParseMode.Silent, input + "{}", out ignore) != null;
+ if (!needs_block)
+ parser = ParseString (ParseMode.Silent, input + ";", out ignore);
}
if (parser == null){
compiled = null;