source_file
comment "//===-------------------------------------------------------"...
comment "//"
comment "// This source file is part of the Swift Argument Parser ope"...
comment "//"
comment "// Copyright (c) 2020 Apple Inc. and the Swift project autho"...
comment "// Licensed under Apache License v2.0 with Runtime Library E"...
comment "//"
comment "// See https://swift.org/LICENSE.txt for license information"
comment "//"
comment "//===-------------------------------------------------------"...
directive
#if "#if"
compiler "compiler"
( "("
>= ">="
integer_literal "6"
. "."
integer_literal "0"
) ")"
import_declaration
modifiers
visibility_modifier
internal "internal"
import "import"
identifier
simple_identifier "Foundation"
directive
#else "#else"
import_declaration
import "import"
identifier
simple_identifier "Foundation"
directive
#endif "#endif"
comment "/// A type that can be parsed from a program's command-line "...
comment "///"
comment "/// When you implement a `ParsableArguments` type, all prope"...
comment "/// one of the four property wrappers provided by the `Argum"...
protocol_declaration (+54 nodes collapsed)
comment "/// A type that provides the `ParsableCommand` interface to "...
class_declaration
struct "struct"
type_identifier "_WrappedParsableCommand"
type_parameters
< "<"
type_parameter
type_identifier "P"
: ":"
user_type
type_identifier "ParsableArguments"
> ">"
: ":"
inheritance_specifier
user_type
type_identifier "ParsableCommand"
class_body
{ "{"
property_declaration
modifiers
property_modifier
static "static"
value_binding_pattern
var "var"
pattern
simple_identifier "_commandName"
type_annotation
: ":"
user_type
type_identifier "String"
computed_property
{ "{"
statements
property_declaration (+30 nodes collapsed)
comment "// If the type is named something like \"TransformOptions\", w"...
comment "// to use \"transform\" as the command name."
if_statement
if "if"
value_binding_pattern
let "let"
simple_identifier "optionsRange"
= "="
call_expression
navigation_expression
simple_identifier "name"
navigation_suffix
. "."
simple_identifier "range"
call_suffix
value_arguments
( "("
value_argument
value_argument_label
simple_identifier "of"
: ":"
line_string_literal
" "\""
line_str_text "_options"
" "\""
) ")"
, ","
equality_expression
navigation_expression
simple_identifier "optionsRange"
navigation_suffix
. "."
simple_identifier "upperBound"
== "=="
navigation_expression
simple_identifier "name"
navigation_suffix
. "."
simple_identifier "endIndex"
{ "{"
statements
control_transfer_statement
return "return"
call_expression
simple_identifier "String"
call_suffix
value_arguments
( "("
value_argument
call_expression
simple_identifier "name"
call_suffix
value_arguments
[ "["
value_argument
open_start_range_expression
..< "..<"
navigation_expression
simple_identifier "optionsRange"
navigation_suffix
. "."
simple_identifier "lowerBound"
] "]"
) ")"
} "}"
else "else"
{ "{"
statements
control_transfer_statement
return "return"
simple_identifier "name"
} "}"
} "}"
property_declaration
modifiers
attribute
@ "@"
user_type
type_identifier "OptionGroup"
value_binding_pattern
var "var"
pattern
simple_identifier "options"
type_annotation
: ":"
user_type
type_identifier "P"
} "}"
class_declaration (+88 nodes collapsed)
comment "// MARK: - API"
class_declaration (+1064 nodes collapsed)
comment "/// Unboxes the given value if it is a `nil` value."
comment "///"
comment "/// If the value passed is the `.none` case of any optional "...
comment "/// returns `nil`."
comment "///"
comment "/// let intAsAny = (1 as Int?) as Any"
comment "/// let nilAsAny = (nil as Int?) as Any"
comment "/// nilOrValue(intAsAny) // Optional(1) as Any?"
comment "/// nilOrValue(nilAsAny) // nil as Any?"
function_declaration (+48 nodes collapsed)
comment "/// Existential protocol for property wrappers, so that they"...
comment "/// the argument set that they define."
protocol_declaration (+34 nodes collapsed)
class_declaration (+23 nodes collapsed)
class_declaration (+358 nodes collapsed)
comment "/// Prints the given message to standard error and exits wit"...
comment "///"
comment "/// - Parameter message: The message to print to standard er"...
comment "/// should be pre-wrapped, if desired."
function_declaration (+169 nodes collapsed)
comment "/// The fatal error message to display when someone accesses"...
comment "/// `ParsableArguments` type after initializing it directly."
property_declaration
modifiers
visibility_modifier
internal "internal"
value_binding_pattern
let "let"
pattern
simple_identifier "directlyInitializedError"
= "="
multi_line_string_literal
""" "\"\"\""
multi_line_str_text "\n Can't read a value from a parsable\u{a0}argument definition.\n\n"...
""" "\"\"\""