Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lexx/yacc warnings #10950

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/buildtools/fslex/Arg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ type ArgParser() =
sbuf.ToString()


static member ParsePartial(cursor,argv,argSpecs:seq<ArgInfo>,?other,?usageText) =
let other = defaultArg other (fun _ -> ())
static member ParsePartial(cursor,argv,arguments:seq<ArgInfo>,?otherArgs,?usageText) =
let otherArgs = defaultArg otherArgs (fun _ -> ())
let usageText = defaultArg usageText ""
let nargs = Array.length argv
incr cursor;
let argSpecs = argSpecs |> Seq.toList
let specs = argSpecs |> List.map (fun (arg:ArgInfo) -> arg.Name, arg.ArgType)
let arguments = arguments |> Seq.toList
let specs = arguments |> List.map (fun (arg:ArgInfo) -> arg.Name, arg.ArgType)
while !cursor < nargs do
let arg = argv.[!cursor]
let rec findMatchingArg args =
match args with
| ((s, action) :: _) when s = arg ->
let getSecondArg () =
if !cursor + 1 >= nargs then
raise(Bad("option "+s+" needs an argument.\n"+getUsage argSpecs usageText));
raise(Bad("option "+s+" needs an argument.\n"+getUsage arguments usageText));
argv.[!cursor+1]

match action with
Expand All @@ -85,12 +85,12 @@ type ArgParser() =
cursor := !cursor + 2
| IntArg f ->
let arg2 = getSecondArg ()
let arg2 = try int32 arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in
let arg2 = try int32 arg2 with _ -> raise(Bad(getUsage arguments usageText)) in
f arg2;
cursor := !cursor + 2;
| FloatArg f ->
let arg2 = getSecondArg()
let arg2 = try float arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in
let arg2 = try float arg2 with _ -> raise(Bad(getUsage arguments usageText)) in
f arg2;
cursor := !cursor + 2;
| RestArg f ->
Expand All @@ -102,26 +102,26 @@ type ArgParser() =
| (_ :: more) -> findMatchingArg more
| [] ->
if arg = "-help" || arg = "--help" || arg = "/help" || arg = "/help" || arg = "/?" then
raise (HelpText (getUsage argSpecs usageText))
raise (HelpText (getUsage arguments usageText))
// Note: for '/abc/def' does not count as an argument
// Note: '/abc' does
elif arg.Length>0 && (arg.[0] = '-' || (arg.[0] = '/' && not (arg.Length > 1 && arg.[1..].Contains ("/")))) then
raise (Bad ("unrecognized argument: "+ arg + "\n" + getUsage argSpecs usageText))
raise (Bad ("unrecognized argument: "+ arg + "\n" + getUsage arguments usageText))
else
other arg;
otherArgs arg;
incr cursor
findMatchingArg specs

static member Usage (specs,?usage) =
static member Usage (arguments,?usage) =
let usage = defaultArg usage ""
System.Console.Error.WriteLine (getUsage (Seq.toList specs) usage)
System.Console.Error.WriteLine (getUsage (Seq.toList arguments) usage)

#if FX_NO_COMMAND_LINE_ARGS
#else
static member Parse (specs,?other,?usageText) =
static member Parse (arguments,?otherArgs,?usageText) =
let current = ref 0
let argv = System.Environment.GetCommandLineArgs()
try ArgParser.ParsePartial (current, argv, specs, ?other=other, ?usageText=usageText)
try ArgParser.ParsePartial (current, argv, arguments, ?otherArgs=otherArgs, ?usageText=usageText)
with
| Bad h
| HelpText h ->
Expand Down
28 changes: 14 additions & 14 deletions src/buildtools/fsyacc/Arg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ type ArgParser() =
sbuf.ToString()


