Bigloo supports command line argument parsing. That is, when an
application is spawn from an Unix shell, the 
main function
 is called and its argument is bound to the list of the command line
arguments, See 
Module Declaration. The
args-parse form may be used to parse these.
| 
The argument| args-parse list rules [null-rule] [else-rule] ... | bigloo syntax |  listis a list of strings.Rulesis defined by
the following grammar:
 
 
Each elements of| <rule>      ==> (section<string>)
              | ((<option> <help>) <s-expression>)
              | ((<option>) <s-expression>)
              | ((<flag> <var> <var> ...) <s-expression>)
              | ((<flag> <var> <var> ... <help>) <s-expression>)
<null-rule> ==> (()<s-expression>)
<else-rule> ==> (else<s-expression>)
<option>    ==> <flag>
              | <string><var>
<flag>      ==> <string>
              | (<string>+)
<var>       ==> an identifier leaded by the?character
<help>      ==> (help<s-expression>)
              | (help<string> <s-expression>) |  listare match against therules. If one
of these matches,args-parseproceeds as follows:
 
 The matched argument elements of listare removed from the list.The <s-expression>associated to the matching rule
      is evaluated in an environment where the rule variables are bound.The argument parsing is resumed with the rest of list.
 | 
In addition to parsing the command line arguments, 
args-parse enables
help message printing. 
| 
This is a procedure of one argument, an boolean.| args-parse-usage fmt | bigloo procedure |  Args-parse-usageconstructs an help message from all the option described in aargs-parseform.Args-parse-usageis only defined in the<s-expression>of anargs-parseform. | 
At last, if no rule matches an argument and if the 
args-parse
form contains an 
else rule, this is evaluated. In the
<s-expression> part of that rule, the pseudo-variable
else is bound to the first unmatched argument and the pseudo-variable
rest is bound to all the unmatched arguments.
Here is an example of argument parsing deploying all the possible rules:
| (module args-example
   (main main))
 (define (main argv)
   (args-parse (cdr argv)
      (section "Help")
      (("?")
       (args-parse-usage #f))
      ((("-h" "--help") (help "?,-h,--help" "This help message"))
       (args-parse-usage #f))
      (section "Misc")
      ((("-v" "--version") (help "Version number"))
       (print *version*))
      (("-o" ?file (help "The output file"))
       (set! *dest* file))
      (("--input=?file" (help "The input file"))
       (set! *input* file))
      (else
       (print "Illegal argument `" else "'. Usage:")
       (args-parse-usage #f))))
 | 
Invoking the compiled 
args-example module could produce:
| > bigloo.new args.scm
args.scm:
> a.out toto        
Illegal argument `toto'. Usage:
 Help:
   ?,-h,--help    --  This help message
 
 Misc:
   -v,--version   --  Version number
   -o <file>      --  The output file
   --input=<file> --  The input file
 |