• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
      • Io
      • Defttag
      • Sys-call
      • Save-exec
      • Quicklisp
      • Std/io
      • Oslib
      • Bridge
      • Clex
      • Tshell
      • Unsound-eval
      • Hacker
      • ACL2s-interface
      • Startup-banner
      • Command-line
        • Save-exec
        • Argv
        • Getopt
          • Demo-p
          • Defoptions
          • Demo2
          • Parsers
            • Custom-parser
            • Parse-nat
            • Parse-plain
            • Parse-string
            • Parse-pos
            • Defparser
          • Sanity-check-formals
          • Formal->parser
          • Formal->argname
          • Formal->longname
          • Formal->alias
          • Formal->usage
          • Formal->merge
          • Formal->hiddenp
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Getopt

Parsers

Parsers for various kinds of command-line options.

Different programs will need to take all sorts of different kinds of options. For instance:

  • ssh takes a port number between 0 and 65535,
  • svn takes a revision number that can be a natural or a special word like HEAD, BASE, or PREV,
  • wget takes a URL,
  • mail takes an email address, and so on.

There's no way for getopt to anticipate and support everything that every program might want, so instead we use a table-driven approach that you can extend with custom parsers for your types.

Now, out of the box we do at least provide parsers for basic options like --verbose, --username jared, --level=100000, and so forth.

But when these aren't good enough, e.g., because you want to have stronger type requirements on your arguments structure, you can add your own custom-parser functions and plug them in.

Subtopics

Custom-parser
How to write custom argument-parsing functions.
Parse-nat
Parser for options that require a natp argument, e.g., --tabsize or -O, etc.
Parse-plain
Parser for plain, argument-free options that are off by default and must be explicitly enabled, e.g., --verbose or --force.
Parse-string
Parser for options that require an argument, but where any arbitrary string will do, e.g., --username or --eval.
Parse-pos
Parser for options that require a posp argument, e.g., --block-size or --line-number.
Defparser
Register a new argument-parsing function with getopt.