::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:
class Program.Argument.Public  public Gilda:  Library interface.

  type Program.Argument  is         &Library used by generated parameter lists
       Position  word,              &Position of the next argument to parse
       Max       word,              &Last argument to convert
      @List[?]   At..byte           :Pointer to the next argument to convert

  type Signature     is             &Method or command signature
       Verb          string,        &The verb name; Uppercase if insensitive
       Purpose       string,        &The commands purpose; May have new lines.
       Size          byte,          &Number of parameters (up to 255)
       Intrinsic     byte,          &Index of intrinsic command
      @List[1 To Size]  Declaration

  type Path  is  Value  string
  type Tail  is  Value  string      :Parameter containing the rest of the line
  type Name  is  Value  string

  type Name.List  is                &Parameter that is a list of Gilda names
       Value   Heap..string

  type Path.List  is                &Parameter that is a list of Dual paths
       Value   Heap..string

  type Type  is                           &Encoded type declaration.
     @Type = 0    Key..User.Type,         &

      User        =>  $Type`Tag,          &Failed to resolve with an @
      User.Name   =>  $Type`Key,          &
      Is.User     =>  @$Type > #FFFF,     &Structure or enumeration (non-zero).

      As.Base     =>  parcel{ @$Type },   &Intrinsic (and non-zero). positive???

      Is( .Type ) =>  @$Type = $.Type,    &EQ( @$Type, .b ) to embed???

      Byte    |=  Byte.Type,              &Primitive type encodings
      Parcel  |=  Parcel.Type,            &
      Word    |=  Word.Type,              &
      Cell    |=  Cell.Type,              &
      String  |=  String.Type,            &
      Single  |=  Single.Type,            &
      Double  |=  Double.Type,            &
      Micro   |=  Micro.Type,             &
      Macro   |=  Macro.Type

  type User.Type                            &User type declaration

   is Flag  = 0  byte,                      &Undefined, Numerate, Genuine,
                                            &   Big, Dynamic, Record

      Align = 0  byte,                      &Log2( alignment)  #FF for natural
                                            &  (0 --> BYTE, ..., 126 --> 2^126)

      Count = 0  parcel,                    &Number of fields for this type
                                            &Maximum enumerated type number

      Field = 0  word,                      &First:  Heap( Ic.Field, Field - 1 )
                                            &Zero if a range enumeration

      Size  = 0  word,                      &Number of bytes (with internal
                                            &   padding) for this type.

      Is.Numerate  => $Flag /\ $Numerate,   &Enumerated type
      Is.Undefined => $Flag /\ $Undefined,  &The type has not been declared.
      Is.Genuine   => $Flag /\ $Genuine,    &Fake types are not allowed.
      Is.Dynamic   => $Flag /\ $Dynamic,    &A structure contains a pointer.
      Is.Record    => $Flag /\ $Record,     &A structure is a record type.
      Is.Extended  => $Flag /\ $Extended,   &In a sequence
      Is.Big       => $Size _> Big.Size,    &Is a big structure

      Numerate  |= Numerate.Flag,           &An enumerated type
      Undefined |= Undefined.Flag,          &The type has not been declared.
      Genuine   |= Genuine.Flag,            &Fake types are not allowed.
      Dynamic   |= Dynamic.Flag,            &A structure contains a pointer.
      Record    |= Record.Flag,             &A structure is a record type.
      Extended  |= Extended.Flag            :In a sequence

import Key(User.Type),
       Declaration

global &This is used for the flag field in declarations for
       &      class types, and class type fields.
       &
       Numerate.Flag  |=   1, &A structure field is an enumerated type.
       Undefined.Flag |=   2, &A structure field is not yet declared.
       Genuine.Flag   |=   4, &The type is not allowed to be faked.
       Dynamic.Flag   |=   8, &A structure contains a pointer.
       Record.Flag    |= #10, &A structure is a record type.
       Extended.Flag  |= #20, &A structure has extended fields.
       Big.Size       |= 128 :Largest structure size before treating it as big

global Byte.Type  |= 'B',           &#42   66     Encoded Gilda primitive types
     Parcel.Type  |= 'P',           &#50   80
       Word.Type  |= 'W',           &#57   87
       Cell.Type  |= 'C',           &#43   67
     String.Type  |= 'S',           &#53   83
     Single.Type  |= '1',           &#31   49
     Double.Type  |= '2',           &#32   50
      Micro.Type  |= '|',           &#7C  124
      Macro.Type  |= '>'            :#3E   62

