Module: Acclaim::Option::Parser::Regexp
- Included in:
- Acclaim::Option::Parser
- Defined in:
- lib/acclaim/option/parser/regexp.rb
Overview
Contains all regular expressions used by the parser.
Constant Summary collapse
- SHORT_SWITCH =
Regular expression for a short option switch.
Examples:
-s; -_
'-mult'
should match MULTIPLE_SHORT_SWITCHES, and will be split into%w(-m -u -l -t)
, which in turn should match this regular expression.w is not used because it matches digits.
/\A-[a-zA-Z_]\Z/.freeze
- LONG_SWITCH =
Regular expression for a long option switch.
Examples:
--long; --no-feature; --with_underscore; --_private-option; --1-1
/\A--\w+(-\w+)*\Z/.freeze
- MULTIPLE_SHORT_SWITCHES =
Regular expression for multiple short options in a single “short” switch.
Examples:
-xvf; -abc; -de_f
w is not used because it matches digits.
/\A-[a-zA-Z_]{2,}\Z/.freeze
- SWITCH_PARAM_EQUALS =
Regular expression for a long switch connected to its parameters with an equal sign. Multiple parameters are be separated by commas.
Examples:
--switch=PARAM; --files=f1,f2,f3; --weird=,PARAM2; --empty=,,; --none=
The reason something like
'--none='
is allowed is because it will become['--none']
when it is split up.'--empty=,,'
will become['--empty']
'--weird=,PARAM2'
will become['--weird', '', 'PARAM2']
when it is split up. What to make of those isn’t a decision for a preprocessor. /\A--\w+(-\w+)*=(,*\w*)*\Z/.freeze
- SWITCH =
Regular expression for any kind of option switch.
::Regexp.union(SHORT_SWITCH, LONG_SWITCH, MULTIPLE_SHORT_SWITCHES, SWITCH_PARAM_EQUALS).freeze
- ARGUMENT_SEPARATOR =
Regular expression for the string that separates options and their parameters from arguments like filenames.
Examples:
--; ---
/\A-{2,}\Z/.freeze