static member ParsePartial(cursor,argv,argSpecs:seq<ArgInfo>,?other,?usageText) =
let other = defaultArg other (fun _ -> ())
static member ParsePartial(cursor,argv,arguments:seq<ArgInfo>,?otherArgs,?usageText) =
let otherArgs = defaultArg otherArgs (fun _ -> ())
let usageText = defaultArg usageText ""
let nargs = Array.length argv
incr cursor;
let argSpecs = argSpecs |> Seq.toList
let specs = argSpecs |> List.map (fun (arg:ArgInfo) -> arg.Name, arg.ArgType)
let arguments = arguments |> Seq.toList
let specs = arguments |> List.map (fun (arg:ArgInfo) -> arg.Name, arg.ArgType)
while !cursor < nargs do
let arg = argv.[!cursor]
let rec findMatchingArg args =
match args with
| ((s, action) :: _) when s = arg ->
let getSecondArg () =
if !cursor + 1 >= nargs then
raise(Bad("option "+s+" needs an argument.\n"+getUsage argSpecs usageText));
raise(Bad("option "+s+" needs an argument.\n"+getUsage arguments usageText));
argv.[!cursor+1]

match action with
Expand All @@ -85,12 +85,12 @@ type ArgParser() =
cursor := !cursor + 2
| IntArg f ->
let arg2 = getSecondArg ()
let arg2 = try int32 arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in
let arg2 = try int32 arg2 with _ -> raise(Bad(getUsage arguments usageText)) in
f arg2;
cursor := !cursor + 2;
| FloatArg f ->
let arg2 = getSecondArg()
let arg2 = try float arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in
let arg2 = try float arg2 with _ -> raise(Bad(getUsage arguments usageText)) in
f arg2;
cursor := !cursor + 2;
| RestArg f ->
Expand All @@ -102,26 +102,26 @@ type ArgParser() =
| (_ :: more) -> findMatchingArg more
| [] ->
if arg = "-help" || arg = "--help" || arg = "/help" || arg = "/help" || arg = "/?" then
raise (HelpText (getUsage argSpecs usageText))
raise (HelpText (getUsage arguments usageText))
// Note: for '/abc/def' does not count as an argument
// Note: '/abc' does
elif arg.Length>0 && (arg.[0] = '-' || (arg.[0] = '/' && not (arg.Length > 1 && arg.[1..].Contains ("/")))) then
raise (Bad ("unrecognized argument: "+ arg + "\n" + getUsage argSpecs usageText))
raise (Bad ("unrecognized argument: "+ arg + "\n" + getUsage arguments usageText))
else
other arg;
otherArgs arg;
incr cursor
findMatchingArg specs

static member Usage (specs,?usage) =
static member Usage (arguments,?usage) =
let usage = defaultArg usage ""
System.Console.Error.WriteLine (getUsage (Seq.toList specs) usage)
System.Console.Error.WriteLine (getUsage (Seq.toList arguments) usage)

#if FX_NO_COMMAND_LINE_ARGS
#else
static member Parse (specs,?other,?usageText) =
static member Parse (arguments,?otherArgs,?usageText) =
let current = ref 0
let argv = System.Environment.GetCommandLineArgs()
try ArgParser.ParsePartial (current, argv, specs, ?other=other, ?usageText=usageText)
try ArgParser.ParsePartial (current, argv, arguments, ?otherArgs=otherArgs, ?usageText=usageText)
with
| Bad h
| HelpText h ->
Expand Down
2 changes: 1 addition & 1 deletion src/buildtools/fsyacc/Parsing.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type Tables<'tok> =

/// Interpret the parser table taking input from the given lexer, using the given lex buffer, and the given start state.
/// Returns an object indicating the final synthesized value for the parse.
member Interpret : lexer:(LexBuffer<'char> -> 'tok) * lexbuf:LexBuffer<'char> * startState:int -> obj
member Interpret : lexer:(LexBuffer<'char> -> 'tok) * lexbuf:LexBuffer<'char> * initialState:int -> obj

#if INTERNALIZED_FSLEXYACC_RUNTIME
exception internal Accept of obj
Expand Down