global Bit.Type       |= #111,      &Encodings for program types
       Name.Type      |= #222,      &
       Name.List.Type |= #333,      &
       Path.Type      |= #444,      &
       Path.List.Type |= #555,      &
       Tail.Type      |= #666
:

;import Type.Integer,
;       Type.Real
:
:...............................................................................



::::::::::::::::::::::::  program/argument/Declaration  ::::::::::::::::::::::::
:
method SIGNATURE  pure:  Setup a method call data structure.

change Signature                          :A signature to be initialized

 entry Verb               string,         &Verb name; Uppercase if insensitive
       Parameter[1 To *]  Declaration,    &Method parameter list to fill in
       Intrinsic = 0      byte,           &Index of an intrinsic command
       Purpose   = ""     string
:
:  The Intrinsic field is used by Intrinsic.Command and passed on to
:  Call.Intrinsic so that it can find the address of the method.
:...............................................................................
:
method PARAMETER  pure:  Append a parameter declaration to a signature.

change Signature                    :Procedure signature to be updated

 entry Name           string,       &Name of the parameter
       Verb           Declare,      &Kind of parameter
       Type,                        &Parameter's type
       Default = ""   string,       &Default value; a static expression
       Purpose = ""   string,       &Parameter description
       Range   = ""   string,       &An optional array range
       At      = 0    Bit,          &A pointer Exit parameter
       Import  = 0    Bit           :Set if an imported value
:
:...............................................................................
:
method ARGUMENT.POSITIONAL:  Convert program arguments to positional values.

 entry Argc          word,        &Number of command parameters.
       Argv[0]       C.String,    &Address of the command line text.
       Method        Signature    :Method description.

change Call[1 To *]  string       :Callers argument list; Bound is Method`Size

  exit Help          Bit          :Set when the "-?" argument is given.
:
:..............................................................................
:
method ASSIGN.LIST:  Convert a path or name list field to an Array of Strings.

change Value     Heap..string   :In - Empty; Out - Set to argument items

 entry Argument  string         :List of values separated by a single semicolon
:
:...............................................................................
:
function FORM..Declaration:  Format a variable declaration for display.

 entry Declaration[0],        &Declaration to format
       Format = ""  string    :Not used

  exit Form   string          :Name  ['['  Range  ']']  ['='  Default]
:
:...............................................................................
:
function FORM..Type:  Format a type declaration for display.

 entry Type[0],               &Type to format
       Format = ""  string    :'p' or "P" for proper case; else a string format

  exit Form   string          :<User Type Name> | <Primitive Type> | "Not known"
:
:...............................................................................
:
function FORM..User.Type:  Format a user defined type declaration.

 entry User.Type[0],          &User defined type to format
       Format = ""  string    :Not used

  exit Form   string          :'{'  "{Flag=#"  Flag   " Align="  Align
:                                   "Count="   Count  " Field="  Field
:                                   " Size="   Size  '}'
:...............................................................................



:::::::::::::::::::::::  program/argument/Root.Argument  :::::::::::::::::::::::
:
method OPEN.CONVERT.LIST:  Initialize parameter list conversion.
:
:...............................................................................
:
method CONVERT.INTEGER:  Convert a string to a parameter value.

 entry Field      string,      &An integer or an invalid value
       Size       word         :Number of bytes in the parameter type.

  exit Parameter  cell         :Value truncated to fit in the parameter type
:
:...............................................................................
:
function CONVERT.STRING:  Convert a string to an argument value.

 entry Field      At..string    :A static string expression

  exit Parameter  cell          :Header of the argument value (zero extended)
:
:...............................................................................
:
method CONVERT.BIT:  Convert a string to a parameter value.

 entry Field      string        :0, 1 or an invalid value.

  exit Parameter  cell          :0 or 1
:
:...............................................................................
:
method CONVERT.PATH.LIST:  Convert a path list field to an Array of Strings.
                        :  Only one path list per command is allowed.

 entry Field      string       :A list of paths separated by a single semicolon

  exit Parameter  cell         :Header address for the array of strings
:
:...............................................................................
:
method CONVERT.NAME.LIST:  Convert a name list field to an Array of Strings.
                        :  Only one name list per command is allowed.

 entry Field      string       :A list of names separated by a single semicolon

  exit Parameter  cell         :Header address for the array of strings
:
:...............................................................................


end