4 # Morgan Deters <mdeters@cs.nyu.edu> for CVC4
5 # Copyright (c) 2011-2014 The CVC4 Project
7 # The purpose of this script is to create options.{h,cpp}
8 # from template files and a list of options.
12 # mkoptions (template-file output-file)+ -t options.h-template options.cpp-template (options-file output-dir)+
20 echo "usage: $me (template-file output-file)+ -t options.h-template options.cpp-template (options-file output-dir)+" >&2
24 if [ -t 1 ]; then r
="\r"; else r
=""; fi
26 file="$(expr "$1" : '.*\(.................................................................\)')"
27 if [ -z "$file" ]; then file="$1"; else file="[...]$file"; fi
28 [ -t 1 ] && printf "$r%c %-70s (%3d%%)" "$progress_char" "$file" "$(($2*100/$3))"
29 progress_char
="`echo "$progress_char" | tr -- '-\\\\|/' '\\\\|/-'`"
33 printf "$r%-80s\n" "$kf:$lineno: note: $@"
37 printf "$r%-80s\n" "$kf:$lineno: warning: $@"
41 printf "$r%-80s\n" "$kf:$lineno: error: $@"
48 while [ "$1" != -t ]; do
49 if [ "$#" -lt 2 ]; then
50 echo "$me: error: expected -t on command line" >&2
54 templates
[${#templates[@]}]="$1"; shift
55 if [ "$1" = -t ]; then
56 echo "$me: error: mismatched number of templates and output files (before -t)" >&2
60 outputs
[${#outputs[@]}]="$1"; shift
64 if [ "$#" -lt 3 ]; then
65 echo "$me: error: not enough arguments" >&2
70 options_h_template
="$1"; shift
71 options_cpp_template
="$1"; shift
74 all_modules_short_options
=
75 all_modules_long_options
=
76 all_modules_smt_options
=
77 all_modules_option_handlers
=
78 all_modules_get_options
=
79 smt_getoption_handlers
=
80 smt_setoption_handlers
=
81 include_all_option_headers
=
82 all_modules_contributions
=
83 option_handler_includes
=
86 remaining_documentation
=
87 common_manpage_documentation
=
88 remaining_manpage_documentation
=
89 common_manpage_smt_documentation
=
90 remaining_manpage_smt_documentation
=
91 common_manpage_internals_documentation
=
92 remaining_manpage_internals_documentation
=
97 expect_doc_alternate
=false
104 short_option_alternate
=
106 long_option_alternate
=
107 long_option_alternate_set
=
111 # just for duplicates-checking
112 all_declared_internal_options
=
113 all_declared_long_options
=
114 all_declared_short_options
=
115 all_declared_smt_options
=
117 long_option_value_begin
=$n_long
125 module_optionholder_spec
=
127 module_specializations
=
130 module_global_definitions
=
133 if [ $# -lt 3 -o -z "$1" -o -z "$2" -o -z "$3" ]; then
134 ERR
"\"module\" directive requires exactly three arguments"
137 module_id
="$1"; shift
140 include_all_option_headers
="${include_all_option_headers}
141 #line $lineno \"$kf\"
142 #include $(check_include "$include")"
143 all_modules_contributions
="${all_modules_contributions}
144 CVC4_OPTIONS__${module_id}__FOR_OPTION_HOLDER"
145 module_optionholder_spec
="#define CVC4_OPTIONS__${module_id}__FOR_OPTION_HOLDER"
147 previous_remaining_documentation
="${remaining_documentation}"
148 remaining_documentation
="${remaining_documentation}\\n\\n\"
149 #line $lineno \"$kf\"
150 \"From the $module_name module:"
151 remaining_documentation_at_start_of_module
="${remaining_documentation}"
153 previous_remaining_manpage_documentation
="${remaining_manpage_documentation}"
154 remaining_manpage_documentation
="${remaining_manpage_documentation}
155 .SH `echo "$module_name" | tr a-z A-Z` OPTIONS
157 remaining_manpage_documentation_at_start_of_module
="${remaining_manpage_documentation}"
159 previous_remaining_manpage_smt_documentation
="${remaining_manpage_smt_documentation}"
160 remaining_manpage_smt_documentation
="${remaining_manpage_smt_documentation}
162 .I \"`echo "$module_name" | tr a-z A-Z` OPTIONS\"
164 remaining_manpage_smt_documentation_at_start_of_module
="${remaining_manpage_smt_documentation}"
166 previous_remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}"
167 remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}
169 .I \"`echo "$module_name" | tr a-z A-Z` OPTIONS\"
171 remaining_manpage_internals_documentation_at_start_of_module
="${remaining_manpage_internals_documentation}"
179 if [ $# -ne 0 ]; then
180 ERR
"endmodule takes no arguments"
183 # check, and if no documented options, remove the headers
185 if [ "$remaining_documentation" = "$remaining_documentation_at_start_of_module" ]; then
186 remaining_documentation
="$previous_remaining_documentation"
189 if [ "$remaining_manpage_documentation" = "$remaining_manpage_documentation_at_start_of_module" ]; then
190 remaining_manpage_documentation
="$previous_remaining_manpage_documentation"
193 if [ "$remaining_manpage_smt_documentation" = "$remaining_manpage_smt_documentation_at_start_of_module" ]; then
194 remaining_manpage_smt_documentation
="$previous_remaining_manpage_smt_documentation"
197 if [ "$remaining_manpage_internals_documentation" = "$remaining_manpage_internals_documentation_at_start_of_module" ]; then
198 remaining_manpage_internals_documentation
="$previous_remaining_manpage_internals_documentation"
202 function common-option
{
203 # common-option option-args...
204 handle_option COMMON
"$@"
208 # option option-args...
209 handle_option STANDARD
"$@"
212 function expert-option
{
213 # expert-option option-args...
214 handle_option EXPERT
"$@"
217 function undocumented-option
{
218 # undocumented-option option-args...
219 handle_option UNDOCUMENTED
"$@"
222 function handle_option
{
228 category
="${args[0]}"
229 internal
="${args[1]}"
232 short_option_alternate
=
234 long_option_alternate
=
235 long_option_alternate_set
=
238 required_argument
=false
246 options_already_documented
=false
247 alternate_options_already_documented
=false
249 if [ "$category" = UNDOCUMENTED
]; then
254 expect_doc_alternate
=false
257 # scan ahead to see where the type is
259 while [ $
(($type_pos+1)) -lt ${#args[@]} ] && ! expr "${args[$(($type_pos+1))]}" : '\:' &>/dev
/null
; do
263 type="${args[$type_pos]}"
265 if [ "$type" = argument
]; then
267 required_argument
=true
270 if [ $type_pos -eq 2 ]; then
275 while [ $i -lt $type_pos ]; do
276 if expr "${args[$i]}" : '\--' &>/dev
/null ||
expr "${args[$i]}" : '/--' &>/dev
/null
; then
277 if [ -n "$long_option" -o -n "$long_option_alternate" ]; then
278 ERR
"malformed option line for \`$internal': unexpected \`${args[$i]}'"
280 long_option
="$(echo "${args[$i]}" | sed 's,/.*,,')"
281 if [ -n "$long_option" ]; then
282 if ! expr "$long_option" : '\--.' &>/dev
/null
; then
283 ERR
"bad long option \`$long_option': expected something like \`--foo'"
285 long_option
="$(echo "$long_option" | sed 's,^--,,')"
287 if expr "${args[$i]}" : '.*/' &>/dev
/null
; then
288 long_option_alternate
="$(echo "${args[$i]}" | sed 's,[^/]*/,,')"
289 long_option_alternate_set
=set
290 if [ -n "$long_option_alternate" ]; then
291 if ! expr "$long_option_alternate" : '\--.' &>/dev
/null
; then
292 ERR
"bad alternate long option \`$long_option_alternate': expected something like \`--foo'"
294 long_option_alternate
="$(echo "$long_option_alternate" | sed 's,^--,,')"
297 elif expr "${args[$i]}" : '\-' &>/dev
/null ||
expr "${args[$i]}" : '/-' &>/dev
/null
; then
298 if [ -n "$short_option" -o -n "$short_option_alternate" -o -n "$long_option" -o -n "$long_option_alternate" ]; then
299 ERR
"malformed option line for \`$internal': unexpected \`${args[$i]}'"
301 short_option
="$(echo "${args[$i]}" | sed 's,/.*,,')"
302 if [ -n "$short_option" ]; then
303 if ! expr "$short_option" : '\-.$' &>/dev
/null
; then
304 ERR
"bad short option \`$short_option': expected something like \`-x'"
306 short_option
="$(echo "$short_option" | sed 's,^-,,')"
308 if expr "${args[$i]}" : '.*/' &>/dev
/null
; then
309 short_option_alternate
="$(echo "${args[$i]}" | sed 's,[^/]*/,,')"
310 if expr "$short_option_alternate" : '\-' &>/dev
/null
; then
311 if ! expr "$short_option_alternate" : '\-.$' &>/dev
/null
; then
312 ERR
"bad alternate short option \`$short_option_alternate': expected something like \`-x'"
314 short_option_alternate
="$(echo "$short_option_alternate" | sed 's,^-,,')"
318 if [ -n "$smtname" -o -n "$short_option" -o -n "$short_option_alternate" -o -n "$long_option" -o -n "$long_option_alternate" ]; then
319 ERR
"malformed option line for \`$internal': unexpected \`${args[$i]}'"
321 smtname
="${args[$i]}"
327 if [ "$type" = void
-a "$internal" != - ]; then
328 ERR
"$internal cannot be void-typed; use \`-' as the name if its to be void"
329 elif [ "$type" != void
-a "$internal" = - ]; then
330 ERR
"cannot use an unnamed option if its type is not void"
333 if [ "$type" = bool
-a -n "$long_option$short_option" -a "$category" != UNDOCUMENTED
]; then
334 if [ -n "$short_option_alternate" -o -n "$long_option_alternate" ]; then
335 expect_doc_alternate
=true
338 if [ "$type" = bool
-a -n "$long_option" -a -z "$long_option_alternate" -a -z "$long_option_alternate_set" ]; then
339 long_option_alternate
="no-$(echo "$long_option" | sed 's,^--,,')"
341 if [ "$type" != bool
-a -n "$short_option_alternate" ]; then
342 ERR
"cannot use alternate short option -$short_option_alternate for \`$internal' because it's not of bool type"
343 elif [ "$type" != bool
-a -n "$long_option_alternate" ]; then
344 ERR
"cannot use alternate long option --$long_option_alternate for \`$internal' because it's not of bool type"
347 # check that normal options are accessible via SmtEngine too
348 if [ -n "$long_option$short_option$long_option_alternate$short_option_alternate" -a -z "$smtname" -a "$internal" != - ]; then
349 if [ -n "$long_option" ]; then
350 smtname
="$long_option"
352 WARN
"$internal is inaccessible via SmtEngine (no smt name for option) but can be set via command-line: $long_option $short_option $long_option_alternate $short_option_alternate"
356 # check for duplicates
357 if [ "$internal" != - ]; then
358 if echo " $all_declared_internal_options " |
grep -q " $internal "; then
359 ERR
"internal option name \`$internal' previously declared"
361 all_declared_internal_options
="$all_declared_internal_options $internal"
363 if [ -n "$long_option" ]; then
364 if echo " $all_declared_long_options " |
grep -q " $long_option "; then
365 ERR
"long option name \`--$long_option' previously declared"
367 all_declared_long_options
="$all_declared_long_options $long_option"
369 if [ -n "$long_option_alternate" ]; then
370 if echo " $all_declared_long_options " |
grep -q " $long_option_alternate "; then
371 ERR
"long option name \`--$long_option_alternate' previously declared"
373 all_declared_long_options
="$all_declared_long_options $long_option_alternate"
375 if [ -n "$short_option" ]; then
376 if echo " $all_declared_short_options " |
grep -q " $short_option "; then
377 ERR
"short option name \`-$short_option' previously declared"
379 all_declared_short_options
="$all_declared_short_options $short_option"
381 if [ -n "$short_option_alternate" ]; then
382 if echo " $all_declared_short_options " |
grep -q " $short_option_alternate "; then
383 ERR
"short option name \`-$short_option_alternate' previously declared"
385 all_declared_short_options
="$all_declared_short_options $short_option_alternate"
387 if [ -n "$smtname" ]; then
388 if echo " $all_declared_smt_options " |
grep -q " $smtname "; then
389 ERR
"SMT option name \`$smtname' previously declared"
391 all_declared_smt_options
="$all_declared_smt_options $smtname"
396 while [ $i -lt ${#args[@]} ]; do
397 attribute
="${args[$i]}"
401 default_value
="${args[$i]}"
405 if [ -n "$handlers" ]; then
406 ERR
"cannot specify more than one handler; maybe you want a :handler and a :predicate"
408 handlers
="${args[$i]}"
411 while [ $
(($i+1)) -lt ${#args[@]} ] && ! expr "${args[$(($i+1))]}" : '\:' &>/dev
/null
; do
413 predicates
="${predicates} ${args[$i]}"
417 while [ $
(($i+1)) -lt ${#args[@]} ] && ! expr "${args[$(($i+1))]}" : '\:' &>/dev
/null
; do
420 if expr "${args[$i]}" : '.*/' &>/dev
/null
; then
421 links
="${links} $(echo "${args[$i]}" | sed 's,/.*,,')"
422 links_alternate
="${links_alternate} $(echo "${args[$i]}" | sed 's,[^/]*/,,')"
424 links
="${links} ${args[$i]}"
430 while [ $
(($i+1)) -lt ${#args[@]} ] && ! expr "${args[$(($i+1))]}" : '\:' &>/dev
/null
; do
433 if [ $j -eq 3 ]; then
434 echo "$kf:$lineno: error: attribute :link-smt can only take two arguments" >&2
437 if expr "${args[$i]}" : '.*/' &>/dev
/null
; then
438 echo "$kf:$lineno: error: attribute :link-smt cannot take alternates" >&2
441 smt_links
="${smt_links} ${args[$i]}"
443 if [ $j -eq 1 ]; then
444 smt_links
="${smt_links} \"true\""
448 while [ $
(($i+1)) -lt ${#args[@]} ] && ! expr "${args[$(($i+1))]}" : '\:' &>/dev
/null
; do
450 module_includes
="${module_includes}
451 #line $lineno \"$kf\"
452 #include $(check_include "${args[$i]}")"
455 :handler-include|
:predicate-include
)
456 while [ $
(($i+1)) -lt ${#args[@]} ] && ! expr "${args[$(($i+1))]}" : '\:' &>/dev
/null
; do
458 option_handler_includes
="${option_handler_includes}
459 #line $lineno \"$kf\"
460 #include $(check_include "${args[$i]}")"
470 ERR
"error in option \`$internal': bad attribute \`$attribute'"
476 if [ "$internal" != - ]; then
477 # set up a field in the options_holder
478 module_optionholder_spec
="${module_optionholder_spec} \\
479 ${internal}__option_t::type $internal; \\
480 bool ${internal}__setByUser__;"
481 all_modules_defaults
="${all_modules_defaults:+${all_modules_defaults},}
482 #line $lineno \"$kf\"
483 $internal($default_value),
484 #line $lineno \"$kf\"
485 ${internal}__setByUser__(false)"
487 module_decls
="${module_decls}
488 #line $lineno \"$kf\"
489 extern struct CVC4_PUBLIC ${internal}__option_t { typedef $type type; type operator()() const; bool wasSetByUser() const; } $internal CVC4_PUBLIC;"
490 module_inlines
="${module_inlines}
491 #line $lineno \"$kf\"
492 inline ${internal}__option_t::type ${internal}__option_t::operator()() const { return Options::current()[*this]; }
493 #line $lineno \"$kf\"
494 inline bool ${internal}__option_t::wasSetByUser() const { return Options::current().wasSetByUser(*this); }
497 module_decls
="${module_decls}
498 #line $lineno \"$kf\"
499 extern struct CVC4_PUBLIC ${internal}__option_t { typedef $type type; type operator()() const; bool wasSetByUser() const; void set(const type& v); } $internal CVC4_PUBLIC;"
500 module_inlines
="${module_inlines}
501 #line $lineno \"$kf\"
502 inline ${internal}__option_t::type ${internal}__option_t::operator()() const { return Options::current()[*this]; }
503 #line $lineno \"$kf\"
504 inline bool ${internal}__option_t::wasSetByUser() const { return Options::current().wasSetByUser(*this); }
505 #line $lineno \"$kf\"
506 inline void ${internal}__option_t::set(const ${internal}__option_t::type& v) { Options::current().set(*this, v); }
508 module_specializations
="${module_specializations}
509 #line $lineno \"$kf\"
510 template <> void Options::set(options::${internal}__option_t, const options::${internal}__option_t::type& x);"
511 module_accessors
="${module_accessors}
512 #line $lineno \"$kf\"
513 template <> void Options::set(options::${internal}__option_t, const options::${internal}__option_t::type& x) { d_holder->$internal = x; }"
515 module_global_definitions
="${module_global_definitions}
516 #line $lineno \"$kf\"
517 struct ${internal}__option_t $internal;"
518 module_specializations
="${module_specializations}
519 #line $lineno \"$kf\"
520 template <> const options::${internal}__option_t::type& Options::operator[](options::${internal}__option_t) const;
521 #line $lineno \"$kf\"
522 template <> bool Options::wasSetByUser(options::${internal}__option_t) const;"
523 if [ "$type" = bool
]; then
524 module_specializations
="${module_specializations}
525 #line $lineno \"$kf\"
526 template <> void Options::assignBool(options::${internal}__option_t, std::string option, bool value, SmtEngine* smt);"
527 elif [ "$internal" != - ]; then
528 module_specializations
="${module_specializations}
529 #line $lineno \"$kf\"
530 template <> void Options::assign(options::${internal}__option_t, std::string option, std::string value, SmtEngine* smt);"
533 module_accessors
="${module_accessors}
534 #line $lineno \"$kf\"
535 template <> const options::${internal}__option_t::type& Options::operator[](options::${internal}__option_t) const { return d_holder->$internal; }
536 #line $lineno \"$kf\"
537 template <> bool Options::wasSetByUser(options::${internal}__option_t) const { return d_holder->${internal}__setByUser__; }"
540 if $required_argument ||
[ "$type" != bool
-a "$type" != void
]; then
542 expect_arg_long
=required_argument
545 expect_arg_long
=no_argument
549 if [ -n "$short_option" ]; then
550 all_modules_short_options
="${all_modules_short_options}$short_option$expect_arg"
552 case '$short_option':"
554 if [ -n "$short_option_alternate" ]; then
555 all_modules_short_options
="${all_modules_short_options}$short_option_alternate$expect_arg"
556 cases_alternate
="${cases_alternate}
557 case '$short_option_alternate':"
559 if [ -n "$long_option" ]; then
560 all_modules_long_options
="${all_modules_long_options}
561 { \"$(echo "$long_option" | sed 's,=.*,,')\", $expect_arg_long, NULL, $n_long },"
563 case $n_long:// --$long_option"
566 if [ -n "$long_option_alternate" ]; then
567 all_modules_long_options
="${all_modules_long_options}
568 { \"$(echo "$long_option_alternate" | sed 's,=.*,,')\", $expect_arg_long, NULL, $n_long },"
569 cases_alternate
="${cases_alternate}
570 case $n_long:// --$long_option_alternate"
576 if [ -n "$links" -a -z "$smt_links" -a -n "$smtname" ]; then
577 WARN
"$smtname has no :link-smt, but equivalent command-line has :link"
578 elif [ -n "$smt_links" -a -z "$links" ] && [ -n "$short_option" -o -n "$short_option_alternate" -o -n "$long_option" -o "$long_option_alternate" ]; then
579 WARN
"$smtname has a :link-smt, but equivalent command-line has no :link"
581 if [ -n "$links" ]; then
583 for link
in $links; do
584 run_links
="$run_links
585 #line $lineno \"$kf\"
586 preemptGetopt(extra_argc, extra_argv, \"$link\");"
589 if [ -n "$smt_links" ]; then
591 smt_links
=($smt_links)
593 while [ $i -lt ${#smt_links[@]} ]; do
594 run_smt_links
="$run_smt_links
595 #line $lineno \"$kf\"
596 smt->setOption(std::string(\"${smt_links[$i]}\"), SExpr(${smt_links[$(($i+1))]}));"
600 if [ -n "$links_alternate" ]; then
602 for link
in $links_alternate; do
603 run_links_alternate
="$run_links_alternate
604 #line $lineno \"$kf\"
605 preemptGetopt(extra_argc, extra_argv, \"$link\");"
608 if [ "$type" = bool
] && [ -n "$cases" -o -n "$cases_alternate" -o -n "$smtname" ]; then
610 if [ -n "$handlers" ]; then
611 ERR
"bool-valued options cannot have handlers"
613 if [ -n "$predicates" ]; then
614 for predicate
in $predicates; do
615 run_handlers
="$run_handlers
616 #line $lineno \"$kf\"
617 $predicate(option, b, smt);"
620 if [ -n "$run_handlers" ]; then
621 all_custom_handlers
="${all_custom_handlers}
622 #line $lineno \"$kf\"
623 template <> void runBoolPredicates(options::${internal}__option_t, std::string option, bool b, SmtEngine* smt) {
628 if [ -n "$cases" ]; then
629 if [ "$type" = bool
]; then
630 all_modules_option_handlers
="${all_modules_option_handlers}${cases}
631 #line $lineno \"$kf\"
632 assignBool(options::$internal, option, true, NULL);$run_links
635 elif [ -n "$expect_arg" -a "$internal" != - ]; then
637 if [ -n "$handlers" ]; then
638 for handler
in $handlers; do
639 run_handlers
="$run_handlers
640 #line $lineno \"$kf\"
641 $handler(option, optionarg, smt);"
645 #line $lineno \"$kf\"
646 handleOption<$type>(option, optionarg);"
648 if [ -n "$predicates" ]; then
649 for predicate
in $predicates; do
650 run_handlers
="$run_handlers
651 #line $lineno \"$kf\"
652 $predicate(option, retval, smt);"
655 all_custom_handlers
="${all_custom_handlers}
656 #line $lineno \"$kf\"
657 template <> options::${internal}__option_t::type runHandlerAndPredicates(options::${internal}__option_t, std::string option, std::string optionarg, SmtEngine* smt) {
658 #line $lineno \"$kf\"
659 options::${internal}__option_t::type retval = $run_handlers
660 #line $lineno \"$kf\"
663 all_modules_option_handlers
="${all_modules_option_handlers}${cases}
664 #line $lineno \"$kf\"
665 assign(options::$internal, option, optionarg, NULL);$run_links
668 elif [ -n "$expect_arg" ]; then
670 if [ -n "$predicates" ]; then
671 ERR
"void-valued options cannot have predicates"
673 if [ -n "$handlers" ]; then
674 for handler
in $handlers; do
675 run_handlers
="$run_handlers
676 #line $lineno \"$kf\"
677 $handler(option, optionarg, smt);"
680 all_modules_option_handlers
="${all_modules_option_handlers}${cases}
681 #line $lineno \"$kf\"
682 $run_handlers$run_links
687 if [ -n "$predicates" ]; then
688 ERR
"void-valued options cannot have predicates"
690 if [ -n "$handlers" ]; then
691 for handler
in $handlers; do
692 run_handlers
="$run_handlers
693 #line $lineno \"$kf\"
694 $handler(option, smt);"
697 all_modules_option_handlers
="${all_modules_option_handlers}${cases}
698 #line $lineno \"$kf\"
699 $run_handlers$run_links
704 if [ -n "$cases_alternate" ]; then
705 if [ "$type" = bool
]; then
706 all_modules_option_handlers
="${all_modules_option_handlers}${cases_alternate}
707 #line $lineno \"$kf\"
708 assignBool(options::$internal, option, false, NULL);$run_links_alternate
712 ERR
"internal error: expected BOOL-typed option in alternate handler"
716 if [ -n "$smtname" ]; then
717 all_modules_smt_options
="${all_modules_smt_options:+$all_modules_smt_options,}
718 #line $lineno \"$kf\"
720 if [ "$internal" != - ]; then
723 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
724 #line $lineno \"$kf\"
725 }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(SExpr::Keyword(d_holder->$internal ? \"true\" : \"false\")); opts.push_back(v); }"
726 smt_getoption_handlers
="${smt_getoption_handlers}
727 #line $lineno \"$kf\"
728 if(key == \"$smtname\") {
729 #line $lineno \"$kf\"
730 return SExprKeyword(options::$internal() ? \"true\" : \"false\");
732 int|unsigned|int
*_t|uint
*_t|unsigned\ long|long|CVC4
::Integer
)
733 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
734 #line $lineno \"$kf\"
735 }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(d_holder->$internal); opts.push_back(v); }"
736 smt_getoption_handlers
="${smt_getoption_handlers}
737 #line $lineno \"$kf\"
738 if(key == \"$smtname\") {
739 #line $lineno \"$kf\"
740 return SExpr(Integer(options::$internal()));
743 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
744 #line $lineno \"$kf\"
745 }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(Rational::fromDouble(d_holder->$internal)); opts.push_back(v); }"
746 smt_getoption_handlers
="${smt_getoption_handlers}
747 #line $lineno \"$kf\"
748 if(key == \"$smtname\") {
749 #line $lineno \"$kf\"
750 stringstream ss; ss << std::fixed << options::$internal();
751 return SExpr(Rational::fromDecimal(ss.str()));
754 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
755 #line $lineno \"$kf\"
756 }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(d_holder->$internal); opts.push_back(v); }"
757 smt_getoption_handlers
="${smt_getoption_handlers}
758 #line $lineno \"$kf\"
759 if(key == \"$smtname\") {
760 #line $lineno \"$kf\"
761 return SExpr(options::$internal());
764 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
765 #line $lineno \"$kf\"
766 }{ std::stringstream ss; ss << d_holder->$internal; std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(ss.str()); opts.push_back(v); }"
767 smt_getoption_handlers
="${smt_getoption_handlers}
768 #line $lineno \"$kf\"
769 if(key == \"$smtname\") {
770 #line $lineno \"$kf\"
771 stringstream ss; ss << options::$internal();
772 return SExpr(ss.str());
777 if [ "$type" = bool
]; then
778 smt_setoption_handlers
="${smt_setoption_handlers}
779 #line $lineno \"$kf\"
780 if(key == \"$smtname\") {
781 #line $lineno \"$kf\"
782 Options::current().assignBool(options::$internal, \"$smtname\", optionarg == \"true\", smt);$run_smt_links
785 elif [ -n "$expect_arg" -a "$internal" != - ]; then
787 if [ -n "$handlers" ]; then
788 for handler
in $handlers; do
789 run_handlers
="$run_handlers
790 #line $lineno \"$kf\"
791 $handler(\"$smtname\", optionarg, smt);
795 smt_setoption_handlers
="${smt_setoption_handlers}
796 #line $lineno \"$kf\"
797 if(key == \"$smtname\") {
798 #line $lineno \"$kf\"
799 Options::current().assign(options::$internal, \"$smtname\", optionarg, smt);$run_smt_links
802 elif [ -n "$expect_arg" ]; then
804 for handler
in $handlers; do
805 run_handlers
="$run_handlers
806 #line $lineno \"$kf\"
807 $handler(\"$smtname\", optionarg, smt);
810 smt_setoption_handlers
="${smt_setoption_handlers}
811 #line $lineno \"$kf\"
812 if(key == \"$smtname\") {
813 #line $lineno \"$kf\"
814 $run_handlers$run_smt_links
819 for handler
in $handlers; do
820 run_handlers
="$run_handlers
821 #line $lineno \"$kf\"
822 $handler(\"$smtname\", smt);
825 smt_setoption_handlers
="${smt_setoption_handlers}
826 #line $lineno \"$kf\"
827 if(key == \"$smtname\") {
828 #line $lineno \"$kf\"
829 $run_handlers$run_smt_links
833 elif [ -n "$long_option" -o "$long_option_alternate" ] && [ "$internal" != - ]; then
836 getoption_name
="$long_option"
838 # case where we have a --disable but no corresponding --enable
839 if [ -z "$getoption_name" ]; then
840 getoption_name
="$long_option_alternate"
843 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
844 #line $lineno \"$kf\"
845 }{ std::vector<SExpr> v; v.push_back(\"$getoption_name\"); v.push_back(SExpr::Keyword((${inv}d_holder->$internal) ? \"true\" : \"false\")); opts.push_back(v); }";;
846 int|unsigned|int
*_t|uint
*_t|unsigned\ long|long|CVC4
::Integer
)
847 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
848 #line $lineno \"$kf\"
849 }{ std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(d_holder->$internal); opts.push_back(v); }";;
851 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
852 #line $lineno \"$kf\"
853 }{ std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(Rational::fromDouble(d_holder->$internal)); opts.push_back(v); }";;
855 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
856 #line $lineno \"$kf\"
857 }{ std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(d_holder->$internal); opts.push_back(v); }";;
859 all_modules_get_options
="${all_modules_get_options:+$all_modules_get_options
860 #line $lineno \"$kf\"
861 }{ std::stringstream ss; ss << d_holder->$internal; std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(ss.str()); opts.push_back(v); }";;
865 if [ "$type" = bool
]; then
866 # emit assignBool/assign
867 all_custom_handlers
="${all_custom_handlers}
868 #line $lineno \"$kf\"
869 template <> void Options::assignBool(options::${internal}__option_t, std::string option, bool value, SmtEngine* smt) {
870 #line $lineno \"$kf\"
871 runBoolPredicates(options::$internal, option, value, smt);
872 #line $lineno \"$kf\"
873 d_holder->$internal = value;
874 #line $lineno \"$kf\"
875 d_holder->${internal}__setByUser__ = true;
876 #line $lineno \"$kf\"
877 Trace(\"options\") << \"user assigned option $internal\" << std::endl;
879 elif [ -n "$expect_arg" -a "$internal" != - ] && [ -n "$cases" -o -n "$cases_alternate" -o -n "$smtname" ]; then
880 all_custom_handlers
="${all_custom_handlers}
881 #line $lineno \"$kf\"
882 template <> void Options::assign(options::${internal}__option_t, std::string option, std::string value, SmtEngine* smt) {
883 #line $lineno \"$kf\"
884 d_holder->$internal = runHandlerAndPredicates(options::$internal, option, value, smt);
885 #line $lineno \"$kf\"
886 d_holder->${internal}__setByUser__ = true;
887 #line $lineno \"$kf\"
888 Trace(\"options\") << \"user assigned option $internal\" << std::endl;
893 function common-alias
{
894 # common-alias -option[=arg] = (-option[=arg])+
895 handle_alias COMMON
"$@"
899 # alias -option[=arg] = (-option[=arg])+
900 handle_alias STANDARD
"$@"
903 function expert-alias
{
904 # expert-alias -option[=arg] = (-option[=arg])+
905 handle_alias EXPERT
"$@"
908 function undocumented-alias
{
909 # undocumented-alias -option[=arg] = (-option[=arg])+
910 handle_alias UNDOCUMENTED
"$@"
913 function handle_alias
{
914 # handle_alias CATEGORY -option[=arg] = (-option[=arg])+
924 short_option_alternate
=
926 long_option_alternate
=
927 long_option_alternate_set
=
930 required_argument
=false
937 options_already_documented
=false
938 alternate_options_already_documented
=false
940 if [ "$category" = UNDOCUMENTED
]; then
945 expect_doc_alternate
=false
947 if [ $# -lt 3 ]; then
948 ERR
"malformed \"alias\" command; expected more arguments"
950 if [ "$1" = '=' ]; then
951 ERR
"malformed \"alias\" command; expected option name"
955 if [ "$1" != '=' ]; then
956 ERR
"malformed \"alias\" command; expected \`='"
959 if [ $# -eq 0 ]; then
960 ERR
"malformed \"alias\" command; expected more arguments"
963 if ! expr "$option" : '\-' &>/dev
/null
; then
964 ERR
"alias for SMT options not yet supported"
966 if expr "$option" : '\--' &>/dev
/null
; then
967 if expr "$option" : '.*=' &>/dev
/null
; then
968 expect_arg_long
=required_argument
969 arg
="$(echo "$option" | sed 's,[^=]*=\(.*\),\1,')"
970 option
="$(echo "$option" | sed 's,--,,;s,=.*,,')"
972 expect_arg_long
=no_argument
974 option
="$(echo "$option" | sed 's,--,,')"
976 all_modules_long_options
="${all_modules_long_options}
977 { \"$(echo "$option" | sed 's,=.*,,')\", $expect_arg_long, NULL, $n_long },"
979 case $n_long:// --$option"
981 long_option
="${long_option:+$long_option | --}$option"
983 if ! expr "$option" : '\-.$' &>/dev
/null
; then
984 if ! expr "$option" : '\-.=' &>/dev
/null
; then
985 ERR
"expected short option specification, got \`$option'"
988 arg
="$(echo "$option" | sed 's,[^=]*=,,')"
989 option
="$(echo "$option" | sed 's,-\(.\)=.*,\1,')"
993 option
="$(echo "$option" | sed 's,-,,')"
995 all_modules_short_options
="${all_modules_short_options}$option$expect_arg"
998 short_option
="${short_option:+$short_option | -}$option"
1001 while [ $# -gt 0 ]; do
1003 # on the RHS, we're looking for =ARG, where "ARG" is *exactly* what
1004 # was given on the LHS
1005 if expr "$linkopt" : '.*=' &>/dev
/null
; then
1006 linkarg
="$(echo "$linkopt" | sed 's,[^=]*=,,')"
1007 if [ "$linkarg" = "$arg" ]; then
1009 linkopt
="$(echo "$linkopt" | sed 's,=.*,,')"
1011 # false positive: =SOMETHING, where SOMETHING != ARG
1018 #line $lineno \"$kf\"
1019 preemptGetopt(extra_argc, extra_argv, \"$linkopt\");"
1020 if [ "$linkarg" ]; then
1021 # include also the arg
1023 #line $lineno \"$kf\"
1024 preemptGetopt(extra_argc, extra_argv, optionarg.c_str());"
1028 all_modules_option_handlers
="$all_modules_option_handlers$cases$links
1047 if [ -z "$short_option" -a -z "$long_option" ]; then
1048 if [ -n "$short_option_alternate" -o -n "$long_option_alternate" ]; then
1049 if [ -n "$smtname" ]; then
1050 expect_doc_alternate
=true
1052 if [ "$internal" != - ]; then
1053 if ! $alternate_options_already_documented; then
1054 if [ "$short_option_alternate" ]; then
1055 if [ "$long_option_alternate" ]; then
1056 altopt
="s -$short_option_alternate and --$long_option_alternate, each of"
1058 altopt
=" -$short_option_alternate,"
1061 altopt
=" --$long_option_alternate,"
1063 if [ -z "$default_value" ]; then
1064 typedefault
="($type)"
1066 typedefault
="($type, default = $default_value)"
1069 if [ "$category" = EXPERT
]; then
1070 mansmtdoc
="$mansmtdoc (EXPERTS only)"
1072 altmanopt
="`echo "$altopt" | sed 's,-,\\\\\\-,g'`"
1073 mansmtdoc
="`echo "$mansmtdoc" | sed 's,-,\\\\\\-,g'`"
1074 typedefault
="`echo "$typedefault" | sed 's,-,\\\\\\-,g'`"
1075 if [ "$category" = COMMON
]; then
1076 common_manpage_internals_documentation
="${common_manpage_internals_documentation}
1081 .B \"This internal Boolean flag is undocumented; however, its alternate option$altmanopt which reverses the sense of the option, is documented thusly:\"
1084 remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}
1089 .B \"This internal Boolean flag is undocumented; however, its alternate option$altmanopt which reverses the sense of the option, is documented thusly:\"
1093 if [ "$category" = COMMON
]; then
1094 common_manpage_internals_documentation
="${common_manpage_internals_documentation}
1097 remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}
1109 if [ "$long_option" ]; then
1110 the_opt
="--$long_option"
1111 if [ "$short_option" ]; then
1113 if expr "$the_opt" : '.*=' &>/dev
/null
; then
1114 shortoptarg
="$(echo "$the_opt" | sed 's,[^=]*=, ,')"
1116 the_opt
="$the_opt | -$short_option$shortoptarg"
1118 elif [ "$short_option" ]; then
1119 the_opt
="-$short_option"
1122 if ! $options_already_documented; then
1123 options_already_documented
=true
1128 if [ "$category" = EXPERT
]; then
1129 the_doc
="$the_doc (EXPERTS only)"
1130 mandoc
="$mandoc (EXPERTS only)"
1131 mansmtdoc
="$mansmtdoc (EXPERTS only)"
1134 if [ "$type" = bool
-a -n "$long_option" -a "$long_option_alternate" = "no-$long_option" ]; then
1135 the_doc
="$the_doc [*]"
1136 mandoc
="$mandoc [*]"
1139 # in man, minus sign is \-, different from hyphen
1140 the_manopt
="`echo "$the_opt" | sed 's,-,\\\\\\-,g'`"
1141 mandoc
="`echo "$mandoc" | sed 's,-,\\\\\\-,g'`"
1142 mansmtdoc
="`echo "$mansmtdoc" | sed 's,-,\\\\\\-,g'`"
1144 if [ "$the_opt" ]; then
1146 while [ -n "$the_doc" ]; do
1147 remaining_doc
="$(expr "$the_doc " : '.\{1,53\} \(.*\)')"
1148 the_doc
="$(expr "$the_doc " : '\(.\{1,53\}\) ')"
1149 if [ -z "$doc_line" ]; then
1150 if expr "$the_opt" : '.\{23\}' &>/dev
/null
; then
1151 # break into two lines
1152 doc_line
="$(printf ' %s\\n\\\n%-24s %s' "$the_opt" "" "$the_doc")"
1154 doc_line
="$(printf ' %-22s %s' "$the_opt" "$the_doc")"
1157 doc_line
="$doc_line\\n$(printf '%-24s %s' "" "$the_doc")"
1159 the_doc
="$(expr "$remaining_doc" : '\(.*\) ')"
1162 if [ "$category" = COMMON
]; then
1163 common_documentation
="${common_documentation}\\n\"
1164 #line $lineno \"$kf\"
1165 \"$(echo "$doc_line" | sed 's,'\'',\\'\'',g;s,",\\",g')"
1166 common_manpage_documentation
="${common_manpage_documentation}
1169 elif [ "$category" != UNDOCUMENTED
]; then
1170 remaining_documentation
="${remaining_documentation}\\n\"
1171 #line $lineno \"$kf\"
1172 \"$(echo "$doc_line" | sed 's,'\'',\\'\'',g;s,",\\",g')"
1173 remaining_manpage_documentation
="${remaining_manpage_documentation}
1179 if [ "$smtname" -a "$category" != UNDOCUMENTED
]; then
1180 if [ "$category" = COMMON
]; then
1181 common_manpage_smt_documentation
="${common_manpage_smt_documentation}
1186 remaining_manpage_smt_documentation
="${remaining_manpage_smt_documentation}
1192 if [ "$internal" != - ]; then
1193 if [ -z "$default_value" ]; then
1194 typedefault
="($type)"
1196 typedefault
="($type, default = $default_value)"
1198 typedefault
="`echo "$typedefault" | sed 's,-,\\\\\\-,g'`"
1199 if [ "$category" = COMMON
]; then
1200 common_manpage_internals_documentation
="${common_manpage_internals_documentation}
1207 remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}
1216 if [ "$the_opt" -a "$category" != UNDOCUMENTED
]; then
1217 if [ "$category" = COMMON
]; then
1218 common_manpage_documentation
="${common_manpage_documentation}
1221 remaining_manpage_documentation
="${remaining_manpage_documentation}
1226 if [ "$smtname" -a "$category" != UNDOCUMENTED
]; then
1227 if [ "$category" = COMMON
]; then
1228 common_manpage_smt_documentation
="${common_manpage_smt_documentation}
1231 remaining_manpage_smt_documentation
="${remaining_manpage_smt_documentation}
1236 if [ "$internal" != - ]; then
1237 if [ "$category" = COMMON
]; then
1238 common_manpage_internals_documentation
="${common_manpage_internals_documentation}
1241 remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}
1248 function doc-alternate
{
1249 # doc-alternate text...
1251 expect_doc_alternate
=false
1253 if $expect_doc; then
1254 ERR
"must provide documentation before alternate documentation"
1257 if [ -z "$short_option_alternate" -a -z "$long_option_alternate" ]; then
1258 ERR
"cannot document an alternative for option \`$internal'; one does not exist"
1261 if [ "$category" = UNDOCUMENTED
]; then
1265 if ! $alternate_options_already_documented; then
1266 alternate_options_already_documented
=true
1268 if [ "$long_option_alternate" ]; then
1269 the_opt
="--$long_option_alternate"
1271 if expr "$the_opt" : '.*=' &>/dev
/null
; then
1272 shortoptarg
="$(echo "$the_opt" | sed 's,[^=]*=, ,')"
1274 if [ "$short_option_alternate" ]; then
1275 the_opt
="$the_opt | -$short_option_alternate$shortoptarg"
1277 elif [ "$short_option_alternate" ]; then
1278 the_opt
="-$short_option_alternate"
1280 if [ -z "$the_opt" ]; then
1281 # nothing to document
1286 if [ "$category" = EXPERT
]; then
1287 the_doc
="$the_doc (EXPERTS only)"
1291 while [ -n "$the_doc" ]; do
1292 remaining_doc
="$(expr "$the_doc " : '.\{1,53\} \(.*\)')"
1293 the_doc
="$(expr "$the_doc " : '\(.\{1,53\}\) ')"
1294 if [ -z "$doc_line" ]; then
1295 if expr "$the_opt" : '.\{23\}' &>/dev
/null
; then
1296 # break into two lines
1297 doc_line
="$(printf ' %s\\n\\\n%-24s %s' "$the_opt" "" "$the_doc")"
1299 doc_line
="$(printf ' %-22s %s' "$the_opt" "$the_doc")"
1302 doc_line
="$doc_line\\n$(printf '%-24s %s' "" "$the_doc")"
1304 the_doc
="$(expr "$remaining_doc" : '\(.*\) ')"
1307 # in man, minus sign is \-, different from hyphen
1308 the_manopt
="`echo "$the_opt" | sed 's,-,\\\\\\-,g'`"
1310 if [ "$category" = COMMON
]; then
1311 common_documentation
="${common_documentation}\\n\"
1312 #line $lineno \"$kf\"
1313 \"$(echo "$doc_line" | sed 's,'\'',\\'\'',g;s,",\\",g')"
1314 common_manpage_documentation
="${common_manpage_documentation}
1318 remaining_documentation
="${remaining_documentation}\\n\"
1319 #line $lineno \"$kf\"
1320 \"$(echo "$doc_line" | sed 's,'\'',\\'\'',g;s,",\\",g')"
1321 remaining_manpage_documentation
="${remaining_manpage_documentation}
1326 if [ "$category" = COMMON
]; then
1327 common_manpage_documentation
="${common_manpage_documentation}
1330 remaining_manpage_documentation
="${remaining_manpage_documentation}
1336 function check_doc
{
1337 if $expect_doc; then
1338 if [ "$internal" != - ]; then
1339 WARN
"$internal is lacking documentation"
1340 elif [ -n "$long_option" ]; then
1341 WARN
"option --$long_option is lacking documentation"
1342 elif [ -n "$short_option" ]; then
1343 WARN
"option -$short_option is lacking documentation"
1344 elif [ -n "$smtname" ]; then
1345 WARN
"SMT option $smtname is lacking documentation"
1348 elif ! $seen_doc; then
1349 if [ -n "$internal" -a "$internal" != - ]; then
1350 if [ -z "$default_value" ]; then
1351 typedefault
="($type)"
1353 typedefault
="($type, default = $default_value)"
1355 if [ "$category" = COMMON
]; then
1356 common_manpage_internals_documentation
="${common_manpage_internals_documentation}
1363 remaining_manpage_internals_documentation
="${remaining_manpage_internals_documentation}
1373 if $expect_doc_alternate; then
1374 WARN
"$internal is lacking documentation for the alternative option(s): $short_option_alternate $long_option_alternate"
1375 expect_doc_alternate
=false
1379 function check_module_seen
{
1380 if $seen_endmodule; then
1381 ERR
"command after \"endmodule\" declaration (endmodule has to be last)"
1383 if ! $seen_module; then
1384 ERR
"no \"module\" declaration found (it has to be first)"
1388 function check_include
{
1389 if ! expr "$1" : '".*"$' &>/dev
/null
&& ! expr "$1" : '<.*>$' &>/dev
/null
; then
1396 function output_module
{
1400 filename
="$(basename "$output")"
1402 #echo "generating module $output from $template"
1404 # generate warnings about incorrect #line annotations in templates
1405 nl -ba -s' ' "$template" |
grep '^ *[0-9][0-9]* # *line' |
1406 awk '{OFS="";if($1+1!=$3) print "'"$template"':",$1,": warning: incorrect annotation \"#line ",$3,"\" (it should be \"#line ",($1+1),"\")"}' >&2
1408 mkdir
-p "`dirname "$output"`"
1409 cp "$template" "$output.working"
1410 echo -n > "$output.sed"
1415 module_optionholder_spec \
1417 module_specializations \
1420 module_global_definitions \
1423 progress
"$output" $count $total
1424 repl
="$(eval "echo \"\
${$var}\"" | sed 's,\\,\\\\,g;s/,/\\,/g;s,&,\\\&,g;$!s,$,\\,g')"
1425 # a little nasty; for multi-line replacements, bash can eat a final
1426 # (blank) newline, and so we get a final \ on the final line, leading
1427 # to malformed replacements in the sed script
1428 repl2
="$(echo "$repl" | sed '$s,\\*$,,')"
1429 while [ "$repl" != "$repl2" ]; do
1431 repl2
="$(echo "$repl" | sed '$s,\\*$,,')"
1434 echo -n ";s,$(eval echo "\$\
{$var\
}"),$repl,g" >>"$output.sed"
1436 sed -f "$output.sed" "$output.working" >"$output.working2"
1437 mv -f "$output.working2" "$output.working"
1438 error
="$(grep '.*\${[^}]*}.*' "$output.working
" | head -n 1)"
1439 if [ -n "$error" ]; then
1440 error
="$(echo "$error" | sed 's,.*\${\([^}]*\)}.*,\1,')"
1441 rm -f "$output.working"
1445 ERR
"undefined replacement \${$error}"
1450 # Output header (if this is a .cpp or .c or .h file) and then the
1453 if expr "$output" : '.*\.cpp$' &>/dev
/null ||
expr "$output" : '.*\.[ch]$' &>/dev
/null
; then
1456 /********************* */
1459 ** Copyright $copyright New York University and The University of Iowa,
1462 ** This file automatically generated by:
1466 ** for the CVC4 project.
1469 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1470 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1471 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1472 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1473 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1474 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1476 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1477 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1478 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1479 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1480 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1481 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1483 /* Edit the template file instead. */
1488 cat "$output.working"
1492 rm -f "$output.working"
1494 if diff -q "$output" "$output.tmp" &>/dev
/null
; then
1497 mv -f "$output.tmp" "$output"
1498 printf "${r}regenerated %-68s\n" "$output"
1502 total
=$
(($#/2+23*${#templates[@]}))
1504 while [ $# -gt 0 ]; do
1506 if [ $# -eq 0 ]; then
1507 echo "$me: error: mismatched number of templates and output files (after -t)" >&2
1513 #echo "scanning $kf"
1515 progress
"$kf" $count $total
1518 seen_endmodule
=false
1519 b
=$
(basename $
(dirname "$kf"))
1521 # IFS= forces read to read an entire line
1522 while IFS
= read -r line
; do
1524 # read any continuations of the line
1525 while expr "$line" : '.*\\$' &>/dev
/null
; do
1527 line
="$(echo "$line" | sed 's,\\$,,')$line2"
1530 if expr "$line" : '[ ].*' &>/dev
/null
; then
1531 doc
"$(echo "$line" | sed 's,^[ ],,')"
1532 elif expr "$line" : '\.[ ]*$' &>/dev
/null
; then
1534 elif expr "$line" : '\.' &>/dev
/null
; then
1535 ERR
"malformed line during processing of option \`$internal': continuation lines should not have content"
1536 elif expr "$line" : '/.*' &>/dev
/null
; then
1537 doc-alternate
"$(echo "$line" | sed 's,^/,,')"
1539 line
="$(echo "$line" | sed 's,\([<>&()!?*]\),\\\1,g')"
1540 progress
"$kf" $count $total
1541 if ! eval "$line"; then
1542 ERR
"error was due to evaluation of this line"
1546 if ! $seen_module; then
1547 ERR
"no module content found in file!"
1549 if ! $seen_endmodule; then
1550 ERR
"no \"endmodule\" declaration found (it is required at the end)"
1553 output_module
"$options_h_template" "$outdir/$(basename "$kf").h"
1554 output_module
"$options_cpp_template" "$outdir/$(basename "$kf").cpp"
1560 i
=0; while [ $i -lt ${#templates[@]} ]; do
1562 template
="${templates[$i]}"
1563 output
="${outputs[$i]}"
1565 progress
"$output" $count $total
1569 filename
="$(basename "$output")"
1571 #echo "generating $output from $template"
1573 # generate warnings about incorrect #line annotations in templates
1574 nl -ba -s' ' "$template" |
grep '^ *[0-9][0-9]* # *line' |
1575 awk '{OFS="";if($1+1!=$3) print "'"$template"':",$1,": warning: incorrect annotation \"#line ",$3,"\" (it should be \"#line ",($1+1),"\")"}' >&2
1577 long_option_value_end
=$n_long
1579 cp "$template" "$output.working"
1580 echo -n > "$output.sed"
1582 smt_getoption_handlers \
1583 smt_setoption_handlers \
1584 long_option_value_begin \
1585 long_option_value_end \
1587 option_handler_includes \
1588 all_modules_defaults \
1589 all_modules_short_options \
1590 all_modules_long_options \
1591 all_modules_smt_options \
1592 all_modules_option_handlers \
1593 all_modules_get_options \
1594 include_all_option_headers \
1595 all_modules_contributions \
1596 all_custom_handlers \
1597 common_documentation \
1598 remaining_documentation \
1599 common_manpage_documentation \
1600 remaining_manpage_documentation \
1601 common_manpage_smt_documentation \
1602 remaining_manpage_smt_documentation \
1603 common_manpage_internals_documentation \
1604 remaining_manpage_internals_documentation \
1607 progress
"$output" $count $total
1608 repl
="$(eval "echo \"\
${$var}\"" | sed 's,\\,\\\\,g;s/,/\\,/g;s,&,\\\&,g;$!s,$,\\,g')"
1609 # a little nasty; for multi-line replacements, bash can eat a final
1610 # (blank) newline, and so we get a final \ on the final line, leading
1611 # to malformed replacements in the sed script
1612 repl2
="$(echo "$repl" | sed '$s,\\*$,,')"
1613 while [ "$repl" != "$repl2" ]; do
1615 repl2
="$(echo "$repl" | sed '$s,\\*$,,')"
1618 echo -n ";s,$(eval echo "\$\
{$var\
}"),$repl,g" >>"$output.sed"
1620 sed -f "$output.sed" "$output.working" >"$output.working2"
1621 mv -f "$output.working2" "$output.working"
1622 error
="$(grep '.*\${[^}]*}.*' "$output.working
" | head -n 1)"
1623 if [ -n "$error" ]; then
1624 error
="$(echo "$error" | sed 's,.*\${\([^}]*\)}.*,\1,')"
1625 echo "$template:0: error: undefined replacement \${$error}" >&2
1626 rm -f "$output.working"
1631 progress
"$output" $count $total
1635 # Output header (if this is a .cpp or .c or .h file) and then the
1638 if expr "$output" : '.*\.cpp$' &>/dev
/null ||
expr "$output" : '.*\.[ch]$' &>/dev
/null
; then
1641 /********************* */
1644 ** Copyright $copyright New York University and The University of Iowa,
1647 ** This file automatically generated by:
1651 ** for the CVC4 project.
1654 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1655 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1656 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1657 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1658 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1659 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1661 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1662 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1663 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1664 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1665 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1666 /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT ! */
1668 /* Edit the template file instead: */
1674 cat "$output.working"
1678 rm -f "$output.working"
1680 if diff -q "$output" "$output.tmp" &>/dev
/null
; then
1683 mv -f "$output.tmp" "$output"
1684 printf "${r}regenerated %-68s\n" "$output"
1691 if ! $regenerated; then
1692 [ -t 1 ] && printf "$r%-80s$r" ""