english
version "1.0"
identify "%Z%%M% %I% %E%"

#: Copyright (c) 1992-2005 by Wayne C. Gramlich.
#, All rights reserved.

module command_types

#: See description of {commands_parse} in commands_parse.sts.

define command_parse[options]
    record
	program_name string
	rules vector[command_rule[options]]
    generate allocate, erase, print

define command_rule[options]	# Information in each parsable rule.
    record
	data command_rule_data[options]	# More rule information.
	help string			# One-line help message
	name string			# Short name of rule (e.g. "-o <file>")
	used logical			# {true} => rule was used
    generate allocate, erase, print

define command_rule_data[options]
    variant type command_rule_type
	argument_optional		command_argument[options]
	argument_required		command_argument[options]
	arguments_optional		command_arguments[options]
	arguments_required		command_arguments[options]
	option_argument_optional	command_option_argument[options]
	option_argument_required	command_option_argument[options]
	option_arguments_optional	command_option_arguments[options]
	option_arguments_required	command_option_arguments[options]
	option_count			command_option_count[options]
	option_logical			command_option_logical[options]
    generate allocate, erase, print

define command_argument[options]	# E.g. <tar_file>
    routine_types
	procedure value_set
	    takes options, string
	    returns_nothing
    record
	value string
	value_set value_set
    generate allocate, erase, print

define command_arguments[options]	# E.g. <source_file> ...
    routine_types
	procedure value_set
	    takes options, vector[string]
	    returns_nothing
    record
	value vector[string]
	value_set value_set
    generate allocate, erase, print

define command_option_count[options]	# E.g. -x -xx -xxx
    routine_types
	procedure value_set
	    takes options, unsigned
	    returns_nothing
    record
	value unsigned
	value_set value_set
    generate allocate, erase, print

define command_option_logical[options]	# E.g. -c
    routine_types
	procedure value_set
	    takes options, logical
	    returns_nothing
    record
	value logical
	value_set value_set
    generate allocate, erase, print

define command_option_argument[options]	# E.g. -o <output_file>
    routine_types
	procedure value_set
	    takes options, string
	    returns_nothing
    record
	value string
	value_set value_set
    generate allocate, erase, print

define command_option_arguments[options] # E.g. -I <include_file> ...
    routine_types
	procedure value_set
	    takes options, vector[string]
	    returns_nothing
    record
	value vector[string]
	value_set value_set
    generate allocate, erase, print