@@ -261,31 +261,40 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
261261
262262 let specs = List.collect GetOptionsOfBlock blocks
263263
264- // returns a tuple - the option token, the option argument string
265- let parseOption ( s : string ) =
266- // grab the option token
267- let opts = s.Split([| ':' |])
268- let mutable opt = opts[ 0 ]
269-
270- if opt = " " then
271- ()
272- // if it doesn't start with a '-' or '/', reject outright
273- elif opt[ 0 ] <> '-' && opt[ 0 ] <> '/' then
274- opt <- " "
275- elif opt <> " --" then
276- // is it an abbreviated or MSFT-style option?
277- // if so, strip the first character and move on with your life
278- if opt.Length = 2 || isSlashOpt opt then
279- opt <- opt[ 1 ..]
280- // else, it should be a non-abbreviated option starting with "--"
281- elif opt.Length > 3 && opt.StartsWithOrdinal( " --" ) then
282- opt <- opt[ 2 ..]
264+ // returns a tuple - the option minus switchchars, the option tokenand the option argument string
265+ let parseOption ( option : string ) =
266+
267+ // Get option arguments, I.e everything following first:
268+ let opts = option.Split([| ':' |])
269+ let optArgs = String.Join( " :" , opts[ 1 ..])
270+
271+ let opt =
272+ if option = " " then
273+ " "
274+ // if it doesn't start with a '-' or '/', reject outright
275+ elif option[ 0 ] <> '-' && option[ 0 ] <> '/' then
276+ " "
277+ elif option <> " --" then
278+ // is it an abbreviated or MSFT-style option?
279+ // if so, strip the first character and move on with your life
280+ // Wierdly a -- option can't have only a 1 character name
281+ if option.Length = 2 || isSlashOpt option then
282+ option[ 1 ..]
283+ elif option.Length >= 3 && option[ 2 ] = ':' then
284+ option[ 1 ..]
285+ elif option.StartsWithOrdinal( " --" ) then
286+ match option.Length with
287+ | l when l >= 4 && option[ 3 ] = ':' -> " "
288+ | l when l > 3 -> option[ 2 ..]
289+ | _ -> " "
290+ else
291+ " "
283292 else
284- opt <- " "
293+ option
285294
286- // get the argument string
287- let optArgs = if opts.Length > 1 then String.Join ( " : " , opts [ 1 ..]) else " "
288- opt, optArgs
295+ // grab the option token
296+ let token = opt.Split ([| ':' |])[ 0 ]
297+ opt, token , optArgs
289298
290299 let getOptionArg compilerOption ( argString : string ) =
291300 if argString = " " then
@@ -352,7 +361,7 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
352361
353362 processArg ( responseFileOptions @ t)
354363 | opt :: t ->
355- let optToken , argString = parseOption opt
364+ let option , optToken , argString = parseOption opt
356365
357366 let reportDeprecatedOption errOpt =
358367 match errOpt with
@@ -361,7 +370,7 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler
361370
362371 let rec attempt l =
363372 match l with
364- | CompilerOption ( s, _, OptionConsoleOnly f, d, _) :: _ when optToken = s && argString = " " ->
373+ | CompilerOption ( s, _, OptionConsoleOnly f, d, _) :: _ when option = s ->
365374 reportDeprecatedOption d
366375 f blocks
367376 t
@@ -710,7 +719,7 @@ let tagAlgorithm = "{SHA1|SHA256}"
710719let tagInt = " <n>"
711720let tagPathMap = " <path=sourcePath;...>"
712721let tagNone = " "
713- let tagLangVersionValues = " {?| version|latest|preview}"
722+ let tagLangVersionValues = " {version|latest|preview}"
714723
715724// PrintOptionInfo
716725//----------------
@@ -1104,23 +1113,16 @@ let mlCompatibilityFlag (tcConfigB: TcConfigBuilder) =
11041113 Some( FSComp.SR.optsMlcompatibility ())
11051114 )
11061115
1107- /// LanguageVersion management
1108- let setLanguageVersion specifiedVersion =
1109-
1110- let dumpAllowedValues () =
1111- printfn " %s " ( FSComp.SR.optsSupportedLangVersions ())
1112-
1113- for v in LanguageVersion.ValidOptions do
1114- printfn " %s " v
1115-
1116- for v in LanguageVersion.ValidVersions do
1117- printfn " %s " v
1118-
1119- exit 0
1116+ let GetLanguageVersions () =
1117+ seq {
1118+ FSComp.SR.optsSupportedLangVersions ()
1119+ yield ! LanguageVersion.ValidOptions
1120+ yield ! LanguageVersion.ValidVersions
1121+ }
1122+ |> String.concat Environment.NewLine
11201123
1121- if specifiedVersion = " ?" then
1122- dumpAllowedValues ()
1123- elif specifiedVersion.ToUpperInvariant() = " PREVIEW" then
1124+ let setLanguageVersion ( specifiedVersion : string ) =
1125+ if specifiedVersion.ToUpperInvariant() = " PREVIEW" then
11241126 ()
11251127 elif not ( LanguageVersion.ContainsVersion specifiedVersion) then
11261128 error ( Error( FSComp.SR.optsUnrecognizedLanguageVersion specifiedVersion, rangeCmdArgs))
@@ -1130,6 +1132,16 @@ let setLanguageVersion specifiedVersion =
11301132let languageFlags tcConfigB =
11311133 [
11321134 // -langversion:? Display the allowed values for language version
1135+ CompilerOption(
1136+ " langversion:?" ,
1137+ tagNone,
1138+ OptionConsoleOnly( fun _ ->
1139+ Console.Write( GetLanguageVersions())
1140+ exit 0 ),
1141+ None,
1142+ Some( FSComp.SR.optsGetLangVersions ())
1143+ )
1144+
11331145 // -langversion:<string> Specify language version such as
11341146 // 'default' (latest major version), or
11351147 // 'latest' (latest version, including minor versions),
@@ -1140,7 +1152,7 @@ let languageFlags tcConfigB =
11401152 tagLangVersionValues,
11411153 OptionString( fun switch -> tcConfigB.langVersion <- setLanguageVersion ( switch)),
11421154 None,
1143- Some( FSComp.SR.optsLangVersion ())
1155+ Some( FSComp.SR.optsSetLangVersion ())
11441156 )
11451157
11461158 CompilerOption(
0 commit comments