1:- module(tokenize_opts, 2 [process_options/4, 3 preopts_data/3, 4 tokenopts_data/3, 5 postopts_data/3]). 6 7:- use_module(library(record)). 8 9/** <module> tokenize_opts 10 11This is an internal module used for option processing. The predicates exported 12are not meant for use by client code. 13*/ 14 15% pre-processing options 16:- record preopts( 17 cased:boolean=false 18 ). 19 20% tokenization options 21:- record tokenopts( 22 numbers:boolean=true, 23 strings:boolean=true 24 ). 25 26% post-processing options 27:- record postopts( spaces:boolean=true, cntrl:boolean=true, punct:boolean=true, to:oneof([strings,atoms,chars,codes])=atoms, pack:boolean=false ).
37process_options(Options, PreOpts, TokenOpts, PostOpts) :- 38 make_preopts(Options, PreOpts, Rest0), 39 make_postopts(Rest0, PostOpts, Rest1), 40 make_tokenopts(Rest1, TokenOpts, InvalidOpts), 41 throw_on_invalid_options(InvalidOpts). 42 43throw_on_invalid_options(InvalidOpts) :- 44 InvalidOpts \= [] 45 -> throw(invalid_options_given(InvalidOpts)) 46 ; true