%%
%% This is file `cooking-units.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cooking-units.dtx  (with options: `package')
%% Copyright (C) 2016--2022 by Ben Vitecek (current Maintainer)
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%% 
%%         https://www.latex-project.org/lppl/
%% 
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2008-05-04 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% This work consists of the files README.md, cooking-units.dtx and cooking-units.ins
%% and the derived file cooking-units.sty.
%% 
\@ifpackageloaded {xparse}
  { }
  { \RequirePackage {xparse} }
\@ifpackageloaded {expl3}
  { }
  { \RequirePackage {expl3} }
\ProvidesExplPackage
  {cooking-units}
  {2022/06/06}
  {2.01}
  {Ein Paket fuer Kocheinheiten}
\@ifpackagelater { expl3 } { 2022/02/24 }
  { }
  {
    \PackageError { cooking-units } { Support~package~expl3~too~old }
      {
        You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
        'l3packages'.\MessageBreak
        Loading~cooking-units~will~abort!
      }
    \tex_endinput:D
  }
\@ifpackageloaded { translations } { } { \RequirePackage { translations } }
\@ifpackageloaded { xfrac } { } { \RequirePackage { xfrac } }
\@ifpackageloaded { l3keys2e } { } { \RequirePackage { l3keys2e } }
\@ifpackagelater { translations } { 2022/02/05 }
  { }
  {
    \PackageError { cooking-units } { Support~package~translations~too~old }
      {
        You~need~to~update~your~installation~of~the~package~'translations'.\MessageBreak
        Loading~cooking-units~will~abort!
      }
    \tex_endinput:D
  }
\msg_new:nnnn { cooking-units } { Option-deprecated }
  {
   The \ option \ '#1' \ is \ deprecated \ and \ should \ be \
   replaced \ by \ '#2'.
  }{
    Please \ replace \ the \ option.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { key-unknown }
  { The~key~'#1'~is~unknown~and~is~being~ignored. }
  {
    The~module~'#2'~does~not~have~a~key~called~'#1'.\\
    Check~that~you~have~spelled~the~key~name~correctly.
  }
\bool_new:N \g__cookingunits_opt_numeral_bool
\keys_define:nn { cooking-units }
  {
    use-numerals .code:n =
      {
        \msg_warning:nnnn { cooking-units } { Option-deprecated } { use-numerals } { use-fmtcount-numerals }
        \keys_set:nn { cooking-units } { use-fmtcount-numerals = #1 }
      } ,
    use-numerals .default:n = { false },
    use-fmtcount-numerals .bool_gset:N = \g__cookingunits_opt_numeral_bool ,
    use-fmtcount-numerals .default:n = { false },
    unknown .code:n = { \msg_error:nnxx { cooking-units } { key-unknown }
      { \l_keys_path_str } { cooking-units }
     }
  }
\ProcessKeysOptions { cooking-units }
\bool_if:NT \g__cookingunits_opt_numeral_bool
  {
    \@ifpackageloaded { fmtcount } { } { \RequirePackage { fmtcount } }
  }
\keys_define:nn { cooking-units }
  {
    use-numerals .code:n =
      {
        \msg_warning:nnnn { cooking-units } { Option-deprecated } { use-numerals } { use-fmtcount-numerals }
        \msg_error:nnn { cooking-units } { load-time-option } { use-fmtcount-numerals }
      } ,
    use-fmtcount-numerals .code:n = { \msg_error:nnn { cooking-units } { load-time-option } { use-fmtcount-numerals } } ,
  }
\cs_generate_variant:Nn \msg_redirect_name:nnn { nnV }
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn }
\cs_generate_variant:Nn \tl_if_in:nnTF { nV }
\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF  }
\cs_generate_variant:Nn \tl_if_in:NnT { NVT }
\cs_generate_variant:Nn \fp_compare:nNnT { vNnT }
\cs_generate_variant:Nn \prop_get:NnN { cVc, Nnc }
\cs_generate_variant:Nn \prop_get:NnNF {  Nnc }
\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV }
\cs_generate_variant:Nn \msg_error:nnnn { nnnV }
\cs_generate_variant:Nn \msg_error:nnn { nnV }
\cs_generate_variant:Nn \msg_warning:nnn { nnV }
\cs_generate_variant:Nn \prop_put:Nnn { cnx }
\cs_generate_variant:Nn \seq_remove_all:Nn { NV }
\cs_generate_variant:Nn \prop_gput:Nnn { Nnv, Nxv }
\cs_generate_variant:Nn \prop_get:NnN { cnc }
\cs_generate_variant:Nn \prg_new_conditional:Npnn { c }
\cs_generate_variant:Nn \text_uppercase:n { x }
\cs_new_eq:NN \__cookingunits_frac:nn \sfrac
\tl_new:N \l__cookingunits_unit_argument_spec_tl
\tl_new:N \l__cookingunits_expand_amount_tl
\tl_set:Nn \l__cookingunits_unit_argument_spec_tl { n }
\tl_set:Nn \l__cookingunits_expand_amount_tl { n }
\cs_new_eq:NN \__cookingunits_set_amount:Nn \tl_set:Nn
\cs_new_eq:NN \__cookingunits_set_unit:Nn \str_set:Nn
\cs_new_eq:NN \__cookingunits_to_unit:n \tl_to_str:n
\cs_new:Npn \__cookingunits_print_numeral:n #1
  { \msg_error:nnn {cooking-units} { define-numeral-function } }
\cs_new:Npn \__cookingunits_print_Numeral:n #1
  { \msg_error:nnn {cooking-units} { define-Numeral-function } }
\bool_if:NT \g__cookingunits_opt_numeral_bool
  {
    \cs_set_eq:NN \__cookingunits_print_numeral:n \numberstringnum
    \cs_set_eq:NN \__cookingunits_print_Numeral:n \Numberstringnum
  }
\cs_generate_variant:Nn \__cookingunits_print_numeral:n { V }
\cs_generate_variant:Nn \__cookingunits_print_Numeral:n { V }
\prop_new:N \l__cookingunits_change_unit_prop
\prop_new:N \g__cookingunits_master_changer_prop
\prop_new:N \g__cookingunits_convert_to_eV_remember_prop
\prop_new:N \g__cookingunits_convert_bonkers_remember_prop
\tl_new:N \l__cookingunits_number_tmpa_tl
\tl_new:N \l__cookingunits_number_tmpb_tl
\tl_new:N \l__cookingunits_mixed_fraction_tl
\tl_new:N \l__cookingunits_original_amount_tl
\tl_new:N \l__cookingunits_original_unit_tl
\tl_new:N \l__cookingunits_option_unit_tl
\tl_new:N \l__cookingunits_language_tl
\tl_new:N \l__cookingunits_cunum_range_sign_tl
\tl_new:N \l__cookingunits_cutext_range_sign_tl
\tl_new:N \l__cookingunits_value_unit_space_tl
\tl_new:N \l__cookingunits_input_digits_tl
\tl_new:N \l__cookingunits_input_decimal_mark_tl
\tl_new:N \l__cookingunits_input_value_signs_tl
\tl_new:N \l__cookingunits_input_allowed_special_signs_tl
\tl_new:N \g__cookingunits_input_str_hash_one_tl
\tl_new:N \l__cookingunits_input_range_sign_tl
\tl_new:N \l__cookingunits_cutext_space_tl
\tl_new:N \l__cookingunits_cutext_numeral_space_tl
\tl_new:N \l__cookingunits_cuphrase_space_tl
\tl_new:N \l__cookingunits_translation_tmpa_tl
\tl_new:N \l__cookingunits_cutext_last_value_tl
\tl_new:N \l__cookingunits_phantom_tl
\tl_new:N \l__cookingunits_phrase_text_tl
\tl_new:N \l__cookingunits_unit_letter_not_allowed_tl
\tl_new:N \l__cookingunits_input_fraction_sign_tl
\tl_new:N \l__cookingunits_input_mixed_fraction_sign_tl
\tl_new:N \l__cookingunits_list_of_units_tl
\tl_new:N \l__cookingunits_list_of_values_tl
\tl_new:N \l__cookingunits_allwed_integer_math_operators_tl
\tl_new:N \l__cookingunits_curr_group_tl
\tl_new:N \l__cookingunits_curr_unit_tl
\tl_new:N \l__cookingunits_new_key_base_tl
\tl_new:N \l__cookingunits_decided_unit_tl
\tl_new:N \l__cookingunits_stored_units_tl
\tl_new:N \l__cookingunits_stored_formula_tl
\tl_new:N \l__cookingunits_base_tl
\tl_new:N \l_cookingunits_raw_amount_a_tl
\tl_new:N \l_cookingunits_raw_amount_b_tl
\tl_new:N \l__cookingunits_cmd_hook_tl
\tl_new:N \l__cookingunits_cunum_hook_tl
\tl_new:N \l__cookingunits_cutext_hook_tl
\tl_new:N \l__cookingunits_Cutext_hook_tl
\tl_new:N \l__cookingunits_cuam_hook_tl
\tl_set:Nn \l__cookingunits_input_digits_tl { 0123456789 }
\tl_set:Nn \l__cookingunits_input_range_sign_tl { -- }
\tl_set:Nn \l__cookingunits_input_fraction_sign_tl { / }
\tl_set:Nn \l__cookingunits_input_mixed_fraction_sign_tl { _ }
\tl_set:Nn \l__cookingunits_input_decimal_mark_tl { . , }
\tl_set:Nn \l__cookingunits_input_value_signs_tl { + - }
\tl_set:Nn \l__cookingunits_input_allowed_special_signs_tl { ? }
\tl_gset_rescan:Nnn \g__cookingunits_input_str_hash_one_tl
  { \char_set_catcode_letter:N \# } {#1}
\tl_set:Nn \l__cookingunits_allwed_integer_math_operators_tl { +-()*/ }
\tl_set:Nn \l__cookingunits_cunum_range_sign_tl { -- }
\tl_set:Nn \l__cookingunits_cutext_range_sign_tl { }
\tl_set:Nn \l__cookingunits_value_unit_space_tl { \thinspace }
\tl_set:Nn \l__cookingunits_cutext_space_tl { ~ }
\tl_set:Nn \l__cookingunits_cutext_numeral_space_tl { \space }
\tl_set:Nn \l__cookingunits_cuphrase_space_tl { \space }
\tl_set:Nn \l__cookingunits_unit_letter_not_allowed_tl { , / }
\AtBeginDocument {
  \cs_if_free:cT { T@TS1 }
    {
      \DeclareFontEncoding { TS1 } { } { }
      \DeclareFontSubstitution { TS1 } { cmr } { m } { n }
    }
}
\DeclareTextSymbolDefault \c__cookingunits_minus_tl { TS1 }
\DeclareTextSymbol \c__cookingunits_minus_tl { TS1 } { 61 }
\AtBeginDocument {
  \@ifpackageloaded { fontspec }
    {
      \@ifpackageloaded { eulervm }
        { }
        {
          \int_const:Nn \c__cookingunits_minus_int { 8722 }
          \tl_set:Nn \c__cookingunits_minus_tl
            { \tex_char:D \c__cookingunits_minus_int }
        }
    }
    { }
}
\dim_new:N \l__cookingunits_mixed_frac_dim
\dim_set:Nn \l__cookingunits_mixed_frac_dim { 0.1 em }
\int_new:N \l__cookingunits_round_precision_int
\int_set:Nn \l__cookingunits_round_precision_int { 2 }
\int_new:N \l__cookingunits_print_numerals_below_int
\int_set:Nn \l__cookingunits_print_numerals_below_int { 13 }
\int_new:N \l__cookingunits_local_number_of_persons_int
\int_new:N \l__cookingunits_wanted_number_of_persons_int
\int_set:Nn \l__cookingunits_wanted_number_of_persons_int { 4 }
\int_new:N \l__cookingunits_phrase_number_tl
\int_new:N \l__cookingunits_phrase_gender_tl
\seq_new:N \l__cookingunits_list_of_defined_keys_seq
\seq_new:N \g__cookingunits_list_of_defined_units_seq
\seq_new:N \g__cookingunits_allowed_special_keys_seq
\seq_new:N \l__cookingunits_phrase_numbers_seq
\seq_new:N \g__cookingunits_stored_derived_unit_symbol_seq
\seq_new:N \g__cookingunits_stored_derived_formula_seq
\seq_new:N \g__cookingunits_stored_derived_unit_print_seq
\int_new:N \l__cookingunits_nr_of_units_int
\int_new:N \l__cookingunits_depth_int
\seq_new:N \g__cookingunits_natural_units_seq
\seq_new:N \l__cookingunits_temperatures_to_check_seq
\seq_new:N \l__cookingunits_curef_do_not_change_seq
\prop_new:N \l__cookingunits_phrase_prop
\prop_new:N \l__cookingunits_derived_units_prop
\bool_new:N \l__cookingunits_pckopt_eval_fractions_bool
\bool_new:N \l__cookingunits_pckopt_convert_fractions_bool
\bool_new:N \l__cookingunits_pckopt_draft_bool
\bool_new:N \l__cookingunits_pckopt_round_to_int_bool
\bool_new:N \l__cookingunits_pckopt_check_temperature_bool
\bool_new:N \l__cookingunits_pckopt_convert_to_eV_bool
\bool_new:N \l__cookingunits_pckopt_cuam_old_bool
\bool_new:N \l__cookingunits_pckopt_recalculate_amount_bool
\bool_new:N \l__cookingunits_pckopt_cutext_to_cunum_bool
\bool_new:N \l__cookingunits_pckopt_cutext_old_bool
\bool_new:N \l__cookingunits_pckopt_cutext_keep_unit_bool
\bool_new:N \l__cookingunits_pckopt_round_commercial_bool
\bool_new:N \l__cookingunits_pckopt_use_phrases_bool
\bool_new:N \l__cookingunits_pckopt_round_precision_negative_bool
\bool_new:N \l__cookingunits_pckopt_fourty_two_bool
\bool_new:N \l__cookingunits_pckopt_bonkers_bool
\bool_new:N \l__cookingunits_minus_bool
\bool_new:N \l__cookingunits_round_number_bool
\bool_new:N \l__cookingunits_single_key_bool
\bool_new:N \l__cookingunits_cutext_uppercase_word_bool
\bool_new:N \l__cookingunits_reference_given_bool
\bool_new:N \l__cookingunits_lokal_recalc_for_people_bool
\bool_new:N \l__cookingunits_lokal_phrase_bool
\bool_new:N \l__cookingunits_lokal_change_unit_bool
\bool_new:N \l__cookingunits_pckopt_print_numeral_bool
\bool_new:N \l__cookingunits_lokal_numeral_bool
\bool_new:N \l__cookingunits_phrase_negative_bool
\bool_new:N \l__cookingunits_cutext_use_single_bool
\bool_new:N \l__cookingunits_symbol_was_set_by_key_bool
\bool_new:N \l__cookingunits_contains_valid_key_bool
\bool_new:N \l__cookingunits_check_decimal_bool
\bool_new:N \l__cookingunits_unit_error_bool
\bool_set_false:N \l__cookingunits_pckopt_cutext_keep_unit_bool
\bool_set_eq:NN \l__cookingunits_pckopt_print_numeral_bool \g__cookingunits_opt_numeral_bool
\quark_new:N \q__cookingunits_range
\quark_new:N \q__cookingunits_no_translation_str
\str_const:Nn \c__cookingunits_no_translation_str { no-translation-sady-found-__cookingunits }
\tl_new:N \l__cookingunits_scrap_tl
\tl_new:N \l__cookingunits_tmpa_tl
\tl_new:N \l__cookingunits_tmpb_tl
\tl_new:N \l__cookingunits_tmp_unit_tl
\fp_new:N \l__cookingunits_tmpa_fp
\clist_new:N \l__cookingunits_tmpa_clist
\prop_new:N \l__cookingunits_tmpa_prop
\prop_new:N \l__cookingunits_tmpb_prop
\seq_new:N \l__cookingunits_tmpa_seq
\seq_new:N \l__cookingunits_tmpb_seq
\int_new:N \l__cookingunits_tmpa_int
\int_new:N \l__cookingunits_tmpb_int
\bool_new:N \l__cookingunits_tmpa_bool
\bool_new:N \l__cookingunits_tmpb_bool
\keys_define:nn { cooking-units }
  {
    add-unit-to-group .code:n =
      {
        \keyval_parse:NNn
          \__cookingunits_add_to_unit_group_error:n
          \__cookingunits_add_to_unit_group:nn
          {#1}
      } ,
    add-unit-to-group .default:n = {} ,
    set-option-for .code:n =
      {
        \keyval_parse:NNn
          \__cookingunits_set_options_for_error:n
          \__cookingunits_set_options_for:nn
          {#1}
      },
    add-option-for .code:n =
      {
        \keyval_parse:NNn
          \__cookingunits_add_options_for_error:n
          \__cookingunits_add_options_for:nn
          {#1}
      },
    erase-all-options .code:n =
      {
        \clist_set_from_seq:NN \l__cookingunits_tmpa_clist \g__cookingunits_list_of_defined_units_seq
        \__cookingunits_clear_options_for:V \l__cookingunits_tmpa_clist
      },
    erase-all-options .value_forbidden:n = { true } ,
    erase-all-options-for .code:n =
      {
        \__cookingunits_clear_options_for:n {#1}
      },
    erase-all-options-for  .value_required:n = { true } ,
    cutext-to-cunum .bool_set:N = \l__cookingunits_pckopt_cutext_to_cunum_bool ,
    cutext-to-cunum .default:n = { false } ,
    cutext-to-cunum .groups:n = { change-command } ,
    cutext-change-unit .bool_set_inverse:N = \l__cookingunits_pckopt_cutext_keep_unit_bool ,
    cutext-change-unit .default:n = { true } ,
    cutext-change-unit .groups:n = { change-unit } ,
    cuam-version .choices:nn =
      { new , old }
      {
        \int_case:nn { \l_keys_choice_int }
          {
            { 1 } { \bool_set_false:N \l__cookingunits_pckopt_cuam_old_bool }
            { 2 } { \bool_set_true:N \l__cookingunits_pckopt_cuam_old_bool }
          }
      } ,
    cuam-version .default:n = { new } ,
    cuam-version .groups:n = { parse } ,
    cutext-version .choices:nn =
      { new , old }
      {
        \int_case:nn { \l_keys_choice_int }
          {
            { 1 } { \bool_set_false:N \l__cookingunits_pckopt_cutext_old_bool }
            { 2 } { \bool_set_true:N \l__cookingunits_pckopt_cutext_old_bool }
          }
      } ,
    cutext-version .default:n = { new } ,
    cutext-version .groups:n = { parse } ,
    expand-both .choices:nn =
      { n , o , f , x }
      {
        \tl_set_eq:NN \l__cookingunits_unit_argument_spec_tl \l_keys_choice_tl
        \tl_set_eq:NN \l__cookingunits_expand_amount_tl \l_keys_choice_tl
      } ,
    expand-both .default:n = { n } ,
    expand-both .groups:n = { parse } ,
    expand-amount .choices:nn =
      { n , o , f , x }
      {
        \tl_set_eq:NN \l__cookingunits_expand_amount_tl \l_keys_choice_tl
      } ,
    expand-amount .default:n = { n } ,
    expand-amount .groups:n = { parse } ,
    expand-unit .choices:nn =
      { n , o , f , x }
      {
        \tl_set_eq:NN \l__cookingunits_unit_argument_spec_tl \l_keys_choice_tl
      } ,
    expand-unit .default:n = { n } ,
    expand-unit .groups:n = { parse } ,
    set-special-sign .code:n =
      {
        \tl_map_inline:nn {#1}
          {
            \str_if_eq:nnT {##1} { < }
              {
                \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign }
                \tl_map_break:n { \use_none:nn }
              }
          }
        \use:n { \tl_set:Nn  \l__cookingunits_input_allowed_special_signs_tl {#1} }
      } ,
    set-special-sign .groups:n = { parse } ,
    add-special-sign .code:n =
      {
        \tl_map_inline:nn {#1}
          {
            \str_if_eq:nnTF {##1} { < }
              {
                \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign }
              }{
                \tl_put_right:Nn  \l__cookingunits_input_allowed_special_signs_tl {##1}
              }
          }
      } ,
    add-special-sign .default:n = { } ,
    add-special-sign .groups:n = { parse } ,
    set-unknown-message .choices:nn =
      { error , warning , none }
      {
        \msg_redirect_name:nnV { cooking-units } { amount-not-known }
          \l_keys_choice_tl
      } ,
    set-unknown-message .default:n = { warning } ,
    set-cutext-translation-message .choices:nn =
      { error , warning , none }
      {
        \msg_redirect_name:nnV { cooking-units } { cutext-no-translation-available }
          \l_keys_choice_tl
      } ,
    set-cutext-translation-message .default:n = { warning } ,
    print-numerals .bool_set:N = \l__cookingunits_pckopt_print_numeral_bool ,
    print-numerals .default:n = { true } ,
    use-numerals-below .int_set:N = \l__cookingunits_print_numerals_below_int ,
    use-numerals-below .default:n = { 13 } ,
    parse-number .bool_set_inverse:N = \l__cookingunits_pckopt_draft_bool ,
    parse-number .default:n= { true } ,
    parse-number .groups:n = { parse } ,
    range-sign .meta:n =
      {
        cunum-range-sign = {#1} ,
        cutext-range-sign = {#1}
      } ,
    range-sign .default:n = { -- } ,
    cunum-range-sign .tl_set:N = \l__cookingunits_cunum_range_sign_tl ,
    cunum-range-sign .default:n = { -- } ,
    cutext-range-sign .tl_set:N = \l__cookingunits_cutext_range_sign_tl ,
    cutext-range-sign .default:n = { -- } ,
    use-phrases .bool_set:N = \l__cookingunits_pckopt_use_phrases_bool ,
    use-phrases .default:n = { true } ,
    round-precision .code:n =
      {
        \int_set:Nn \l__cookingunits_round_precision_int {#1}
        \int_compare:nNnTF {#1} < { 0 }
          { \bool_set_true:N  }
          { \bool_set_false:N  }
        \l__cookingunits_pckopt_round_precision_negative_bool
      } ,
    round-precision .default:n = { 2 } ,
    round-to-int .bool_set:N = \l__cookingunits_pckopt_round_to_int_bool ,
    round-to-int .choices:nn =
      { true , false }
      {
        \msg_error:nnnn { cooking-units } { Option-deprecated }  { round-to-int } { round-precision = 0 }
        \int_compare:nNnTF { \l_keys_choice_int } = { 1 }
          {
            \int_set:Nn \l__cookingunits_round_precision_int { 0 }
          }{

          }
        \use:c { bool_set_ \l_keys_choice_tl :N } \l__cookingunits_pckopt_round_to_int_bool
      } ,
    round-to-int .default:n = { false } ,
    round-half .choices:nn =
      { default , commercial , up }
      {
        \int_case:nn { \l_keys_choice_int }
          {
            { 1 } { \bool_set_false:N \l__cookingunits_pckopt_round_commercial_bool }
            { 2 } { \bool_set_true:N \l__cookingunits_pckopt_round_commercial_bool }
            { 3 } { \bool_set_true:N \l__cookingunits_pckopt_round_commercial_bool }
          }
      },
    round-half .default:n = { default },
    eval-fraction .bool_set:N = \l__cookingunits_pckopt_eval_fractions_bool ,
    eval-fraction .default:n = { false } ,
    convert-fraction .bool_set:N = \l__cookingunits_pckopt_convert_fractions_bool ,
    convert-fraction .default:n = { true } ,
    fraction-command .code:n = { \cs_set_eq:NN \__cookingunits_frac:nn #1 } ,
    fraction-command .default:n = { \sfrac } ,
    fraction-inline .code:n = { \cs_set:Npn \__cookingunits_frac:nn ##1##2 {#1} } ,
    fraction-inline .default:n = { \sfrac {#1} {#2} } ,
    mixed-fraction-space .dim_set:N = \l__cookingunits_mixed_frac_dim ,
    mixed-fraction-space .default:n = { 0.1 em } ,
    cutext-space .tl_set:N = \l__cookingunits_cutext_space_tl ,
    cutext-space .default:n = { ~ } ,
    cutext-numeral-space .tl_set:N = \l__cookingunits_cutext_numeral_space_tl ,
    cutext-numeral-space .default:n = { \space } ,
    phrase-space .tl_set:N = \l__cookingunits_cuphrase_space_tl ,
    phrase-space .default:n = { ~ } ,
    amount-unit-space .tl_set:N = \l__cookingunits_value_unit_space_tl ,
    amount-unit-space .default:n = { \thinspace } ,
    recalculate-amount .bool_set:N = \l__cookingunits_pckopt_recalculate_amount_bool ,
    recalculate-amount .default:n = { false } ,
    set-number-of-persons .int_set:N = \l__cookingunits_wanted_number_of_persons_int ,
    set-number-of-persons .default:n = { 4 } ,
    label .code:n = \__cookingunits_label_and_persons:n {#1} ,
    label .value_required:n = { true } ,
    get-label .code:n = \__cookingunits_curef:n {#1} ,
    get-label .value_required:n = { true } ,
    ref .code:n = \__cookingunits_reference_label_and_persons:n {#1} ,
    ref .value_required:n = { true } ,
    check-temperature .bool_set:N = \l__cookingunits_pckopt_check_temperature_bool ,
    check-temperature .default:n = { true } ,
    add-temperature-to-check .code:n =
      {
        \keyval_parse:NNn
          \__cookingunits_temperature_to_check_print_error:n
          \__cookingunits_temperatures_to_check_define:nn
          {#1}
      } ,
    temperature-to-check .value_required:n = { true } ,
    convert-to-eV .bool_set:N = \l__cookingunits_pckopt_convert_to_eV_bool ,
    convert-to-eV .default:n = { true } ,
    add-natural-unit .code:n =
      {
        \seq_set_from_clist:Nn \l__cookingunits_tmpa_seq {#1}
        \seq_map_inline:Nn \l__cookingunits_tmpa_seq
          {
            \__cookingunits_error_if_unit_not_defined:nNF {##1} \l__cookingunits_curr_unit_tl
              {
                \seq_if_in:NVF \g__cookingunits_natural_units_seq \l__cookingunits_curr_unit_tl
                  { \seq_gput_right:NV \g__cookingunits_natural_units_seq \l__cookingunits_curr_unit_tl }
              }
          }
      } ,
    add-natural-unit .value_required:n = { true } ,
    42 .choice: ,
    42 / true .code:n = { \bool_set_true:N \l__cookingunits_pckopt_fourty_two_bool } ,
    42 / false .code:n = { \msg_fatal:nnn { cooking-units } { 42-is-...-wrong? } } ,
    42 .default:n = { true } ,
    42 .groups:n = { parse } ,
    input-range-sign .tl_set:N = \l__cookingunits_input_range_sign_tl ,
    input-range-sign .default:n = { -- } ,
    input-range-sign .groups:n = { parse } ,
    numeral-function .code:n = { \cs_set_eq:NN \__cookingunits_print_numeral:n #1 } ,
    Numeral-function .code:n = { \cs_set_eq:NN \__cookingunits_print_Numeral:n #1 } ,
    commands-add-hook .meta:n =
      {
        cunum-add-hook =  {#1} ,
        cutext-add-hook =  {#1} ,
        Cutext-add-hook =  {#1} ,
        cuam-add-hook =  {#1} ,
      } ,
    cunum-add-hook .code:n = { \tl_put_right:Nn \l__cookingunits_cunum_hook_tl {#1} } ,
    cutext-add-hook .code:n = { \tl_put_right:Nn \l__cookingunits_cutext_hook_tl {#1} } ,
    Cutext-add-hook .code:n = { \tl_put_right:Nn \l__cookingunits_Cutext_hook_tl {#1} } ,
    cuam-add-hook .code:n = { \tl_put_right:Nn \l__cookingunits_cuam_hook_tl {#1} } ,
    cunum-add-hook .groups:n = { parse } ,
    cutext-add-hook .groups:n = { parse } ,
    Cutext-add-hook .groups:n = { parse } ,
    cuam-add-hook .groups:n = { parse } ,
    commands-add-hook .groups:n = { parse } ,
  curef-add-forbidden-unit .code:n = { \__cookingunits_add_forbidden_unit:n {#1} } ,
  curef-add-forbidden-unit .default:n = { } ,
  curef-remove-forbidden-unit .code:n = { \__cookingunits_remove_forbidden_unit:n {#1} } ,
  curef-remove-forbidden-unit .default:n = { } ,
  curef-clear-forbidden-units .choice: ,
  curef-clear-forbidden-units/true .code:n = { \__cookingunits_clear_forbidden_unit: } ,
  curef-clear-forbidden-units/false .code:n = { } ,
  curef-clear-forbidden-units .value_required:n = true,
  definition / symbol .code:n =
    {
      \bool_set_true:N \l__cookingunits_contains_valid_key_bool
      \bool_set_true:N \l__cookingunits_symbol_was_set_by_key_bool
      \tl_set:cn { l__cookingunits_default_unit_ \l__cookingunits_original_unit_tl _tl } {#1}
    },
  definition / symbol .value_required:n = { true } ,
  definition / gender .code:n =
    {
      \bool_set_true:N \l__cookingunits_contains_valid_key_bool
      \__cookingunits_if_gender_error:nTF {#1}
        { \__cookingunits_culang_def_base:nVn { gender } \l__cookingunits_original_unit_tl { m } }
        { \__cookingunits_culang_def_base:nVn { gender } \l__cookingunits_original_unit_tl {#1} }
    },
  definition / gender .value_required:n = { true } ,
  definition / set-option .code:n =
    {
      \bool_set_true:N \l__cookingunits_contains_valid_key_bool
      \__cookingunits_set_options_for:Vn \l__cookingunits_original_unit_tl {#1}
    },
  definition / set-option .value_required:n = { true } ,
  definition / add-to-group .code:n =
    {
      \bool_set_true:N \l__cookingunits_contains_valid_key_bool
      \__cookingunits_add_to_unit_group:nV {#1} \l__cookingunits_original_unit_tl
    },
  definition / add-to-group .value_required:n = { true } ,
  definition / natural-unit .code:n =
    {
      \bool_set_true:N \l__cookingunits_contains_valid_key_bool
      \seq_if_in:NVF \g__cookingunits_natural_units_seq \l__cookingunits_original_unit_tl
        { \seq_gput_right:NV \g__cookingunits_natural_units_seq \l__cookingunits_original_unit_tl }
    },
  definition / natural-unit .default:n = { true } ,
  definition / unknown .code:n =
    {
      \tl_if_empty:nF {#1}
        {
          \msg_error:nnxx
            { cooking-units }
            { definition-key-mistyped? }
            \l_keys_key_str
            {#1}
        }
    },
   nothing-special .code:n =
    {
      \prop_gclear:N \g__cookingunits_master_changer_prop
      \prop_gclear:N \g__cookingunits_convert_bonkers_remember_prop
      \bool_set_false:N \l__cookingunits_pckopt_bonkers_bool
      \tl_set_eq:NN \l__cookingunits_bonkers_state_tl \c__cookingunits_bonkers_state_normal_tl
    },
  nothing-special .value_forbidden:n = { true } ,
   going-bonkers .code:n =
    {
      \prop_gclear:N \g__cookingunits_convert_bonkers_remember_prop
      \bool_set_true:N \l__cookingunits_pckopt_bonkers_bool
      \tl_set_eq:NN \l__cookingunits_bonkers_state_tl \c__cookingunits_bonkers_state_going_tl
    },
  going-bonkers .value_forbidden:n = { true } ,
   fully-bonkers .code:n =
    {
      \prop_gclear:N \g__cookingunits_master_changer_prop
      \prop_gclear:N \g__cookingunits_convert_bonkers_remember_prop
      \bool_set_true:N \l__cookingunits_pckopt_bonkers_bool
      \tl_set_eq:NN \l__cookingunits_bonkers_state_tl \c__cookingunits_bonkers_state_fully_tl
    },
  fully-bonkers .value_forbidden:n = { true } ,
   xD-lol .code:n =
    {
      \prop_gclear:N \g__cookingunits_master_changer_prop
      \prop_gclear:N \g__cookingunits_convert_bonkers_remember_prop
      \bool_set_true:N \l__cookingunits_pckopt_bonkers_bool
      \tl_set_eq:NN \l__cookingunits_bonkers_state_tl \c__cookingunits_bonkers_state_xD_tl
    },
  xD-lol .value_forbidden:n = { true } ,
  }
\msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range }
  {
    You \ cannot \ use \ '/' \ ( and  \ '_' )\ in \ combination \
    with \ '\l__cookingunits_input_range_sign_tl' \ in \  '#1'.
  }{
    You \ cannot \ use \ fractions \ with \ a \ range.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { missing-slash }
  {
    You \ cannot \ use \ '_'  \ without \
    '/' \ in \  '#1'.
  }{
    You \ cannot \ have \ a \ mixed \ fraction \ ('_') \ without \
    a \ normal \ fraction \ ('/').
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { fraction-wrong-order }
  {
    You \ cannot \ use \ '/'  \ before \ '_' \ in \ '#1'.
  }{
    You \ can \ only \ use \ '_' \ before \ '/'.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { unknown-unit }
  {
    The \ unit \ '#1' \ is \ not \ defined. \ Use \
    \newcookingunit (or \ one \ of \ the \ others) \ to \
    define \ new \ units.
  }{
    Define \ units \ before \ using \ or \ check \ if \ the \
    unit-key \ is \ written \ correctly.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { unit-already-defined }
  { The\ unit \ '#1' \ is \ already \ defined. }
  {
    The \ unit-key \ is \ already \ defined. \ Please \ use \ a \ different \
    key \ for \ a \ new \ unit.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { character-not-allowed }
  {
    Unit-keys \ are \ not \ allowed \ to \ either \ contain \ ',' \ or \ '/' \
    in \ '#1'.
  }{
    The \ unit-key \ is \ not \ allowed \ to \ contain \ ',' \ or \ '/'. \
    Due \ to \ internal \ reasons.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { missing-argument }
  { There \ is \ a \ missing \ argument. }
  {
    You \ probably \ have \ forgotten \ a \ curly-brace \ pair.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { symbol-and-special-keys-error }
  { You \ cannot \ use \ special-key \ '#1' \ with \ symbol \ '#2' \ definitions. }
  {
    You \ cannot \ redefine \ a \ symbol \ of \ a \ special-key.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Division-by-zero }
  { Division\ by \ zero \ is \ not \ allowed \ in \ '#1'. }
  { See \ a \ math \ book \ of \ your \ choice \ or \ for \ example \ Wikipedia. }
\msg_new:nnnn { cooking-units } { Token-not-allowed }
  { The \ token \ '#1' \ is \ not \ allowed \ in \ '#2'. }
  {
    The \ command \ accepts \ only \ a \ fixed \ number \ of \ tokens.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Second-decimal-sign-not-allowed }
  { A \ second \ decimal \ sign \ is \ not \ allowed \ in \ '#1'. }
  {
    Perhaps \ you \ didn't \ type \ it \ correctly.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Second-fraction-sign-not-allowed }
  { A \ second  \ fraction \ sign \ is \ not \ allowed \ in \ '#1'. }
  {
    Perhaps \ you \ didn't \ type \ it \ correctly.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Second-mixed-fraction-sign-not-allowed }
  { A \ second  \ mixed \ fraction \ sign \ is \ not \ allowed \ in \ '#1'. }
  {
    Perhaps \ you \ didn't \ type \ it \ correctly.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Key-not-defined }
  {
    The \ key \ '#1' \ is \ not \ defined. \ Use \ \cudefinekeys or \
    \cudefinesinglekey to \ define \ keys.
  }
  {
    This \ key \ is \ not \ defined, \ perhaps \ you  \ misspelled \ it.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Key-chain-unit-not-found }
  {
    It \ appears \ that \ \token_to_str:N \cuaddtokeychain\  was \ not \ able \ to \ find
    a \ key-chain-unit. Define \ key-chains \ first \ using \token_to_str:N \cudefinekeychain.
  }
  {
    No \ key-chain-unit\ was \ found, \ perhaps \ you  \ misspelled \ it?
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { Temperature-too-low }
  {
    The \ temperature \ '#1' \ is \ too \ low.\ It \ cannot \ be \
    below \ the \ absolute \ zero - point \ of \ '#2'. \ Note \ that \
    the \ temperatures \
    '\__cookingunits_seq_use_msg:N \l__cookingunits_temperatures_to_check_seq' \
    are \ rounded \ to \ integers \ by \ default.
    \\\\
    You \ can \ disable \ the \ option \ 'check-temperature' \ to \
    disable \ this \ error.
  }
  { See \ for \ example \ Wikipedia. }
\msg_new:nnnn { cooking-units } { key-choice-unknown }
  {
    The \ key \ '#1' \ only \ accepts \ only \
    '#3' \ as \ a \ set \ of \ choices \ and \ '#2' \ is \ non \ of \ these.
  }{
    The \ key \ accepts \ only \ a \ fixed \ set \ of \ choices. \
    You \ can \ add \ new \ choices \ via \ \token_to_str:N \cuaddkeys, ~
    \token_to_str:N \cuaddsinglekeys ~ and \ \token_to_str:N \cuaddtokeys.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { key-no-knows-value }
  {
    It \ appears \ that \ the \ key \ '#1' \ does \ not \ accept \ the \ value
    '#2'. \ Are \ you \ sure \ it \ is \ in \ the \ same \ key-chain?
  }{
    The \ key \ accepts \ only \ a \ fixed \ set \ of \ choices. \
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { group-choice-not-allowed }
  {
    The \ group \ key \ '#1' \ accepts \ only \
    '#3' \ as \ a \ set \ of \ choices \ and \ '#2' \ is \ non \ of \ these.
  }{
    The \ key \ accepts\ only \ a \ fixed \ set \ of \ choices. \
    You \ can \ add \ new \ choices \ via \ option \ 'add-unit-to-group'.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { amount-not-known }
  {
    The \ amount \  '#1' \ is \ not \ known \ at \ line \
    \msg_line_number: .
  }{
    You \ used\  a\  special\  sign\  indicating\  that\  the\  true\  amount\  of\  the\
    specific\  ingredient\  is\  (was) \ not\  known\  to\  you. This\  message\
    reminds\  you\  about\  that\  fact.
    \msg_see_documentation_text:n {cooking-units}
  }
\msg_new:nnnn { cooking-units } { group-key-unknown }
  {
    The \ group \ key \ '#1' \ is \ not \ defined. \ Perhaps
    \ you \ misspelled \ it?
  }{
    The \ group \ key \ is \ not \ defined.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { load-time-option }
  {
    The \ option \ '#1' \ is \ only \ available \ as \ a \ load-time-option. \
    Please \ set \ it \ as \ a \ package \ option.
  }{
    You \ cannot \ set \ this \ option \ using \ \cusetup ~
    but \ only \ as \ a \ package \ option.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { obsolete-command }
  {
    Command \ #1 is \ obsolete. \ Please \ use \ #2 instead.
  }{
    Don't \ use \ this \ old \ command \ ...
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { No-Value-given }
  {
    Please \ input \ a \ value \ for \ the \ key-value \ list \ in \ '#1'
  }{
    Each \ element \ of \ the \ list \ needs \ a \ value.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { Adding-single-to-multi-key-or-vice-verca }
  {
    You \ are \ trying \ to \ add \ a \ single-key \ to \ a \ multi-key \
    or \ vice-versa.
  }{
    This \ is \ not \ allowed!
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { Value-not-allowed }
  {
    The \ key-list \ in \ '#1' \ does \ not \ take \ a \ value.
  }{
    This \ key-list \ does \ not \ take \ a \ value. \ The \
    given \ value \ will \ be \ ignored.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { Minimum-already-defined }
  {
    A \ minimum \ for \ '#1' \ has \ already \ been \  defined.
  }{
    You \ cannot \ redefine \ it.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { Number-of-persons-missing }
  {
    Please \ add \ the \ number \ of \ persons \ this \ recipe \ is \ for \ in \ '#1'. \
    Note \ that\ the \ number \ must \ be \ given \ after \ a \ '*'.
  }{
    Write \ 'Schweinsbraten*4' \ to \ create \ the \ label \ 'Schweinsbraten' \
    which \ is \ initially \ for \ 4 \ persons.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { Number-of-persons-is-not-an-integer }
  {
    The \ number \ of \ persons \ the \ recipe \ is \ for \ must \ be \ an \
    integer. \ '#1' \ is \ not \ allowed.
  }{
    The \ number \ '#1' \ is \ not \ allowed.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { label-already-defined }
  {
    The \ label \ '#1' \ has \ already \ been \ defined.
  }{
    Each \ label \ must \ be \ unique.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { label-not-defined }
  {
    The \ label \ '#1' \ is \ not \ defined. \ Please \ note \ that \ a \ label
    \ has \ to \ defined \ before \ it \ is \ referenced.
  }{
    Define \ the \ label \ before \ using \ it.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { redefine-unit }
  {
    The \ unit \ '#1' \ is \ redefined \ by \ \declarecookingunit ~ at \
    \msg_line_context: .
  }{
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { phrase-unit-not-an-integer }
  {
    A \ phrase \ must \ be \ an \ integer,  \ '#1' \ is \ not \ allowed.
  }{
    You \ can \ only \ use \ integers.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { cutext-no-translation-available }
  {
    For \ the \ unit \ '#1' \ there \ exists \ no \ translation \ to \ be \ used \
    for \ \cutext ~ and \ \token_to_str:N \Cutext. \
    You \ can \ define \ new \ translations \ for \ a \ given \ language \ using \
    \cudefinename.
  }{
    \cunum ~ is \ used \ instead.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { Translation-not-available }
  {
    The \ translation \ for \ #1 \ does \ not \ exist.
    Please \ define \ it \ using \ \token_to_str:N\cudefinename.
  }{
    And \ you \ may \ send \ me \ the \ translation \ as \ it \ is \
    not \ available \ yet.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { formula-in-non-singlekeys }
  {
    The \ conversion \ value \ '#1' \ seems \ to \ be \ a \ formula. \
    This \ is \ not \ allowed \ for \ NON-\ singlekeys!
  }{
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { <-not-allowed-as-special-sign }
  {
    Currently \ (and \ probably \ forever) \ the \ sign \ '<' \
    is \ not \ allowed \ to \ be \ used \ as \ a \ special \ sign.
  }{
    I \ apologize \ for \ the \ inconvenience.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { unknown-gender }
  {
    '#1' \ is \ not \ allowed \ to \ be \ used \ as \ a \ gender-specification.
    Only \ 'm', \ 'f' \ or \ 'n' \ are \ allowed.
  }{
    Please \ remove \ spaces \ if \ there \ are \ some.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { no-natural-unit-known }
  {
    It \ seems\ that \ I \ cannot \ convert \ '#1' \ in \ a \ natural \
    unit \ as \ there \ is \ no \ conversion-factor \ defined.
  }{
    Not \ converting \ the \unit.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { curef-not-inside-list }
  {
   '#1' \ cannot \ be \ removed \ from \ the \ 'forbidden \ unit' \ list \ because
   \ it \ is \ not \ inside \ the \ list.
  }{
    Currently \ the \ list\ contains \ '#2'.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { curef-forbidden-unit }
  {
   The \ amount \  of \ '#1' \ cannot \ be \ changed \ using \ cooking-units`
   \ label \ and \ ref \ feature.
  }{
    You \ can \ remove \ the \ unit \ using \ 'curef-remove-forbidden-unit'.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { define-numeral-function }
  {
   You \ are \ using \ numerals \ (lowercase) \ without \ the \ load-time \ option \
   'use-fmtcount-numerals' \ as \ such \ you \ need \ to \ define \
   which \ function \ is \ to \ be \ used \ for \ numerals. \ You \ can
   \ do \ that \ via \ 'numeral-function' \ and \ 'Numeral-function'
  }{
    Please \ specify\ which \ function \ should \ be \ used \ to \ print \
    numerals (lowercase \ and \ uppercase).
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { define-Numeral-function }
  {
   You \ are \ using \ numerals \ (capitalized) \ without \ the \ load-time \ option \
   'use-fmtcount-numerals' \ as \ such \ you \ need \ to \ define \
   which \ function \ is \ to \ be \ used \ for \ numerals. \ You \ can
   \ do \ that \ via \ 'numeral-function' \ and \ 'Numeral-function'
  }{
    Please \ specify\ which \ function \ should \ be \ used \ to \ print \
    numerals (lowercase \ and \ uppercase).
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { 42-is-...-wrong? }
  {
   You \ requested \ to \ set  \ 42 \ to \ 'false'. \ This \ doesn't \ make
   \ any \ sense! \ It \ cannot \ be \ 'false', \ it \ is \ the \ answer \ to \ the
   \ question \ of \ life, \ universe \ and \ everything. \ For \ the \ sake \ of \
   the \ world \ I \ cannot \ allow \ you \ to \ set \ it \ to \ 'false', \ the \ universe
   \ might \ explode \ otherwise. \\
   The \ run \ will \ be \ aborted.
  }{
    Phew ... \ this \ might \ have \ ended \ disastrous.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { empty-amount }
  {
    The \ amount \ given \ is \ empty \ ( spaces \ are \ removed ).
  }{
    The \ amount \ given \ is \ empty.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { unknown-unit-option }
  {
    The \ unit-option \ '#1' \ is \ not \ defined.
  }{
    Please \ define \ the \ key \ '#1' \ via \ \newcukeysadd \ and \ friends.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { unknown-option }
  {
    The \ option \ '#1' \ is \ not \ defined.
  }{
    Perhaps \ you \ misspelled \ the \ option.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { unknown-choice }
  {
    The \ choice \ '#2' \ for \ key \ '#1' \ is \ not \ defined.
  }{
    Perhaps \ you \ misspelled \ the \ choice.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { internal-error }
  {
   This \ error \ shouldn't \ show. \ This \ means \ I
   \ (the \ package \ author) \  screwed
   \ up. \ The \ error \ code \ is \ '#1'. \
   Addition \ is \ '#2'.
  }{
    Please \ send \ me \ a \ bug \ report.
    \msg_see_documentation_text:n { cooking-units }
  }
\msg_new:nnnn { cooking-units } { definition-key-mistyped? }
  {
    This \ message \ shows \ during \ the \ definition \ of \ unit-keys. \
    You \ may \ have \ mistyped \ the \ key \ '#1'. \ You \ may \ see \
    this \ message \ because \ you \ have \ used \ a \ '=' \ sign \ in \ the \
    optional \ argument. \ If \ this \ is \ the \ case \ and \ you \ still \ want
    \ to \ use \ '=' \ in \ a \ symbol, \ please \ wrap \ the \ symbol
    \ in \ two \ braces: \ {{#1=#2}}.
  }{
    Or \ try \ using \ the \ 'symbol' \ option.
    \msg_see_documentation_text:n { cooking-units }
  }
\prg_new_protected_conditional:Npnn \__cookingunits_if_unit_defined:nN #1 #2 { TF , T }
  {
    \__cookingunits_set_unit:Nn #2 {#1}
    \seq_if_in:NVTF \g__cookingunits_list_of_defined_units_seq #2
      { \prg_return_true: }
      { \prg_return_false: }
  }
\prg_new_protected_conditional:Npnn \__cookingunits_error_if_unit_not_defined:nN #1#2 { TF, T, F }
  {
    \__cookingunits_if_unit_defined:nNTF {#1} #2
      { \prg_return_false: }
      {
        \msg_error:nnn { cooking-units } { unknown-unit } {#1}
        \prg_return_true:
      }
  }
\prg_new_protected_conditional:Npnn \__cookingunits_error_if_unit_not_defined:n #1 { TF, T, F }
  {
    \__cookingunits_error_if_unit_not_defined:nNTF {#1} \l__cookingunits_scrap_tl
      { \prg_return_true: }
      { \prg_return_false: }
  }
\cs_generate_variant:Nn \__cookingunits_error_if_unit_not_defined:nTF { V }
\prg_new_protected_conditional:Npnn \__cookingunits_if_unit_has_a_key:n #1 { T , F, TF }
  {
    \keys_if_exist:nnTF { cooking-units } {#1}
      { \prg_return_true: }
      { \prg_return_false: }
  }
\prg_generate_conditional_variant:Nnn \__cookingunits_if_unit_has_a_key:n { V } { T, TF }
\cs_new:Npn \__cookingunits_seq_use_msg:N #1
  { \seq_use:Nnnn #1 { ' , ~ ' } { ' , ~ ' } { ' ~ and ~ ' } }
\cs_generate_variant:Nn \__cookingunits_seq_use_msg:N { c }
\prg_new_protected_conditional:Npnn \__cookingunits_if_integer:n #1 { TF , F }
  {
    \tl_map_inline:nn {#1}
      {
        \tl_if_in:NnF \l__cookingunits_input_digits_tl {##1}
          {
            \tl_map_break:n { \use_i:nn \prg_return_false: }
          }
      }
    \prg_return_true:
  }
\cs_generate_variant:Nn \__cookingunits_if_integer:nTF { V }
\prg_new_protected_conditional:Npnn \__cookingunits_if_evaluation_is_integer:n #1 { TF , T , F }
  {
    \tl_concat:NNN \l__cookingunits_tmpa_tl
      \l__cookingunits_input_digits_tl \l__cookingunits_allwed_integer_math_operators_tl
    \tl_map_inline:nn {#1}
      {
        \tl_if_in:NnF \l__cookingunits_tmpa_tl {##1}
          { \tl_map_break:n { \use_iii:nnn } }
      }
    \use_i:nn
      { \prg_return_true: }
      { \prg_return_false: }
  }
\prg_new_conditional:Npnn \__cookingunits_if_integers:NN #1#2 { TF }
  {
    \__cookingunits_if_integer:VTF #1
      {
        \__cookingunits_if_print_type_equal:nTF { range }
          {
            \__cookingunits_if_integer:VTF #2
              { \prg_return_true: }
              { \prg_return_false: }
          }
          { \prg_return_true: }
      }
      { \prg_return_false: }
  }
\prg_new_conditional:Npnn \__cookingunits_if_contains_decimal:N #1 { TF }
  {
    \exp_after:wN \__cookingunits_check_for_decimal:w #1 . \q_nil . \q_stop
  }
\cs_new:Npn \__cookingunits_check_for_decimal:w #1 . #2 . \q_stop
  {
    \if_meaning:w \q_nil #2
      \exp_after:wN \prg_return_false:
    \else:
      \exp_after:wN \prg_return_true:
    \fi:
  }
\prg_new_conditional:Npnn \__cookingunits_if_contain_decimals:NN #1#2 { TF }
  {
    \__cookingunits_if_contains_decimal:NTF #1
      { \prg_return_true: }
      {
        \__cookingunits_if_print_type_equal:nTF { range }
          {
            \__cookingunits_if_contains_decimal:NTF #2
              { \prg_return_true: }
              { \prg_return_false: }
          }
          { \prg_return_false: }
      }
  }
\prg_new_conditional:Npnn \__cookingunits_if_gender_error:n #1 { TF, F , T }
  {
    \str_case:nnTF {#1}
      {
        { m } { }
        { f } { }
        { n } { }
      }
      { \prg_return_false: }
      {
        \msg_error:nnn { cooking-units } { unknown-gender } {#1}
        \prg_return_true:
      }
  }
\prg_new_conditional:Npnn \__cookingunits_error_if_group_not_defined:nN #1#2 { F, T , TF }
  {
    \__cookingunits_set_unit:Nn #2 {#1}
    \seq_if_exist:cTF { l__cookingunits_group_ #2 _seq }
      { \prg_return_false: }
      {
        \msg_error:nn { cooking-units} { group-key-unknown }
        \prg_return_true:
      }
  }
\prg_new_conditional:Npnn \__cookingunits_error_if_group_not_defined:n #1 { F }
  {
    \seq_if_exist:cTF { l__cookingunits_group_ \__cookingunits_to_unit:n {#1} _seq }
      { \prg_return_false: }
      {
        \msg_error:nn { cooking-units} { group-key-unknown }
        \prg_return_true:
      }
  }
\cs_new:Npn \__cookingunits_define_clear_unit_group:n #1
  {
    \__cookingunits_set_unit:Nn \l__cookingunits_tmpa_tl {#1}
    \seq_clear_new:c { l__cookingunits_group_ \l__cookingunits_tmpa_tl _seq }
    \keys_define:nn { cooking-units }
      {
        #1 .code:n = { \__cookingunits_unit_group_convert_units:nn {#1} {##1} } ,
        #1 .groups:n = { change-unit } ,
      }
  }
\cs_new:Npn \__cookingunits_unit_group_convert_units:nn #1#2
  {
    \bool_set_true:N \l__cookingunits_tmpa_bool
    \__cookingunits_error_if_group_not_defined:nNT {#1} \l__cookingunits_curr_group_tl
      { \bool_set_false:N \l__cookingunits_tmpa_bool }
    \__cookingunits_error_if_unit_not_defined:nNT {#2} \l__cookingunits_curr_unit_tl
      { \bool_set_false:N \l__cookingunits_tmpa_bool }
    \bool_if:NT \l__cookingunits_tmpa_bool
      {
        \seq_if_in:cVTF { l__cookingunits_group_ \l__cookingunits_curr_group_tl _seq } \l__cookingunits_curr_unit_tl
          {
            \seq_map_inline:cn { l__cookingunits_group_ \l__cookingunits_curr_group_tl _seq }
              { \__cookingunits_keys_set:nnn { cooking-units } {##1} {#2} }
          }{
            \msg_error:nnxxx
              { cooking-units }
              { group-choice-not-allowed }
              { \l__cookingunits_curr_group_tl } { \l__cookingunits_curr_unit_tl }
              { \__cookingunits_seq_use_msg:c { l__cookingunits_group_ \l__cookingunits_curr_group_tl _seq } }
          }
      }
  }
\cs_new:Npn \__cookingunits_add_to_unit_group_error:n #1
  { \msg_error:nnn { cooking-units } { No-Value-given } { add-unit-to-group } }
\cs_new:Npn \__cookingunits_add_to_unit_group:nn #1#2
  {
    \__cookingunits_error_if_group_not_defined:nNF {#1} \l__cookingunits_curr_group_tl
      {
        \clist_map_inline:nn {#2}
          {
            \__cookingunits_error_if_unit_not_defined:nNF {##1} \l__cookingunits_curr_unit_tl
              {
                \seq_if_in:cVF { l__cookingunits_group_ \l__cookingunits_curr_group_tl _seq } \l__cookingunits_curr_unit_tl
                  {
                    \seq_put_right:cV
                      { l__cookingunits_group_ \l__cookingunits_curr_group_tl _seq }
                      \l__cookingunits_curr_unit_tl
                  }
              }
          }
      }
  }
\cs_generate_variant:Nn \__cookingunits_add_to_unit_group:nn { nV }
\cs_new:Npn \__cookingunits_seq_get_overlap:NNTF #1#2 #3#4
  {
    \seq_map_inline:Nn #1
      {
        \seq_if_in:NnT #2 {##1}
          { #3 \seq_map_break:n { \use_none:nn } }
      }
    \use:n {#4}
  }
\cs_new:Npn \__cookingunits_keys_set:nnn #1#2#3
  { \keys_set:nn {#1} { #2 = #3 } }
\cs_generate_variant:Nn \__cookingunits_keys_set:nnn { nVV , nVn }
\cs_new:Npn \__cookingunits_convert_to_eV:N #1
  {
    \prop_get:NVNTF \g__cookingunits_convert_to_eV_remember_prop
      #1 \l__cookingunits_tmpa_tl
      { \__cookingunits_keys_set:nVV { cooking-units } #1 \l__cookingunits_tmpa_tl }
      {
        \__cookingunits_if_unit_has_a_key:VTF #1
          {
            \tl_set_eq:Nc \l__cookingunits_tmp_unit_tl { l__cookingunits_base_key_unit_ #1 _tl }
            \prop_get:cnNT { l__cookingunits_new_cukeys_ \l__cookingunits_tmp_unit_tl _prop }
              { Liste } \l__cookingunits_tmpa_seq
              {
                \__cookingunits_seq_get_overlap:NNTF \g__cookingunits_natural_units_seq \l__cookingunits_tmpa_seq
                  {
                    \prop_gput:NVn \g__cookingunits_convert_to_eV_remember_prop #1 {##1}
                    \__cookingunits_keys_set:nVn { cooking-units } #1 {##1}
                  }
                  { \msg_warning:nnx { cooking-units } { no-natural-unit-known } {#1} }
              }
          }
          { \msg_warning:nnx { cooking-units } { Key-not-defined } {#1} }
      }
  }
\cs_new:Npn \__cookingunits_changing_unit_bonkers:N #1
  {
    \prop_get:NVNTF \g__cookingunits_convert_bonkers_remember_prop
      #1 \l__cookingunits_tmpa_tl
      { \__cookingunits_keys_set:nVV { cooking-units } #1 \l__cookingunits_tmpa_tl }
      {
        \tl_case:NnF \l__cookingunits_bonkers_state_tl
          {
            \c__cookingunits_bonkers_state_going_tl { \__cookingunits_convert_going_bonkers:N #1 }
            \c__cookingunits_bonkers_state_fully_tl { \__cookingunits_convert_fully_bonkers:N #1 }
            \c__cookingunits_bonkers_state_xD_tl { \__cookingunits_convert_xD_bonkers:N #1 }
          }
          { \__cookingunits_create_internal_error:nN { going-bonkers } \l__cookingunits_bonkers_state_tl }
      }
  }
\cs_new:Npn \__cookingunits_convert_going_bonkers:N #1
  {
    \__cookingunits_if_unit_has_a_key:VT #1
      {
        \__cookingunits_prepare_going_bonkers:N #1
        \keys_set:nn { cooking-units } { eval-fraction = true }
        \__cookingunits_keys_set:nVV { cooking-units } #1 \l__cookingunits_tmpa_tl
        \prop_gput:NVV \g__cookingunits_convert_bonkers_remember_prop #1 \l__cookingunits_tmpa_tl
      }
  }
\cs_new:Npn \__cookingunits_convert_fully_bonkers:N #1
  {
    \__cookingunits_if_unit_has_a_key:VT #1
      {
        \__cookingunits_prepare_going_bonkers:N #1
        \keys_set:nn { cooking-units }
          { eval-fraction = true , curef-clear-forbidden-units = true }
        \prop_put:NVV \l__cookingunits_change_unit_prop {#1} \l__cookingunits_tmpa_tl
        \__cookingunits_cukeys_calculate_change_value:VVV #1 \l__cookingunits_tmpa_tl \l__cookingunits_tmp_unit_tl
      }
  }
\cs_new:Npn \__cookingunits_prepare_going_bonkers:N #1
  {
    \tl_set_eq:Nc \l__cookingunits_tmp_unit_tl { l__cookingunits_base_key_unit_ #1 _tl }
    \prop_get:cnN { l__cookingunits_new_cukeys_ \l__cookingunits_tmp_unit_tl _prop } { Liste } \l__cookingunits_tmpa_seq
    \bool_set_false:N \l__cookingunits_tmpa_bool
    \bool_until_do:Nn \l__cookingunits_tmpa_bool
      {
        \tl_set:Nf \l__cookingunits_tmpa_tl { \seq_rand_item:N \l__cookingunits_tmpa_seq }
        \seq_if_in:NVF \g__cookingunits_natural_units_seq \l__cookingunits_tmpa_tl
          { \bool_set_true:N \l__cookingunits_tmpa_bool }
      }
  }
\cs_new:Npn \__cookingunits_convert_xD_bonkers:N #1
  {
    \keys_set:nn { cooking-units } { eval-fraction = true , curef-clear-forbidden-units = true }
    \bool_set_false:N \l__cookingunits_tmpa_bool
    \bool_until_do:Nn \l__cookingunits_tmpa_bool
      {
        \tl_set:Nx \l__cookingunits_tmpa_tl { \seq_rand_item:N \g__cookingunits_list_of_defined_units_seq }
        \__cookingunits_if_no_unit_marker:NF \l__cookingunits_tmpa_tl
          { \bool_set_true:N \l__cookingunits_tmpa_bool }
      }
    \prop_put:NVV \l__cookingunits_change_unit_prop {#1} \l__cookingunits_tmpa_tl
    \tl_set:cf { l__cookingunits_unit_change_ #1 _tl } { \fp_eval:n { rand() * randint(255) } }
  }
\cs_new:Npn \__cookingunits_tl_eval:Nn #1#2 { \tl_set:Nf #1 { \fp_eval:n {#2} } }
\cs_generate_variant:Nn \__cookingunits_tl_eval:Nn { Nv, cn }
\prg_new_conditional:Npnn \__cookingunits_change_unit: { TF }
  {
    \__cookingunits_if_print_type_equal:nTF { fraction }
      { \prg_return_false: }
      {
        \__cookingunits_if_state_equal:nTF { special_sign }
          { \prg_return_false: }
          { \prg_return_true:  }
      }
  }
\cs_new:Npn \__cookingunits_temperature_to_check_print_error:n #1
  {
    \__cookingunits_error_if_unit_not_defined:n {#1}
    \msg_error:nnn { cooking-units } { No-Value-given } { add-temperature-to-check }
  }
\cs_new:Npn \__cookingunits_temperatures_to_check_define:nn #1#2
  {
    \__cookingunits_error_if_unit_not_defined:nNF {#1} \l__cookingunits_curr_unit_tl
      {
        \fp_if_exist:cF { l__cookingunits_ \l__cookingunits_curr_unit_tl _min_fp }
          {
            \seq_put_right:NV \l__cookingunits_temperatures_to_check_seq \l__cookingunits_curr_unit_tl
            \fp_new:c { l__cookingunits_ \l__cookingunits_curr_unit_tl _min_fp }
          }
        \fp_set:cn { l__cookingunits_ \l__cookingunits_curr_unit_tl _min_fp } {#2}
      }
  }
\cs_new:Npn \__cookingunits_set_options_for_error:n  #1
  {
    \__cookingunits_error_if_unit_not_defined:n {#1}
    \msg_error:nnn { cooking-units } { No-Value-given } { set-option-for }
  }
\cs_new:Npn \__cookingunits_add_options_for_error:n #1
  {
    \__cookingunits_error_if_unit_not_defined:n {#1}
    \msg_error:nnn { cooking-units } { No-Value-given } { add-option-for }
  }
\cs_new:Npn \__cookingunits_rounding_function:n #1
  {
    #1
      , \l__cookingunits_round_precision_int
      \bool_if:NT \l__cookingunits_pckopt_round_commercial_bool
        { , #1 }
  }
\cs_new:Npn \__cookingunits_label_and_persons:n #1
  {
    \str_if_in:nnTF {#1} { * }
      { \__cookingunits_label_and_persons_times_persons:ww #1 \q_stop }
      { \msg_error:nnn { cooking-units} { Number-of-persons-missing } {#1} }
  }
\cs_new:Npn \__cookingunits_label_and_persons_times_persons:ww #1 * #2 \q_stop
  {
    \__cookingunits_culabel:nn {#1} {#2}
  }
\cs_new:Npn \__cookingunits_culabel:nn #1#2
  {
    \int_if_exist:cTF { g__cookingunits_number_of_persons_ #1 _int }
      { \msg_error:nnn { cooking-units } { label-already-defined } {#1} }
      {
        \__cookingunits_if_evaluation_is_integer:nTF {#2}
          {
            \int_set:Nn \l__cookingunits_tmpa_int {#2}
            \int_new:c { g__cookingunits_number_of_persons_ #1 _int }
            \int_gset_eq:cN { g__cookingunits_number_of_persons_ #1 _int } \l__cookingunits_tmpa_int
          }
          { \msg_error:nnn { cooking-units } { Number-of-persons-is-not-an-integer } {#2} }
      }
  }
\cs_new:Npn \__cookingunits_reference_label_and_persons:n #1
  {
    \int_if_exist:cTF { g__cookingunits_number_of_persons_ #1 _int }
      {
        \bool_set_true:N \l__cookingunits_reference_given_bool
        \int_set_eq:Nc \l__cookingunits_local_number_of_persons_int
          { g__cookingunits_number_of_persons_ #1 _int }
      }
      { \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
  }
\cs_new:Npn \__cookingunits_curef:n #1
  {
    \int_if_exist:cTF { g__cookingunits_number_of_persons_ #1 _int }
      {
        \bool_if:NTF \l__cookingunits_pckopt_recalculate_amount_bool
          { \int_use:N \l__cookingunits_wanted_number_of_persons_int }
          { \int_use:c { g__cookingunits_number_of_persons_ #1 _int } }
      }{ \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
  }
\NewDocumentCommand \culabel { m m } { \__cookingunits_culabel:nn {#1} {#2} }
\NewExpandableDocumentCommand \curef { m } { \__cookingunits_curef:n {#1} }
\cs_new:Npn \__cookingunits_check_minus_remove_and_reverse:NN #1#2
  {
    \quark_if_nil:NF #2
      {
        %% Maybe simplify by a command?
        \tl_if_in:NnT #2 { - }
          {
            \tl_remove_once:Nn #2 { - }
            \bool_if:NTF #1 { \bool_set_false:N } { \bool_set_true:N } #1
          }
        \__cookingunits_check_minus_remove_and_reverse:NN #1
      }
  }
\cs_new:Npn \__cookingunits_add_forbidden_unit:n #1
  {
    \seq_set_from_clist:Nn \l__cookingunits_tmpa_seq {#1}
    \seq_map_inline:Nn \l__cookingunits_tmpa_seq
      {
        \__cookingunits_error_if_unit_not_defined:nNF {##1} \l__cookingunits_curr_unit_tl
          {
            \seq_if_in:NVF \l__cookingunits_curef_do_not_change_seq \l__cookingunits_curr_unit_tl
              { \seq_put_right:NV \l__cookingunits_curef_do_not_change_seq \l__cookingunits_curr_unit_tl }
          }
      }
  }
\cs_new:Npn \__cookingunits_remove_forbidden_unit:n #1
  {
    \seq_set_from_clist:Nn \l__cookingunits_tmpa_seq {#1}
    \seq_map_inline:Nn \l__cookingunits_tmpa_seq
      {
        \__cookingunits_error_if_unit_not_defined:nNF {##1} \l__cookingunits_curr_unit_tl
          {
            \seq_if_in:NVTF \l__cookingunits_curef_do_not_change_seq \l__cookingunits_curr_unit_tl
              { \seq_remove_all:NV \l__cookingunits_curef_do_not_change_seq \l__cookingunits_curr_unit_tl }
              {
                \msg_warning:nnnn { cooking-units } { curef-not-inside-list } {##1}
                  { \__cookingunits_seq_use_msg:N \l__cookingunits_curef_do_not_change_seq }
              }
          }
      }
  }
\cs_new:Npn \__cookingunits_clear_forbidden_unit:
  { \seq_clear:N \l__cookingunits_curef_do_not_change_seq }
\NewDocumentCommand \cudeclareunitgroup { m m }
  {
    \__cookingunits_define_clear_unit_group:n {#1}
    \__cookingunits_add_to_unit_group:nn {#1} {#2}
  }
\NewDocumentCommand \cuaddtounitgroup { m m }
  {
    \__cookingunits_add_to_unit_group:nn {#1} {#2}
  }
\NewDocumentCommand \cuclearunitgroup { m }
  {
    \__cookingunits_error_if_group_not_defined:nF {#1}
      { \__cookingunits_define_clear_unit_group:n {#1} }
  }
\NewDocumentCommand \cusetoptionfor { m m }
  { \__cookingunits_set_options_for:nn {#1} {#2} }
\NewDocumentCommand \cuaddoptionfor { m m }
  { \__cookingunits_add_options_for:nn {#1} {#2} }
\NewDocumentCommand \cuclearoptionfor { m }
  { \__cookingunits_clear_options_for:n {#1} }
\cs_new:Npn \__cookingunits_set_options_for:nn #1#2
  {
    \__cookingunits_map_trough_valid_unit_options:nnn {#1} {#2} { \clist_set:cV }
  }
\cs_new:Npn \__cookingunits_add_options_for:nn #1#2
  {
    \__cookingunits_map_trough_valid_unit_options:nnn {#1} {#2} { \clist_put_right:cV }
  }
\cs_new:Npn \__cookingunits_clear_options_for:n #1
  {
    \__cookingunits_map_trough_valid_unit_options:nnn {#1} { \q_no_value } { \clist_clear:c }
  }
\cs_generate_variant:Nn \__cookingunits_set_options_for:nn { V }
\cs_generate_variant:Nn \__cookingunits_clear_options_for:n { V }
\cs_new:Npn \__cookingunits_map_trough_valid_unit_options:nnn #1#2 #3
  {
    \seq_clear:N \l__cookingunits_tmpa_seq
    \clist_clear:N \l__cookingunits_tmpa_clist
    \clist_map_inline:nn {#1}
      {
        \__cookingunits_error_if_unit_not_defined:nNF {##1} \l__cookingunits_curr_unit_tl
          { \seq_put_right:NV \l__cookingunits_tmpa_seq \l__cookingunits_curr_unit_tl }
      }
    \quark_if_no_value:nTF {#2}
      {
        \seq_map_inline:Nn \l__cookingunits_tmpa_seq
          { #3 { l__cookingunits_unit_option_ ##1 _clist } }
      }{
        \tl_if_empty:nF {#2}
          { \__cookingunits_unit_options_check_validity:n {#2} }
        \seq_map_inline:Nn \l__cookingunits_tmpa_seq
          { #3 { l__cookingunits_unit_option_ ##1 _clist } \l__cookingunits_tmpa_clist }
      }
  }
\cs_new:Npn \__cookingunits_unit_options_check_validity:n #1
  {
    \keyval_parse:NNn
      \__cookingunits_unit_options_check_validity_aux_i:n
      \__cookingunits_unit_options_check_validity_aux_ii:nn
      {#1}
  }
\cs_new:Npn \__cookingunits_unit_options_check_validity_aux_i:n #1
  {
    \keys_if_exist:nnTF { cooking-units } {#1}
      { \clist_put_right:Nn \l__cookingunits_tmpa_clist {#1} }
      { \msg_error:nnn { cooking-units } { unknown-option } {#1} }
  }
\cs_new:Npn \__cookingunits_unit_options_check_validity_aux_ii:nn #1#2
  {
    \keys_if_exist:nnTF { cooking-units } {#1}
      {
        \clist_put_right:Nn \l__cookingunits_tmpa_clist { #1= {#2} }
      }
      { \msg_error:nnn { cooking-units } { unknown-option } {#1} }
  }
\cs_new:Npn \__cookingunits_culang_def_base:nnn #1#2#3
  { \declaretranslationfallback { #2 - #1 (__cookingunits) } {#3} }
\cs_generate_variant:Nn \__cookingunits_culang_def_base:nnn { nnv, nVn }
\cs_new:Npn \__cookingunits_culang_def_for:nnnn #1#2#3#4
  { \declaretranslation {#1} { #3 - #2  (__cookingunits) } {#4} }
\cs_generate_variant:Nn \__cookingunits_culang_def_for:nnnn { VnnV, V  }
\cs_new:Npn \__cookingunits_culang_print:nn #1#2
  { \GetTranslation { #2 - #1  (__cookingunits) } }
\cs_generate_variant:Nn \__cookingunits_culang_print:nn { nV }
\cs_new:Npn \__cookingunits_culang_let:nnN #1#2#3
  { \SaveTranslation #3 { #2 - #1 (__cookingunits) } }
\cs_new:Npn \__cookingunits_culang_let_for:nnnN #1#2#3#4
  { \SaveTranslationFor #4 {#1} { #3-#2 (__cookingunits) } }
\cs_generate_variant:Nn \__cookingunits_culang_let_for:nnnN { V }
\cs_new:Npn \__cookingunits_culang_if_translation_exists_for:nnnTF #1#2#3
  { \IfTranslation {#1} { #3 - #2 (__cookingunits) } }
\cs_generate_variant:Nn \__cookingunits_culang_if_translation_exists_for:nnnTF { V }
\prg_new_conditional:Npnn \__cookingunits_culang_unitname_let:Nn #1#2 { TF, F , T }
  {
    \__cookingunits_culang_let:nnN { name } {#2} #1
    \tl_if_eq:NNTF #1 \c__cookingunits_no_translation_str
      { \prg_return_false: }
      { \prg_return_true: }
  }
\cs_generate_variant:Nn \__cookingunits_culang_unitname_let:NnTF { NV, Nx }
\cs_generate_variant:Nn \__cookingunits_culang_unitname_let:NnT {  Nx }
\prg_new_conditional:Npnn \__cookingunits_culang_one_let:Nn #1#2 { T }
  {
    \__cookingunits_culang_let:nnN { gender } {#2} \l__cookingunits_tmpa_tl
    \__cookingunits_culang_one_let_by_gender:NVTF #1 \l__cookingunits_tmpa_tl
      { \prg_return_true: }
      {
        \tl_set:Nn #1 { 1 }
        \prg_return_false:
      }
  }
\cs_generate_variant:Nn \__cookingunits_culang_one_let:NnT { NV }
\prg_new_conditional:Npnn \__cookingunits_culang_one_let_by_gender:Nn #1#2 { TF }
  {
    \__cookingunits_culang_unitname_let:NnTF #1 { one (#2) }
      { \prg_return_true: }
      {
        \msg_error:nnx { cooking-units } { Translation-not-available } { one (#2) }
        \prg_return_false:
      }
  }
\cs_generate_variant:Nn \__cookingunits_culang_one_let_by_gender:NnTF { NV }
\seq_gset_from_clist:Nn \g__cookingunits_allowed_special_keys_seq
  {
    cutext-range-sign ,
    decimal-mark ,
    one (m) ,
    one (f) ,
    one (n)
  }
\__cookingunits_culang_def_base:nnn { name } { decimal-mark }  { . }
\__cookingunits_culang_def_base:nnn { name-pl } { decimal-mark } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_for:nnnn { German } { name-pl } { decimal-mark } { , }
\__cookingunits_culang_def_for:nnnn { French } { name-pl } { decimal-mark } { , }
\__cookingunits_culang_def_base:nnn { name } { one (m) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name } { one (f) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name } { one (n) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name-pl } { one (m) }  { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name-pl } { one (f) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name-pl } { one (n) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_for:nnnn { English } { name } { one (m) } { one }
\__cookingunits_culang_def_for:nnnn { English } { name } { one (f) } { one }
\__cookingunits_culang_def_for:nnnn { English } { name } { one (n) } { one }
\__cookingunits_culang_def_for:nnnn { German } { name } { one (m) } { ein }
\__cookingunits_culang_def_for:nnnn { German } { name } { one (f) } { eine }
\__cookingunits_culang_def_for:nnnn { German } { name } { one (n) } { ein }
\__cookingunits_culang_def_for:nnnn { French } { name } { one (m) } { un }
\__cookingunits_culang_def_for:nnnn { French } { name } { one (f) } { une }
\__cookingunits_culang_def_for:nnnn { French } { name } { one (n) } { un }
\__cookingunits_culang_def_base:nnn { name } { cutext-range-sign } { -- }
\__cookingunits_culang_def_base:nnn { name-pl } { cutext-range-sign } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_for:nnnn { German } { name } { cutext-range-sign } { ~bis~ }
\__cookingunits_culang_def_for:nnnn { English } { name } { cutext-range-sign } { ~to~ }
\__cookingunits_culang_def_for:nnnn { French } { name } { cutext-range-sign } { ~\`{a}~ }
\cs_new:Npn \__cookingunits_def_new_type:nnn #1#2#3
  {
    \tl_new:c { l__cookingunits_ #1 _tl }
    \clist_map_inline:nn {#3}
      { \tl_const:cn { c__cookingunits_ #1 _ ##1 _tl } {##1} }
    \__cookingunits_def_new_type_aux:cnn { l__cookingunits_ #1 _tl } {#1} {#2}
  }
\cs_new:Npn \__cookingunits_def_new_type_aux:Nnn #1#2#3
  {
    \cs_new_nopar:cpn { __cookingunits_set_ #2 _to:n } ##1
      {
        \tl_if_exist:cF { c__cookingunits_#2_ ##1 _tl }
          { \msg_error:nnn {cooking-units } { internal-error } { Type } { ERROR-set-#2-##1 } }
         \tl_set_eq:Nc #1 { c__cookingunits_#2_ ##1 _tl }
      }
    \tl_if_empty:nF {#3}
      {
        \prg_new_conditional:cpnn { __cookingunits_if_ #2 _equal:n } ##1 {#3}
          {
            \tl_if_exist:cF { c__cookingunits_#2_ ##1 _tl }
              { \msg_error:nnnn {cooking-units }  { internal-error } { Type-2 } { ERROR-set-#2-##1 } }
            \tl_if_eq:NcTF #1 { c__cookingunits_#2_ ##1 _tl }
              { \prg_return_true: }
              { \prg_return_false: }
          }
      }
  }
\cs_generate_variant:Nn \__cookingunits_def_new_type_aux:Nnn { c }
\__cookingunits_def_new_type:nnn { state } { TF , T , F , p }
  { normal , special_sign , 42 , error }
\__cookingunits_def_new_type:nnn { cmd_type } { TF , T , p }
  { cunum , cCutext , cuam }
\__cookingunits_def_new_type:nnn { parse_and_process_type } { TF , T }
  { number , range , fraction  }
\__cookingunits_def_new_type:nnn { print_type } { TF , T }
  { unknown , number , range , fraction  }
\__cookingunits_def_new_type:nnn { bonkers_state } { }
  { normal , going , fully , xD }
\tl_set_eq:NN \l__cookingunits_bonkers_state_tl \c__cookingunits_bonkers_state_normal_tl
\cs_new:Npn \__cookingunits_expand_unit_input:Nn #1#2
  {
    \cs_if_exist_use:c { exp_args:NN \l__cookingunits_unit_argument_spec_tl }
    \__cookingunits_set_unit:Nn #1 {#2}
  }
\cs_new:Npn \__cookingunits_expand_amount_input:Nn #1#2
  {
    \cs_if_exist_use:c { exp_args:NN \l__cookingunits_expand_amount_tl }
    \__cookingunits_set_amount:Nn #1 {#2}
  }
\cs_new:Npn \__cookingunits_do_the_stuff:nnnnnn #1#2#3#4#5#6
  {
    \__cookingunits_initialice_accordingly:nnnn {#1} {#4} {#2} {#5}
    \__cookingunits_use_hook_accordingly:
    \__cookingunits_parse_the_amount:n {#3}
    \__cookingunits_general_checkups:
    \__cookingunits_if_state_equal:nTF { normal }
      { \__cookingunits_process_amount_normally:n {#2} }
      { \__cookingunits_process_amount_special: }
    \__cookingunits_new_print_amount_correctly:
    \__cookingunits_new_print_unit_correctly:
  }
\cs_generate_variant:Nn \__cookingunits_do_the_stuff:nnnnnn { nnnnV }
\cs_new:Npn \__cookingunits_initialice_accordingly:nnnn #1#2#3#4
  {
    \__cookingunits_initialize_new_default:nnn {#1} {#3} {#4}
    \__cookingunits_initialize_new_default_units:
    \tl_case:NnF \l__cookingunits_cmd_type_tl
      {
        \c__cookingunits_cmd_type_cunum_tl { \tl_set:Nn \l__cookingunits_phantom_tl {#2} }
        \c__cookingunits_cmd_type_cCutext_tl  { \__cookingunits_initialice_addon_cutext: }
        \c__cookingunits_cmd_type_cuam_tl { }
      }
      { \__cookingunits_create_internal_error:nN { init-acc } \l__cookingunits_cmd_type_tl }
  }
\cs_new:Npn \__cookingunits_initialice_addon_cutext:
  {
    \bool_if:NT \l__cookingunits_pckopt_cutext_to_cunum_bool
      { \__cookingunits_set_cmd_type_to:n { cunum } }
    \bool_set_false:N \l__cookingunits_cutext_use_single_bool
  }
\cs_new:Npn \__cookingunits_initialize_new_default:nnn #1#2#3
  {
    \tl_clear:N \l__cookingunits_option_unit_tl
    \tl_if_empty:nF {#2} { \keys_set:nn { cooking-units } {#2} }
    \IfNoValueF {#1}
      { \__cookingunits_reference_label_and_persons:n {#1} }
    \__cookingunits_expand_unit_input:Nn \l__cookingunits_original_unit_tl {#3}
    \__cookingunits_error_if_unit_not_defined:VTF \l__cookingunits_original_unit_tl
      {
        \__cookingunits_set_state_to:n { error }
        \bool_set_true:N \l__cookingunits_unit_error_bool
      }
      { \__cookingunits_set_state_to:n { normal } }
    \__cookingunits_set_parse_and_process_type_to:n { number }
    \__cookingunits_set_print_type_to:n { unknown }
    \tl_clear:N \l__cookingunits_phantom_tl
    \__cookingunits_initialize_new_default_units:
  }
\cs_new:Npn \__cookingunits_initialize_new_default_units:
  {
    \__cookingunits_if_no_unit_marker:NTF \l__cookingunits_original_unit_tl
      { \tl_set_eq:NN \l__cookingunits_option_unit_tl \l__cookingunits_original_unit_tl }
      { \__cookingunits_intialize_new_default_units_aux: }
  }
\cs_new:Npn \__cookingunits_intialize_new_default_units_aux:
  {
    \bool_if:NTF \l__cookingunits_pckopt_bonkers_bool
      { \__cookingunits_changing_unit_bonkers:N \l__cookingunits_original_unit_tl }
      {
        \bool_if:NT \l__cookingunits_pckopt_convert_to_eV_bool
          { \__cookingunits_convert_to_eV:N \l__cookingunits_original_unit_tl }
      }
    \prop_get:NVNF \l__cookingunits_change_unit_prop \l__cookingunits_original_unit_tl \l__cookingunits_option_unit_tl
      { \tl_set_eq:NN \l__cookingunits_option_unit_tl \l__cookingunits_original_unit_tl }
  }
\cs_new_protected:Npn \__cookingunits_initialise_new_after_parsing:n #1
  {
    \clist_if_empty:cF { l__cookingunits_unit_option_ \l__cookingunits_decided_unit_tl _clist }
      {
        \keys_set_filter:nnv
          { cooking-units }
          { change-unit }
          { l__cookingunits_unit_option_ \l__cookingunits_decided_unit_tl _clist }
        \tl_if_empty:nF {#1} { \keys_set:nn { cooking-units } {#1} }
      }
    \bool_set_eq:NN \l__cookingunits_lokal_numeral_bool \l__cookingunits_pckopt_print_numeral_bool
  }
\cs_new:Npn \__cookingunits_decide_unit:
  {
    \__cookingunits_change_unit:TF
      { \tl_set_eq:NN \l__cookingunits_decided_unit_tl \l__cookingunits_option_unit_tl }
      { \tl_set_eq:NN \l__cookingunits_decided_unit_tl \l__cookingunits_original_unit_tl }
  }
\cs_new:Npn \__cookingunits_new_setup_bools_for_process_and_prints:
  {
    \bool_set_false:N \l__cookingunits_lokal_recalc_for_people_bool
    \bool_lazy_and:nnT
      { \l__cookingunits_reference_given_bool }
      { \l__cookingunits_pckopt_recalculate_amount_bool }
      {
        \int_compare:nNnF
          { \l__cookingunits_wanted_number_of_persons_int }
          =
          { \l__cookingunits_local_number_of_persons_int }
          { \bool_set_true:N \l__cookingunits_lokal_recalc_for_people_bool }
      }
    \__cookingunits_if_print_type_equal:nT { fraction }
      {
        \bool_lazy_or:nnTF
          { \l__cookingunits_pckopt_eval_fractions_bool }
          { \l__cookingunits_lokal_recalc_for_people_bool }
          { \__cookingunits_set_print_type_to:n { number } }
          {
            \bool_lazy_and:nnT
              { \l__cookingunits_pckopt_convert_fractions_bool }
              { ! \tl_if_eq_p:NN \l__cookingunits_option_unit_tl \l__cookingunits_original_unit_tl }
              { \__cookingunits_set_print_type_to:n { number } }
          }
      }
  }
\cs_new:Npn \__cookingunits_use_hook_accordingly:
  {
    \l__cookingunits_cmd_hook_tl
    \tl_case:NnF \l__cookingunits_cmd_type_tl
      {
        \c__cookingunits_cmd_type_cunum_tl { \l__cookingunits_cunum_hook_tl }
        \c__cookingunits_cmd_type_cCutext_tl
          {
            \bool_if:NTF \l__cookingunits_cutext_uppercase_word_bool
              { \l__cookingunits_Cutext_hook_tl }
              { \l__cookingunits_cutext_hook_tl }
          }
        \c__cookingunits_cmd_type_cuam_tl { \l__cookingunits_cuam_hook_tl }
      }
      { \__cookingunits_create_internal_error:nN { use-hook-acc } \l__cookingunits_cmd_type_tl }
  }
\cs_new:Npn \__cookingunits_general_checkups:
  {
    \tl_set_eq:NN \l__cookingunits_print_type_tl \l__cookingunits_parse_and_process_type_tl
    \__cookingunits_if_state_equal:nT { normal }
      { \__cookingunits_new_setup_bools_for_process_and_prints: }
    \__cookingunits_decide_unit:
    \__cookingunits_if_cmd_type_equal:nT { cCutext }
      { \__cookingunits_cutext_check_if_translation_available: }
  }
\cs_new:Npn \__cookingunits_process_amount_normally:n #1
  {
    \__cookingunits_initialise_new_after_parsing:n {#1}
    \tl_case:NnF \l__cookingunits_parse_and_process_type_tl
      {
        \c__cookingunits_parse_and_process_type_number_tl  \__cookingunits_new_process_number_in_input:
        \c__cookingunits_parse_and_process_type_range_tl     \__cookingunits_new_process_range_in_input:
        \c__cookingunits_parse_and_process_type_fraction_tl  \__cookingunits_new_process_fraction_in_input:
      }
      { \__cookingunits_create_internal_error:nN { process_the_input } \l__cookingunits_parse_and_process_type_tl }
  }
\cs_new:Npn \__cookingunits_process_amount_special:
  {
    \__cookingunits_if_state_equal:nT { special_sign }
      { \msg_warning:nnV { cooking-units } { amount-not-known } \l__cookingunits_original_amount_tl }
    \bool_if:NT \l__cookingunits_pckopt_fourty_two_bool
      { \__cookingunits_prepare_fourty_two_amount: }
  }
\cs_new:Npn \__cookingunits_prepare_fourty_two_amount:
  {
    \tl_set:Nn \l__cookingunits_number_tmpa_tl { 42 }
    \tl_set:Nn \l__cookingunits_number_tmpb_tl { 42 }
    \tl_if_empty:NF \l__cookingunits_mixed_fraction_tl
      { \tl_set:Nn \l__cookingunits_mixed_fraction_tl { 42 } }
    \__cookingunits_if_state_equal:nT { special_sign }
      {
        \tl_put_right:Nn \l__cookingunits_number_tmpa_tl { (!) }
        \tl_put_right:Nn \l__cookingunits_number_tmpb_tl { (!) }
        \tl_if_empty:NF \l__cookingunits_mixed_fraction_tl
          { \tl_put_right:Nn \l__cookingunits_mixed_fraction_tl { (!) }  }
      }
  }
\cs_new:Npn \__cookingunits_new_process_number_in_input:
  {
    \__cookingunits_calculate_and_store_in:N \l__cookingunits_number_tmpa_tl
    \__cookingunits_post_process_accordingly:NN \l__cookingunits_number_tmpa_tl \q_no_value
  }
\cs_new:Npn \__cookingunits_new_process_range_in_input:
  {
    \__cookingunits_calculate_and_store_in:N \l__cookingunits_number_tmpa_tl
    \__cookingunits_calculate_and_store_in:N \l__cookingunits_number_tmpb_tl
    \__cookingunits_post_process_accordingly:NN \l__cookingunits_number_tmpa_tl \l__cookingunits_number_tmpb_tl
  }
\cs_new:Npn \__cookingunits_new_process_fraction_in_input:
  {
    \__cookingunits_process_and_remove_minus_in_fraction:NNNN \l__cookingunits_minus_bool
      \l__cookingunits_mixed_fraction_tl
      \l__cookingunits_number_tmpa_tl
      \l__cookingunits_number_tmpb_tl
    \__cookingunits_if_print_type_equal:nTF { number }
      {
        \__cookingunits_convert_fraction_to_number_in_input:NNN
          \l__cookingunits_mixed_fraction_tl
          \l__cookingunits_number_tmpa_tl
          \l__cookingunits_number_tmpb_tl
      }{
        \__cookingunits_post_process_fraction_accordingly:NNN
          \l__cookingunits_mixed_fraction_tl
          \l__cookingunits_number_tmpa_tl
          \l__cookingunits_number_tmpb_tl
      }
  }
\cs_new:Npn \__cookingunits_process_and_remove_minus_in_fraction:NNNN #1 #2#3#4
  {
    \bool_set_false:N #1
    \__cookingunits_check_minus_remove_and_reverse:NN
      #1 #2#3#4
      \q_nil
  }
\cs_new:Npn \__cookingunits_convert_fraction_to_number_in_input:NNN #1#2#3
  {
    \fp_compare:nNnTF {#3} = { 0 }
      { \__cookingunits_create_error:n { Division-by-zero } }
      {
        \__cookingunits_tl_eval:Nn \l__cookingunits_number_tmpa_tl { #1 + #2 / #3 }
        \bool_if:NT \l__cookingunits_minus_bool
          { \tl_put_left:Nn \l__cookingunits_number_tmpa_tl { - } }
        \__cookingunits_new_process_number_in_input:
      }
  }
\cs_new:Npn \__cookingunits_new_print_amount_correctly:
  {
    \__cookingunits_if_state_equal:nTF { error }
      { \l__cookingunits_original_amount_tl }
      {
        \tl_case:NnF \l__cookingunits_print_type_tl
          {
            \c__cookingunits_print_type_number_tl
              {
                \__cookingunits_print_number_accordingly:N
                  \l__cookingunits_number_tmpa_tl
              }
            \c__cookingunits_print_type_range_tl
              {
                \__cookingunits_print_range_accordingly:NN
                  \l__cookingunits_number_tmpa_tl
                  \l__cookingunits_number_tmpb_tl
              }
            \c__cookingunits_print_type_fraction_tl
              {
                \__cookingunits_culang_let:nnN { name } { decimal-mark } \l__cookingunits_translation_tmpa_tl
                \tl_replace_once:Nnn \l__cookingunits_mixed_fraction_tl { . } \l__cookingunits_translation_tmpa_tl
                \tl_replace_once:Nnn \l__cookingunits_number_tmpa_tl { . } \l__cookingunits_translation_tmpa_tl
                \tl_replace_once:Nnn \l__cookingunits_number_tmpb_tl { . } \l__cookingunits_translation_tmpa_tl
                \__cookingunits_print_fractions:Nnn
                  \l__cookingunits_mixed_fraction_tl
                  \l__cookingunits_number_tmpa_tl
                  \l__cookingunits_number_tmpb_tl
              }
          }
          { \__cookingunits_create_internal_error:nN { print_the_input } \l__cookingunits_print_type_tl }
      }
  }
\cs_new:Npn \__cookingunits_new_print_unit_correctly:
  {
    \__cookingunits_if_state_equal:nTF { error }
      {
        \tl_case:NnF \l__cookingunits_cmd_type_tl
          { \c__cookingunits_cmd_type_cuam_tl { } }
          { \__cookingunits_print_unit_in_case_of_error: }
      }
      {
        \tl_case:NnF \l__cookingunits_cmd_type_tl
          {
            \c__cookingunits_cmd_type_cunum_tl { \__cookingunits_cunum_print_correct_unit: }
            \c__cookingunits_cmd_type_cCutext_tl { \__cookingunits_cutext_print_correct_unitname: }
            \c__cookingunits_cmd_type_cuam_tl { \__cookingunits_cuam_print_correct_unitphrase: }
          }
          { \__cookingunits_create_internal_error:nN { print-unit-acc } \l__cookingunits_cmd_type_tl }
      }
  }
\cs_new:Npn \__cookingunits_print_unit_in_case_of_error:
  {
    \tl_if_empty:NF \l__cookingunits_phantom_tl { \phantom { \l__cookingunits_phantom_tl } }
    \tl_use:N \l__cookingunits_value_unit_space_tl
    \bool_if:NTF \l__cookingunits_unit_error_bool
      { \l__cookingunits_original_unit_tl }
      { \__cookingunits_culang_print:nV { unit-symbol } \l__cookingunits_original_unit_tl }
  }
\cs_new:Npn \__cookingunits_print_number_accordingly:N #1
  {
    \tl_case:NnF \l__cookingunits_cmd_type_tl
      {
        \c__cookingunits_cmd_type_cunum_tl { \__cookingunits_print_numerical_input:N #1 }
        \c__cookingunits_cmd_type_cCutext_tl { \__cookingunits_cutext_print_input:N #1 }
        \c__cookingunits_cmd_type_cuam_tl { \__cookingunits_cuam_print_numerical_input:N #1 }
      }
      { \__cookingunits_create_internal_error:nN { print-input-acc } \l__cookingunits_cmd_type_tl }
  }
\cs_new:Npn \__cookingunits_print_range_accordingly:NN #1#2
  {
    \__cookingunits_print_number_accordingly:N #1
    \__cookingunits_print_range_sign:
    \__cookingunits_print_number_accordingly:N #2
  }
\cs_new:Npn \__cookingunits_print_range_sign:
  {
   \__cookingunits_if_cmd_type_equal:nTF { cunum }
     { \tl_use:N \l__cookingunits_cunum_range_sign_tl }
     {
        \bool_lazy_or:nnTF
          { \__cookingunits_if_cmd_type_equal_p:n { cCutext } }
          { \l__cookingunits_lokal_numeral_bool }
          {
            \bool_set_false:N \l__cookingunits_cutext_uppercase_word_bool
            \tl_if_empty:NTF \l__cookingunits_cutext_range_sign_tl
              { \__cookingunits_culang_print:nn { name } { cutext-range-sign } }
              { \tl_use:N \l__cookingunits_cutext_range_sign_tl }
          }
          { \tl_use:N \l__cookingunits_cunum_range_sign_tl }
     }
  }
\cs_new:Npn \__cookingunits_post_process_accordingly:NN #1#2
  {
    \tl_case:NnF \l__cookingunits_cmd_type_tl
      {
        \c__cookingunits_cmd_type_cunum_tl { }
        \c__cookingunits_cmd_type_cCutext_tl { \__cookingunits_cutext_post_process_input:NN #1#2 }
        \c__cookingunits_cmd_type_cuam_tl { \__cookingunits_cuam_post_process_input:NN #1#2 }
      }{
        \__cookingunits_create_internal_error:nN { post-process } \l__cookingunits_cmd_type_tl
      }
  }
\cs_new:Npn \__cookingunits_post_process_fraction_accordingly:NNN #1#2#3
  {
    \tl_case:NnF \l__cookingunits_cmd_type_tl
      {
        \c__cookingunits_cmd_type_cunum_tl { }
        \c__cookingunits_cmd_type_cCutext_tl { \__cookingunits_cutext_post_process_fraction_input:NNN #1#2#3 }
        \c__cookingunits_cmd_type_cuam_tl { }
      }{
        \__cookingunits_create_internal_error:nN { post-process-frac } \l__cookingunits_cmd_type_tl
      }
  }
\cs_new_protected:Npn \__cookingunits_print_numerical_input:N #1
  {
    \tl_if_in:NnT #1 { . }
      {
        \__cookingunits_culang_let:nnN { name } { decimal-mark } \l__cookingunits_translation_tmpa_tl
        \tl_replace_once:Nnn #1 { . } { \l__cookingunits_translation_tmpa_tl }
      }
    \tl_replace_once:Nnn #1 { - } \c__cookingunits_minus_tl
    #1
  }
\cs_new:Npn \__cookingunits_print_fractions:Nnn #1#2#3
  {
    \bool_if:NT \l__cookingunits_minus_bool { \c__cookingunits_minus_tl }
    \tl_if_empty:NF #1
      {
        #1
        \skip_horizontal:N \l__cookingunits_mixed_frac_dim
      }
    \__cookingunits_frac:nn {#2} {#3}
  }
\cs_new:Npn \__cookingunits_create_internal_error:nN #1#2
  {
    \__cookingunits_set_state_to:n { error }
    \msg_error:nnnV { cooking-units } { internal-error } {#1} #2
  }
\cs_new:Npn \__cookingunits_create_error:n #1
  {
    \__cookingunits_set_state_to:n { error }
    \msg_error:nnV { cooking-units } {#1} \l__cookingunits_original_amount_tl
  }
\cs_new:Npn \__cookingunits_create_error_and_stop:n #1
  {
    \__cookingunits_create_error:n {#1}
    \use_none_delimit_by_q_nil:w
  }
\cs_new:Npn \__cookingunits_create_error:nn #1#2
  {
    \__cookingunits_set_state_to:n { error }
    \msg_error:nnnV { cooking-units } {#1} {#2} \l__cookingunits_original_amount_tl
  }
\cs_new:Npn \__cookingunits_parse_the_amount:n #1
  {
    \__cookingunits_expand_amount_input:Nn \l__cookingunits_original_amount_tl {#1}
    \tl_set_rescan:NnV \l__cookingunits_original_amount_tl
      {
        \char_set_catcode_letter:N \_ %
        \char_set_catcode_ignore:N \ %
        \char_set_catcode_other:N ? %
      } \l__cookingunits_original_amount_tl
    \bool_lazy_any:nTF
      {
        { \tl_if_empty_p:N \l__cookingunits_original_amount_tl }
        { \l__cookingunits_pckopt_draft_bool }
      }
      { \__cookingunits_prepare_just_print_input: }
      { \__cookingunits_split_and_parse_input: }
  }
\cs_new:Npn \__cookingunits_split_and_parse_input:
  {
    \bool_if:NT \l__cookingunits_pckopt_fourty_two_bool
      { \__cookingunits_set_state_to:n { 42 } }
    \tl_set_eq:NN \l__cookingunits_tmpa_tl \l__cookingunits_original_amount_tl
    \__cookingunits_prepare_to_split_input:N \l__cookingunits_tmpa_tl
  }
\cs_new:Npn \__cookingunits_prepare_just_print_input:
  {
    \__cookingunits_set_state_to:n { error }
    \tl_if_empty:NT \l__cookingunits_original_amount_tl
      { \__cookingunits_create_error:nn { cooking-units } { empty-amount } }
  }
\cs_new:Npn \__cookingunits_prepare_to_split_input:N #1
  {
    \tl_if_in:NVT #1 \l__cookingunits_input_range_sign_tl
      {
        \tl_replace_once:NVn #1 \l__cookingunits_input_range_sign_tl { \q__cookingunits_range }
        \__cookingunits_set_parse_and_process_type_to:n { range }
      }
    \tl_if_in:NnT #1 { / }
      {
        \__cookingunits_if_parse_and_process_type_equal:nT { range }
          { \__cookingunits_create_error_and_stop:n { fraction-not-allowed-with-range } }
        \__cookingunits_set_parse_and_process_type_to:n { fraction }
      }
    \__cookingunits_split_and_parse:N #1
    \use_none_delimit_by_q_nil:w \q_nil
  }
\cs_new:Npn \__cookingunits_split_and_parse:N #1
  {
    \tl_case:NnF \l__cookingunits_parse_and_process_type_tl
      {
        \c__cookingunits_parse_and_process_type_number_tl { \__cookingunits_split_and_parse_number:V }
        \c__cookingunits_parse_and_process_type_range_tl { \__cookingunits_split_and_parse_range:V }
        \c__cookingunits_parse_and_process_type_fraction_tl { \__cookingunits_split_and_parse_fraction:V }
      }
      { \__cookingunits_create_internal_error:nN { split } \l__cookingunits_parse_and_process_type_tl }
    #1
  }
\cs_new:Npn \__cookingunits_split_and_parse_number:n #1
  {
    \__cookingunits_parse_input_and_safe_in:nN {#1} \l__cookingunits_number_tmpa_tl
  }
\cs_new:Npn \__cookingunits_split_and_parse_range:n #1
  {
    \__cookingunits_split_and_parse_range_aux:ww #1 \q_stop
  }
\cs_new:Npn \__cookingunits_split_and_parse_range_aux:ww #1 \q__cookingunits_range #2 \q_stop
  {
    \__cookingunits_parse_input_and_safe_in:nN {#1} \l__cookingunits_number_tmpa_tl
    \__cookingunits_parse_input_and_safe_in:nN {#2} \l__cookingunits_number_tmpb_tl
  }
\cs_new:Npn \__cookingunits_split_and_parse_fraction:n #1
  {
    \__cookingunits_split_and_parse_fraction_mixed:ww
      #1 \q_stop / \q_recursion_tail _ \q_nil \q_stop
      \q_recursion_stop
  }
\cs_new:Npn \__cookingunits_split_and_parse_fraction_mixed:ww #1 _ #2 \q_stop
  {
    \quark_if_nil:nTF {#2}
      {
        \tl_clear:N \l__cookingunits_mixed_fraction_tl
        \__cookingunits_split_and_parse_fraction_frac:ww #1 \q_stop
      }{
        \__cookingunits_parse_input_and_safe_in:nN {#1} \l__cookingunits_mixed_fraction_tl
        \__cookingunits_split_and_parse_fraction_frac:ww #2 \q_stop
      }
  }
\cs_new:Npn \__cookingunits_split_and_parse_fraction_frac:ww #1 / #2 \q_stop
  {
    \quark_if_recursion_tail_stop_do:nn {#2}
      { \__cookingunits_create_error:n { fraction-wrong-order } }
    \__cookingunits_parse_input_and_safe_in:nN {#1} \l__cookingunits_number_tmpa_tl
    \__cookingunits_parse_input_and_safe_in:nN {#2} \l__cookingunits_number_tmpb_tl
    \use_none_delimit_by_q_recursion_stop:w
  }
\cs_generate_variant:Nn \__cookingunits_split_and_parse_number:n { V }
\cs_generate_variant:Nn \__cookingunits_split_and_parse_range:n { V }
\cs_generate_variant:Nn \__cookingunits_split_and_parse_fraction:n { V }
\cs_new:Npn \__cookingunits_parse_input_and_safe_in:nN #1 #2
  {
    \tl_clear:N \l__cookingunits_tmpa_tl
    \bool_set_false:N \l__cookingunits_check_decimal_bool
    \cs_set_eq:NN \__cookingunits_parse:N \__cookingunits_start_loop:N
    \tl_map_function:nN {#1} \__cookingunits_parse:N
    \__cookingunits_if_state_equal:nF { error }
      { \tl_set_eq:NN #2 \l__cookingunits_tmpa_tl }
  }
\cs_new:Npn \__cookingunits_start_loop:N #1
  {
    \cs_set_eq:NN \__cookingunits_parse:N \__cookingunits_parse_input_loop_aux:N
    \tl_if_in:NnTF \l__cookingunits_input_value_signs_tl {#1}
      { \tl_put_right:Nn \l__cookingunits_tmpa_tl {#1} }
      { \tl_map_function:nN {#1} \__cookingunits_parse:N }
  }
\cs_new:Npn \__cookingunits_parse_input_loop_aux:N #1
  {
    \tl_if_in:NnTF \l__cookingunits_input_digits_tl {#1}
      { \tl_put_right:Nn \l__cookingunits_tmpa_tl {#1} }
      {
        \tl_if_in:NnTF \l__cookingunits_input_decimal_mark_tl {#1}
          {
            \__cookingunits_check_repitition:N \l__cookingunits_check_decimal_bool
            \tl_put_right:Nn \l__cookingunits_tmpa_tl { . }
          }{
            \tl_if_in:NnTF \l__cookingunits_input_allowed_special_signs_tl {#1}
              {
                \__cookingunits_if_state_equal:nF { error }
                  { \__cookingunits_set_state_to:n { special_sign } }
                \tl_put_right:Nn \l__cookingunits_tmpa_tl {#1}
              }
              { \__cookingunits_check_which_error:n {#1} }
          }
      }
  }
\cs_new:Npn \__cookingunits_check_which_error:n #1
  {
    \tl_if_in:NnTF \l__cookingunits_input_fraction_sign_tl {#1}
      { \__cookingunits_create_error:n { Second-fraction-sign-not-allowed } }
      {
        \tl_if_in:NnTF \l__cookingunits_input_mixed_fraction_sign_tl {#1}
          {
            \__cookingunits_if_parse_and_process_type_equal:nTF { fraction }
              { \__cookingunits_create_error:n { Second-mixed-fraction-sign-not-allowed } }
              { \__cookingunits_create_error:n { missing-slash } }
          }
          { \__cookingunits_create_error:nn { Token-not-allowed } {#1} }
      }
  }
\cs_new:Npn \__cookingunits_check_repitition:N #1
  {
    \bool_if:NTF #1
      { \__cookingunits_create_error:n { Second-decimal-sign-not-allowed } }
      { \bool_set_true:N #1 }
  }
\cs_new:Npn \__cookingunits_calculate_and_store_in:N #1
  {
    \__cookingunits_calculate_input_and_store_in:N #1
    \__cookingunits_calc_references_and_store_in:N #1
    \__cookingunits_round_calculated_input_and_store_in:N #1
    \__cookingunits_check_temperature_limit:N #1
  }
\cs_new:Npn \__cookingunits_calculate_input_and_store_in:N #1
  {
    \tl_if_eq:NNF \l__cookingunits_decided_unit_tl \l__cookingunits_original_unit_tl
      {
        \fp_set:Nn \l__cookingunits_tmpa_fp {#1}
        \tl_if_in:cnTF { l__cookingunits_unit_change_ \l__cookingunits_original_unit_tl _tl } { \l__cookingunits_tmpa_fp }
          {
            \__cookingunits_tl_eval:Nv #1 { l__cookingunits_unit_change_ \l__cookingunits_original_unit_tl _tl }
          }{
            \__cookingunits_tl_eval:Nn #1
              { \l__cookingunits_tmpa_fp * \tl_use:c { l__cookingunits_unit_change_ \l__cookingunits_original_unit_tl _tl }  }
          }
      }
  }
\cs_new:Npn \__cookingunits_calc_references_and_store_in:N #1
  {
    \bool_if:NT \l__cookingunits_lokal_recalc_for_people_bool
      {
        \seq_if_in:NVTF \l__cookingunits_curef_do_not_change_seq \l__cookingunits_decided_unit_tl
          { \msg_error:nnV { cooking-units } { curef-forbidden-unit } \l__cookingunits_decided_unit_tl }
          { \__cookingunits_calc_references_and_store_in_aux:N #1 }
      }
  }
\cs_new:Npn \__cookingunits_calc_references_and_store_in_aux:N #1
  {
    \__cookingunits_tl_eval:Nn #1
      {
        #1 *
        \l__cookingunits_wanted_number_of_persons_int /
        \l__cookingunits_local_number_of_persons_int
      }
  }
\cs_new:Npn \__cookingunits_round_calculated_input_and_store_in:N #1
  {
    \bool_if:NTF \l__cookingunits_pckopt_round_precision_negative_bool
      { \bool_set_true:N \l__cookingunits_round_number_bool }
      { \__cookingunits_check_number_for_rounding:V #1 }
    \bool_if:NT \l__cookingunits_round_number_bool
      { \__cookingunits_tl_eval:Nn #1 { round ( \__cookingunits_rounding_function:n {#1} ) } }
  }
\cs_new:Npn \__cookingunits_check_number_for_rounding:n #1
  {
    \bool_set_false:N \l__cookingunits_round_number_bool
    \__cookingunits_check_number_after_dot_aux:ww #1 . \q_recursion_tail .
    \q_recursion_stop
  }
\cs_generate_variant:Nn \__cookingunits_check_number_for_rounding:n { V }
\cs_new:Npn \__cookingunits_check_number_after_dot_aux:ww #1 . #2 .
  {
    \quark_if_recursion_tail_stop:n {#2}
    \int_compare:nNnT
      { \tl_count:n {#2} } >
      { \l__cookingunits_round_precision_int }
      { \bool_set_true:N  \l__cookingunits_round_number_bool }
    \use_none_delimit_by_q_recursion_stop:w
  }
\cs_new:Npn \__cookingunits_check_temperature_limit:N #1
  {
    \bool_if:NT \l__cookingunits_pckopt_check_temperature_bool
      {
        \seq_if_in:NVT \l__cookingunits_temperatures_to_check_seq \l__cookingunits_decided_unit_tl
          {
            \fp_compare:vNnT
              { l__cookingunits_ \l__cookingunits_decided_unit_tl _min_fp } > {#1}
              {
                \msg_error:nnxx { cooking-units }
                  { Temperature-too-low }
                  { #1 \space \l__cookingunits_decided_unit_tl }
                  {
                    \fp_use:c { l__cookingunits_ \l__cookingunits_decided_unit_tl _min_fp }
                    \space \l__cookingunits_decided_unit_tl
                  }
              }
          }
      }
  }
\cs_new_nopar:Npn \__cookingunits_if_arrow_grab_until_close_do:nnTF #1#2#3#4
  {
    \str_if_eq:nnTF {#1} { < }
      {
        \tl_if_in:NoT \l__cookingunits_input_allowed_special_signs_tl { < }
          { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
        \tl_clear:N \l__cookingunits_tmpa_tl
        \tl_put_right:Nx \l__cookingunits_tmpa_tl { \tl_to_str:N < }
        \__cookingunits_grab_arrows_for_safety_do_afterwards:nN {#3} #2
      }
      {#4}
  }
\cs_new_nopar:Npn \__cookingunits_grab_arrows_for_safety_do_afterwards:nN #1#2
  {
    \str_if_eq:nnTF {#2} { > }
      {
        \tl_put_right:Nx \l__cookingunits_tmpa_tl { \tl_to_str:N > }
        \exp_last_unbraced:NV #1 \l__cookingunits_tmpa_tl
      }{
        \tl_put_right:Nn \l__cookingunits_tmpa_tl {#2}
        \__cookingunits_grab_arrows_for_safety_do_afterwards:nN {#1}
      }
  }
\NewDocumentCommand \cunum { d<> O{} m O{} m }
  {
    \__cookingunits_if_arrow_grab_until_close_do:nnTF {#3} {#5}
      { \cunum }
      {
        \group_begin:
        \__cookingunits_cunum:nnnnn {#1} {#2} {#3} {#4} {#5}
        \group_end:
      }
  }
\cs_new:Npn \__cookingunits_cunum:nnnnn #1#2#3#4#5
  {
    \__cookingunits_set_cmd_type_to:n { cunum }
    \__cookingunits_do_the_stuff:nnnnnn {#1} {#2} {#3} {#4} {#5} { }
  }
\cs_new:Npn \__cookingunits_cunum_print_correct_unit:
  {
    \tl_if_empty:NF \l__cookingunits_phantom_tl { \phantom { \l__cookingunits_phantom_tl } }
    \tl_use:N \l__cookingunits_value_unit_space_tl
    \__cookingunits_culang_print:nV { unit-symbol } \l__cookingunits_decided_unit_tl
  }
\NewDocumentCommand \cutext { d<> O{} m m }
  {
    \__cookingunits_if_arrow_grab_until_close_do:nnTF {#3} {#4}
      { \cutext }
      {
        \group_begin:
        \bool_set_false:N \l__cookingunits_cutext_uppercase_word_bool
        \__cookingunits_cutext:nnnn {#1} {#2} {#3} {#4}
        \group_end:
      }
  }
\NewDocumentCommand \Cutext { d<> O{} m m }
  {
    \__cookingunits_if_arrow_grab_until_close_do:nnTF {#3} {#4}
      { \Cutext }
      {
        \group_begin:
        \bool_set_true:N \l__cookingunits_cutext_uppercase_word_bool
        \__cookingunits_cutext:nnnn {#1} {#2} {#3} {#4}
        \group_end:
      }
  }
\cs_new:Npn \__cookingunits_cutext:nnnn #1#2#3#4
  {
    \__cookingunits_set_cmd_type_to:n { cCutext }
    \__cookingunits_do_the_stuff:nnnnnn {#1} {#2} {#3} { } {#4} { }
  }
\cs_new_protected:Npn \__cookingunits_cutext_print_input:N #1
  {
    \bool_if:NTF \l__cookingunits_lokal_numeral_bool
      {
        \__cookingunits_cutext_print_input_aux:NV #1 \l__cookingunits_decided_unit_tl
      }
      { \__cookingunits_print_numerical_input:N #1 }
  }
\cs_new_protected:Npn \__cookingunits_cutext_print_input_aux:Nn #1#2
  {
    \int_compare:nNnTF {#1} = { 1 }
      {
        \__cookingunits_culang_one_let:NnT \l__cookingunits_translation_tmpa_tl {#2}
          {
            \bool_if:NT \l__cookingunits_cutext_uppercase_word_bool
              {
                \text_uppercase:x { \tl_head:V \l__cookingunits_translation_tmpa_tl }
                \tl_tail:V
              }
          }
        \l__cookingunits_translation_tmpa_tl
      }{
        \bool_if:NTF \l__cookingunits_cutext_uppercase_word_bool
          { \__cookingunits_print_Numeral:V #1 }
          { \__cookingunits_print_numeral:V #1 }
      }
  }
\cs_generate_variant:Nn \__cookingunits_cutext_print_input_aux:Nn { NV }
\cs_new:Npn \__cookingunits_cutext_print_correct_unitname:
  {
    \bool_if:NTF \l__cookingunits_lokal_numeral_bool
      { \l__cookingunits_cutext_numeral_space_tl }
      { \l__cookingunits_cutext_space_tl }
    \bool_if:NTF \l__cookingunits_cutext_use_single_bool
      { \__cookingunits_culang_print:nV { name } \l__cookingunits_decided_unit_tl }
      { \__cookingunits_culang_print:nV { name-pl }  \l__cookingunits_decided_unit_tl }
  }
\cs_new:Npn \__cookingunits_cutext_check_if_translation_available:
  {
    \bool_if:NTF \l__cookingunits_pckopt_cutext_keep_unit_bool
      { \tl_set_eq:NN \l__cookingunits_curr_unit_tl \l__cookingunits_original_unit_tl }
      { \tl_set_eq:NN \l__cookingunits_curr_unit_tl \l__cookingunits_decided_unit_tl }
    \__cookingunits_culang_unitname_let:NVTF \l__cookingunits_scrap_tl \l__cookingunits_curr_unit_tl
      {
        \bool_if:NT \l__cookingunits_pckopt_cutext_keep_unit_bool
          {
            \tl_set_eq:NN \l__cookingunits_decided_unit_tl \l__cookingunits_original_unit_tl
            \tl_set_eq:NN \l__cookingunits_option_unit_tl \l__cookingunits_original_unit_tl
          }
      }{
        \msg_warning:nnx
          { cooking-units }
          { cutext-no-translation-available }
          \l__cookingunits_curr_unit_tl
        \__cookingunits_set_cmd_type_to:n { cunum }
        \__cookingunits_decide_unit:
      }
  }
\cs_new:Npn \__cookingunits_cutext_post_process_input:NN #1#2
  {
    \__cookingunits_if_parse_and_process_type_equal:nTF { range }
      {
        \__cookingunits_culang_let:nnN { pluraltest } { range } \l__cookingunits_translation_tmpa_tl
        \use:c { __cookingunits_pluraltest_range_ \l__cookingunits_translation_tmpa_tl :NN } #1#2
      }{
        \__cookingunits_culang_let:nnN { pluraltest } { normal } \l__cookingunits_translation_tmpa_tl
        \use:c { __cookingunits_pluraltest_normal_ \l__cookingunits_translation_tmpa_tl :N } #1
      }
    \bool_if:NT \l__cookingunits_lokal_numeral_bool
      {
        \__cookingunits_if_contain_decimals:NNTF #1#2
          { \bool_set_false:N \l__cookingunits_lokal_numeral_bool }
          { \__cookingunits_check_if_integer_can_be_numerals:NN #1#2 }
      }
  }
\cs_new:Npn \__cookingunits_cutext_post_process_fraction_input:NNN #1#2#3
  {
    \__cookingunits_culang_let:nnN { pluraltest } { fraction } \l__cookingunits_translation_tmpa_tl
    \use:c { __cookingunits_pluraltest_fraction_ \l__cookingunits_translation_tmpa_tl :NNN } #1#2#3
  }
\cs_new:Npn \__cookingunits_check_if_integer_can_be_numerals:NN #1#2
  {
    \__cookingunits_if_parse_and_process_type_equal:nTF { range }
      {
        \bool_lazy_all:nF
          {
            { \int_compare_p:nNn {#1} < { \l__cookingunits_print_numerals_below_int } }
            { \int_compare_p:nNn {#2} < { \l__cookingunits_print_numerals_below_int } }
            { \int_compare_p:nNn {#1} > { 0 } }
            { \int_compare_p:nNn {#2} > { 0 } }
          }
          { \bool_set_false:N \l__cookingunits_lokal_numeral_bool }
      }{
        \bool_lazy_and:nnF
          { \int_compare_p:nNn {#1} < { \l__cookingunits_print_numerals_below_int } }
          { \int_compare_p:nNn {#1} > { 0 } }
          { \bool_set_false:N \l__cookingunits_lokal_numeral_bool }
      }
  }
\tl_const:Nx \c__cookingunits_no_unit_marker_tl { \__cookingunits_to_unit:n { __cookingunits_no_unit } }
\prg_new_conditional:Npnn \__cookingunits_if_no_unit_marker:N #1 { TF , F }
  {
    \tl_if_eq:NNTF \c__cookingunits_no_unit_marker_tl #1
      { \prg_return_true: }
      { \prg_return_false: }
  }
\seq_gput_right:NV \g__cookingunits_list_of_defined_units_seq \c__cookingunits_no_unit_marker_tl
\tl_new:c { l__cookingunits_unit_change_ \c__cookingunits_no_unit_marker_tl _tl }
\tl_set:cn { l__cookingunits_unit_change_ \c__cookingunits_no_unit_marker_tl _tl } { 1.0 }
\clist_new:c { l__cookingunits_unit_option_ \c__cookingunits_no_unit_marker_tl _clist }
\NewDocumentCommand \cuam { d<> O{} m }
  {
    \__cookingunits_if_arrow_grab_until_close_do:nnTF {#3} { }
      { \cuam }
      {
        \group_begin:
        \__cookingunits_cuam:nnn {#1} {#2} {#3}
        \group_end:
      }
  }
\cs_new:Npn \__cookingunits_cuam:nnn #1#2#3
  {
    \__cookingunits_set_cmd_type_to:n { cuam }
    \__cookingunits_do_the_stuff:nnnnVn {#1} {#2} {#3} { } \c__cookingunits_no_unit_marker_tl { }
  }
\cs_new_protected:Npn \__cookingunits_cuam_post_process_input:NN #1#2
  {
    \__cookingunits_if_contain_decimals:NNTF #1#2
      { \bool_set_false:N \l__cookingunits_lokal_numeral_bool }
      {
        \bool_if:NT \l__cookingunits_pckopt_use_phrases_bool
          { \__cookingunits_cuam_post_process_input_phrases:NN #1#2 }
        \bool_if:NT \l__cookingunits_lokal_numeral_bool
          { \__cookingunits_check_if_integer_can_be_numerals:NN #1#2 }
      }
  }
\cs_new:Npn \__cookingunits_cuam_post_process_input_phrases:NN #1#2
  {
    \__cookingunits_culang_get_phrase_prop:N \l__cookingunits_phrase_prop
    \tl_if_eq:NNT \c__cookingunits_no_translation_str \l__cookingunits_phrase_prop
      { \use_none_delimit_by_q_stop:w }
    \prop_get:NnN \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq
    \__cookingunits_cuam_post_process_input_phrases_aux:NNN
      #1 \l__cookingunits_tmpa_int \l__cookingunits_phrase_number_tl
    \bool_if:NF \l__cookingunits_lokal_phrase_bool
      { \use_none_delimit_by_q_stop:w }
    \__cookingunits_if_parse_and_process_type_equal:nTF { range }
      {
        \bool_if:NT \l__cookingunits_phrase_negative_bool
          { \use_none_delimit_by_q_stop:w }
        \__cookingunits_cuam_post_process_input_phrases_range:NN
          #2 \l__cookingunits_tmpb_int
        \bool_if:NF \l__cookingunits_lokal_phrase_bool
          { \use_none_delimit_by_q_stop:w }
        \tl_set:NV #1 \l__cookingunits_tmpa_int
        \tl_set:NV #2 \l__cookingunits_tmpb_int
        \__cookingunits_cuam_get_phrase_name:NVN
          \l__cookingunits_phrase_text_tl \l__cookingunits_phrase_number_tl #2
      }{
        \tl_set:NV #1 \l__cookingunits_tmpa_int
        \__cookingunits_cuam_get_phrase_name:NVN
          \l__cookingunits_phrase_text_tl \l__cookingunits_phrase_number_tl #1
      }
     \use_none_delimit_by_q_stop:w \q_stop
  }
\cs_new:Npn \__cookingunits_cuam_post_process_input_phrases_aux:NNN #1#2#3
  {
    \bool_set_false:N \l__cookingunits_lokal_phrase_bool
    \seq_map_inline:Nn \l__cookingunits_phrase_numbers_seq
      {
        \int_compare:nNnF { \int_abs:n {##1} } > {#1}
          {
            \prop_get:NnN \l__cookingunits_phrase_prop { ##1-singlebool } \l_tmpa_tl
            \int_compare:nNnTF { \l_tmpa_tl } = { 1 }
              { \bool_set_true:N \l__cookingunits_phrase_negative_bool }
              {
                \bool_set_false:N \l__cookingunits_phrase_negative_bool
                \tl_set:Nf \l_tmpa_tl { \int_div_truncate:nn {#1} {##1} }
              }
            \int_compare:nNnT { \int_abs:n {##1} * \l_tmpa_tl } = {#1}
              {
                \tl_set_eq:NN #2 \l_tmpa_tl
                \tl_set:Nn #3 {##1}
                \bool_set_true:N \l__cookingunits_lokal_phrase_bool
                \seq_map_break:
              }
          }
      }
  }
\cs_new:Npn \__cookingunits_cuam_post_process_input_phrases_range:NN #1#2
  {
    \int_set:Nn \l_tmpa_int
      {
        \int_div_truncate:nn {#1} { \int_abs:n {\l__cookingunits_phrase_number_tl } }
      }
    \int_compare:nNnTF { \int_abs:n {\l__cookingunits_phrase_number_tl} * \l_tmpa_int } = {#1}
      {
        \int_set_eq:NN #2 \l_tmpa_int
        \bool_set_true:N \l__cookingunits_lokal_phrase_bool
      }{
        \bool_set_false:N \l__cookingunits_lokal_phrase_bool
      }
  }
\cs_new:Npn \__cookingunits_cuam_get_phrase_name:NnN #1#2#3
  {
    \int_compare:nNnTF {#3} = { 1 }
      { \prop_get:NnN \l__cookingunits_phrase_prop {#2} #1 }
      { \prop_get:NnN \l__cookingunits_phrase_prop { #2-pl } #1 }
    \prop_get:NnN \l__cookingunits_phrase_prop { #2-gender } \l__cookingunits_phrase_gender_tl
  }
\cs_generate_variant:Nn \__cookingunits_cuam_get_phrase_name:NnN { NVN }
\cs_new_protected:Npn \__cookingunits_cuam_print_numerical_input:N #1
  {
    \bool_lazy_and:nnTF
      { \l__cookingunits_lokal_phrase_bool }
      { \l__cookingunits_lokal_numeral_bool }
      {
        \__cookingunits_cuam_print_numerical_input_aux:NV #1\l__cookingunits_phrase_number_tl
      }
      { \__cookingunits_print_numerical_input:N #1 }
  }
\cs_new:Npn \__cookingunits_cuam_print_numerical_input_aux:Nn #1#2
  {
    \int_compare:nNnTF {#1} = { 1 }
      {
        \__cookingunits_culang_one_let_by_gender:NVTF
          \l__cookingunits_translation_tmpa_tl \l__cookingunits_phrase_gender_tl
          { \l__cookingunits_translation_tmpa_tl  }
          {
            \__cookingunits_print_numeral:V #1
            \bool_set_false:N \l__cookingunits_lokal_numeral_bool
          }
      }
      { \__cookingunits_print_numeral:V #1 }
  }
\cs_generate_variant:Nn \__cookingunits_cuam_print_numerical_input_aux:Nn { NV }
\cs_new:Npn \__cookingunits_cuam_print_correct_unitphrase:
  {
    \bool_if:NT \l__cookingunits_lokal_phrase_bool
      {
        \l__cookingunits_cuphrase_space_tl
        \l__cookingunits_phrase_text_tl
      }
  }
\cs_new:Npn \cookingunits_print_fraction:nnn #1#2#3
  {
    \group_begin:
    \__cookingunits_set_amount:Nn \l__cookingunits_mixed_fraction_tl {#1}
    \__cookingunits_set_amount:Nn \l__cookingunits_number_tmpa_tl {#2}
    \__cookingunits_set_amount:Nn \l__cookingunits_number_tmpb_tl {#3}
    \__cookingunits_print_fractions:Nnn
      \l__cookingunits_mixed_fraction_tl
      \l__cookingunits_number_tmpa_tl
      \l__cookingunits_number_tmpb_tl
    \group_end:
  }
\cs_new:Npn \cookingunits_print_range:nn #1#2
  {
    \group_begin:
    \__cookingunits_set_cmd_type_to:n { cunum }
    #1
    \__cookingunits_print_range_sign:
    #2
    \group_end:
  }

%% To be deleted. In order to remove error messages.
\NewDocumentCommand \cudefinekeys { m m }
  {
    \bool_set_false:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeys_define:n {#1}
    \__cookingunits_cukeys_prepare_parsing_keys:nn {#1} {#2}
  }
\NewDocumentCommand \cudefinesinglekey { m m }
  {
    \bool_set_true:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeys_define:n {#1}
    \tl_set_rescan:Nno \l__cookingunits_tmpa_tl
      { \char_set_catcode_letter:N \# } {#2}
    \__cookingunits_cukeys_prepare_parsing_keys:nV {#1} \l__cookingunits_tmpa_tl
  }
\cs_new:Npn \__cookingunits_initialice_cukeys_define:n #1
  {
    \__cookingunits_set_state_to:n { normal }
    \seq_clear:N \l__cookingunits_tmpa_seq
    \seq_clear:N \l__cookingunits_tmpb_seq
    \prop_clear:N \l__cookingunits_tmpa_prop
    \tl_set:Nn \l__cookingunits_new_key_base_tl { 1 }
    \__cookingunits_error_if_unit_not_defined:nNT {#1} \l__cookingunits_original_unit_tl
      { \__cookingunits_set_state_to:n { error } }
  }
\NewDocumentCommand \cudefinekeychain { m }
  {
    \bool_set_false:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeychain_define:n {#1}
    \__cookingunits_cukeys_prepare_parsing_keys:n {#1}
  }
\cs_new:Npn \__cookingunits_initialice_cukeychain_define:n #1
  {
    \__cookingunits_cukeychain_get_first_unit_aux:nn #1
      \q_recursion_tail \q_recursion_tail \q_recursion_stop
    \__cookingunits_if_state_equal:nF { error }
      {
        \exp_args:NV \__cookingunits_initialice_cukeys_define:n \l__cookingunits_curr_unit_tl
        \__cookingunits_tl_eval:Nn \l__cookingunits_new_key_base_tl { 1 / (\l__cookingunits_base_tl) }
        \tl_clear:N \l__cookingunits_curr_unit_tl
      }
  }
\cs_new:Npn \__cookingunits_cukeychain_get_first_unit_aux:nn #1#2
  {
    \quark_if_recursion_tail_stop_do:nn {#1}
      { \__cookingunits_set_state_to:n { error } }
    \quark_if_recursion_tail_stop_do:nn {#2}
      {
        \msg_error:nn { cooking-units } { missing-argument }
        \__cookingunits_set_state_to:n { error }
      }
    \tl_set:Nn \l__cookingunits_curr_unit_tl {#1}
    \tl_set:Nn \l__cookingunits_base_tl {#2}
    \use_none_delimit_by_q_recursion_stop:w
    \__cookingunits_cukeychain_get_first_unit_aux:nn
  }
\NewDocumentCommand \cuaddkeys { m m }
  {
    \bool_set_false:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeys_add:n {#1}
    \__cookingunits_cukeys_prepare_parsing_keys:nn {#1} {#2}
  }
\NewDocumentCommand \cuaddtokeys { m m m }
  {
    \bool_set_false:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeys_add:n {#1}
    \tl_set:Nn \l__cookingunits_tmpa_tl { {#2} { \fp_eval:n { 1.0 / (#3) } } }
    \__cookingunits_cukeys_prepare_parsing_keys:nV {#1} \l__cookingunits_tmpa_tl
  }
\NewDocumentCommand \cuaddsinglekeys { m m }
  {
    \bool_set_true:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeys_add:n {#1}
    \tl_set_rescan:Nno \l__cookingunits_tmpa_tl
      { \char_set_catcode_letter:N \# } {#2}
    \__cookingunits_cukeys_prepare_parsing_keys:nV {#1} \l__cookingunits_tmpa_tl
  }
\cs_new:Npn \__cookingunits_initialice_cukeys_add:n #1
  {
    \seq_clear:N \l__cookingunits_tmpa_seq
    \seq_clear:N \l__cookingunits_tmpb_seq
    \__cookingunits_set_state_to:n { normal }
    \__cookingunits_error_if_unit_not_defined:nNT {#1} \l__cookingunits_curr_unit_tl
      {
        \__cookingunits_set_state_to:n { error }
        \use_none_delimit_by_q_stop:w
      }
    \__cookingunits_if_unit_has_a_key:nF {#1}
      {
        \msg_error:nnx { cooking-units } { Key-not-defined } \l__cookingunits_curr_unit_tl
        \__cookingunits_set_state_to:n { error }
        \use_none_delimit_by_q_stop:w
      }
    \tl_set_eq:Nc \l__cookingunits_original_unit_tl { l__cookingunits_base_key_unit_ \l__cookingunits_curr_unit_tl _tl }
    \prop_set_eq:Nc \l__cookingunits_tmpa_prop { l__cookingunits_new_cukeys_ \l__cookingunits_original_unit_tl _prop }
    \prop_get:NnN \l__cookingunits_tmpa_prop {#1} \l__cookingunits_new_key_base_tl
    \prop_get:NnN \l__cookingunits_tmpa_prop { Liste } \l__cookingunits_tmpa_seq
    \prop_get:NnN \l__cookingunits_tmpa_prop { single } \l__cookingunits_tmpa_tl
    \int_compare:nNnF { \l__cookingunits_single_key_bool } = { \l__cookingunits_tmpa_tl }
      {
        \msg_error:nn { cooking-units } { Adding-single-to-multi-key-or-vice-verca }
        \__cookingunits_set_state_to:n { error }
      }
    \use_none_delimit_by_q_stop:w \q_stop
  }
\cs_generate_variant:Nn \__cookingunits_initialice_cukeys_add:n { V }
\NewDocumentCommand \cuaddtokeychain { m }
  {
    \bool_set_false:N \l__cookingunits_single_key_bool
    \__cookingunits_initialice_cukeys_keychain_add:n {#1}
    \__cookingunits_cukeys_prepare_parsing_keys:n {#1}
  }
\cs_new:Npn \__cookingunits_initialice_cukeys_keychain_add:n #1
  {
    \__cookingunits_cukeys_keychain_get_first_valid_unit:n {#1}
    \__cookingunits_if_state_equal:nF { error }
      {
        \__cookingunits_initialice_cukeys_add:V \l__cookingunits_curr_unit_tl
        \__cookingunits_tl_eval:Nn \l__cookingunits_new_key_base_tl { (\l__cookingunits_new_key_base_tl) / (\l__cookingunits_base_tl) }
      }
  }
\cs_new:Npn \__cookingunits_cukeys_keychain_get_first_valid_unit:n #1
  {
    \__cookingunits_cukeys_keychain_get_first_valid_unit_aux:nn #1
      \q_recursion_tail \q_recursion_tail \q_recursion_stop
  }
\cs_new:Npn \__cookingunits_cukeys_keychain_get_first_valid_unit_aux:nn #1#2
  {
    \quark_if_recursion_tail_stop_do:nn {#1}
      {
        \msg_error:nn { cooking-units } { Key-chain-unit-not-found }
        \__cookingunits_set_state_to:n { error }
      }
    \quark_if_recursion_tail_stop_do:nn {#2}
      {
        \msg_error:nn { cooking-units } { missing-argument }
        \__cookingunits_set_state_to:n { error }
      }
    \__cookingunits_if_unit_has_a_key:nT  {#1}
      {
        \__cookingunits_error_if_unit_not_defined:nNT {#1} \l__cookingunits_curr_unit_tl
          { \__cookingunits_set_state_to:n { error } }
        \tl_set_eq:NN \l__cookingunits_original_unit_tl \l__cookingunits_curr_unit_tl
        \tl_set:Nn \l__cookingunits_base_tl {#2}
        \use_none_delimit_by_q_recursion_stop:w
      }
    \__cookingunits_cukeys_keychain_get_first_valid_unit_aux:nn
  }
\cs_new:Npn \__cookingunits_cukeys_prepare_parsing_keys:nn #1#2
  {
    \__cookingunits_cukeys_prepare_parsing_keys:n { {#1} { 1.0 } #2 }
  }
\cs_new:Npn \__cookingunits_cukeys_prepare_parsing_keys:n #1
  {
    \__cookingunits_cukeys_parse_keys:n {#1}
    \bool_lazy_or:nnF
      { \int_compare_p:nNn \l__cookingunits_nr_of_units_int = 0 }
      { \__cookingunits_if_state_equal_p:n { error } }
      {
        \prop_gclear:N \g__cookingunits_master_changer_prop
        \__cookingunits_cukeys_prepare_lists:N \l__cookingunits_original_unit_tl
        \__cookingunits_new_cukeys_create_keys:V \l__cookingunits_original_unit_tl
      }
  }
\cs_generate_variant:Nn \__cookingunits_cukeys_prepare_parsing_keys:nn { nV }
\cs_new:Npn \__cookingunits_cukeys_parse_keys:n #1
  {
    \int_zero:N \l__cookingunits_nr_of_units_int
    \__cookingunits_cukeys_parse_keys_aux:nn #1
      \q_recursion_tail \q_recursion_tail \q_recursion_stop
  }
\cs_new:Npn \__cookingunits_cukeys_parse_keys_aux:nn #1#2
  {
    \quark_if_recursion_tail_stop:n {#1}
    \quark_if_recursion_tail_stop_do:nn {#2}
      {
        \msg_error:nn { cooking-units } { missing-argument }
        \__cookingunits_set_state_to:n { error }
      }
    \__cookingunits_error_if_unit_not_defined:nNT {#1} \l__cookingunits_option_unit_tl
      { \__cookingunits_set_state_to:n { error } }
    \tl_set:Nn \l__cookingunits_tmpb_tl {#2}
    \tl_if_in:NVT \l__cookingunits_tmpb_tl \g__cookingunits_input_str_hash_one_tl
      {
        \bool_if:NTF \l__cookingunits_single_key_bool
          { \tl_replace_all:NVn \l__cookingunits_tmpb_tl \g__cookingunits_input_str_hash_one_tl { \l__cookingunits_tmpa_fp } }
          {
            \msg_error:nnx { cooking-units } { formula-in-non-singlekeys } \l__cookingunits_tmpb_tl
            \__cookingunits_set_state_to:n { error }
          }
      }
    \__cookingunits_if_state_equal:nF { error }
      {
        \int_incr:N \l__cookingunits_nr_of_units_int
        \bool_if:NF \l__cookingunits_single_key_bool
          { \__cookingunits_tl_eval:Nn \l__cookingunits_tmpb_tl { (\l__cookingunits_tmpb_tl) * (\l__cookingunits_new_key_base_tl) } }
        \seq_if_in:NVF \l__cookingunits_tmpa_seq \l__cookingunits_option_unit_tl
          { \seq_put_right:NV \l__cookingunits_tmpa_seq \l__cookingunits_option_unit_tl }
        \prop_put:NnV \l__cookingunits_tmpa_prop {#1} \l__cookingunits_tmpb_tl
      }
    \__cookingunits_cukeys_parse_keys_aux:nn
  }
\cs_new:Npn \__cookingunits_cukeys_prepare_lists:N #1
  {
    \prop_clear_new:c { l__cookingunits_new_cukeys_ #1 _prop }
    \prop_set_eq:cN { l__cookingunits_new_cukeys_ #1 _prop } \l__cookingunits_tmpa_prop
    \prop_put:cnV { l__cookingunits_new_cukeys_ #1 _prop } { Liste } \l__cookingunits_tmpa_seq
    \prop_put:cnV { l__cookingunits_new_cukeys_ #1 _prop } { single } \l__cookingunits_single_key_bool
    \tl_set:cn { l__cookingunits_unit_change_ #1 _tl } { 1 }
    \tl_set_eq:cN { l__cookingunits_base_key_unit_ #1 _tl } #1
    \bool_if:NF \l__cookingunits_single_key_bool
      {
        \seq_map_inline:Nn \l__cookingunits_tmpa_seq
          {
            \tl_set_eq:cN { l__cookingunits_base_key_unit_ ##1 _tl } #1
            \tl_set:cn { l__cookingunits_unit_change_ ##1 _tl } { 1 }
          }
      }
  }
\cs_new:Npn \__cookingunits_new_cukeys_create_keys:n #1
  {
    \clist_set_from_seq:NN \l__cookingunits_tmpa_clist \l__cookingunits_tmpa_seq
    \bool_if:NTF \l__cookingunits_single_key_bool
      {
        \__cookingunits_new_cukeys_define_key:nVn
           {#1} \l__cookingunits_tmpa_clist {#1}
      }{
        \seq_map_inline:Nn \l__cookingunits_tmpa_seq
          {
            \__cookingunits_new_cukeys_define_key:nVn
               {##1} \l__cookingunits_tmpa_clist {#1}
          }
      }
  }
\cs_generate_variant:Nn \__cookingunits_new_cukeys_create_keys:n { V }
\cs_new:Npn \__cookingunits_new_cukeys_define_key:nnn #1#2#3
  {
    \__cookingunits_if_unit_has_a_key:nF {#1}
      { \seq_put_right:Nn \l__cookingunits_list_of_defined_keys_seq {#1} }
    \keys_define:nn { cooking-units }
      {
        #1 .choices:nn =
          {#2}
          { \__cookingunits_change_unit_from_to:nVn {#1} \l_keys_choice_tl {#3} } ,
        #1 / unknown .code:n=
          {
            \seq_set_split:Nnn \l_tmpa_seq { , } {#2}
            \msg_error:nnxxx
              { cooking-units }
              { key-choice-unknown }
              {#1}
              {##1}
              { \__cookingunits_seq_use_msg:N \l_tmpa_seq }
          } ,
         #1 .default:n = {#1} ,
         #1 .groups:n = { change-unit }
      }
  }
\cs_generate_variant:Nn \__cookingunits_new_cukeys_define_key:nnn { nVn }
\cs_new:Npn \__cookingunits_change_unit_from_to:nnn #1#2#3
  {
    \prop_put:Nnn \l__cookingunits_change_unit_prop {#1} {#2}
    \prop_get:NncF
      \g__cookingunits_master_changer_prop
      { #1 ~->~ #2 }
      { l__cookingunits_unit_change_ #1_tl }
      {
        \__cookingunits_cukeys_calculate_change_value:nnn {#1} {#2} {#3}
        \prop_gput:Nnv \g__cookingunits_master_changer_prop
          { #1 ~->~ #2 }
          { l__cookingunits_unit_change_ #1 _tl }
      }
  }
\cs_generate_variant:Nn \__cookingunits_change_unit_from_to:nnn { nVn }
\cs_new:Npn \__cookingunits_cukeys_calculate_change_value:nnn #1 #2 #3
  {
    \str_if_eq:nnTF {#1} {#3}
      {
        \prop_get:cnc { l__cookingunits_new_cukeys_ #1 _prop } {#2} { l__cookingunits_unit_change_ #1 _tl }
      }{
        \prop_set_eq:Nc \l__cookingunits_tmpa_prop { l__cookingunits_new_cukeys_ #3 _prop }
        \__cookingunits_tl_eval:cn { l__cookingunits_unit_change_ #1 _tl }
          {
            ( \prop_item:Nn \l__cookingunits_tmpa_prop {#2} ) /
            ( \prop_item:Nn \l__cookingunits_tmpa_prop {#1} )
          }
      }
  }
\cs_generate_variant:Nn \__cookingunits_cukeys_calculate_change_value:nnn { VVV }
\NewDocumentCommand \declarecookingunit { o m }
  {
    \__cookingunits_if_unit_defined:nNTF {#2} \l__cookingunits_original_unit_tl
      { \msg_info:nnx { cooking-units } { redefine-unit } { \l__cookingunits_original_unit_tl } }
      { \__cookingunits_new_cooking_unit:V \l__cookingunits_original_unit_tl }
    \__cookingunits_set_cooking_unit:nnV {#1} {#2} \l__cookingunits_original_unit_tl
  }
\NewDocumentCommand \newcookingunit { o m }
  {
    \__cookingunits_if_unit_defined:nNTF {#2} \l__cookingunits_original_unit_tl
      { \msg_error:nnV { cooking-units } { unit-already-defined } \l__cookingunits_original_unit_tl }
      {
        \__cookingunits_new_cooking_unit:V \l__cookingunits_original_unit_tl
        \__cookingunits_set_cooking_unit:nnV {#1} {#2} \l__cookingunits_original_unit_tl
      }
  }
\NewDocumentCommand \providecookingunit { o m }
  {
    \__cookingunits_if_unit_defined:nNT {#2} \l__cookingunits_original_unit_tl
      {
        \__cookingunits_new_cooking_unit:V \l__cookingunits_original_unit_tl
        \__cookingunits_set_cooking_unit:nnV {#1} {#2} \l__cookingunits_original_unit_tl
      }
  }
\cs_new:Npn \__cookingunits_new_cooking_unit:n #1
  {
    \tl_map_inline:nn {#1}
      {
        \tl_if_in:NnT \l__cookingunits_unit_letter_not_allowed_tl {##1}
          { \msg_error:nnn { cooking-units } { character-not-allowed } {#1} }
      }
    \seq_gput_right:Nn \g__cookingunits_list_of_defined_units_seq {#1}
    \tl_new:c { l__cookingunits_unit_change_ #1 _tl }
    \tl_new:c { l__cookingunits_base_key_unit_ #1 _tl }
    \tl_new:c { l__cookingunits_default_unit_ #1 _tl }
    \clist_new:c { l__cookingunits_unit_option_ #1 _clist }
    \tl_set:cn { l__cookingunits_unit_change_ #1 _tl } { 1 }
    \keys_define:nn { cooking-units }
      {
        set-unit-hook-#1 .code:n =  { \__cookingunits_set_options_for:nn {#1} {##1} } ,
        add-unit-hook-#1 .code:n = { \__cookingunits_add_options_for:nn {#1} {##1} },
        set-option-for-#1 .meta:n = { set-unit-hook-#1 = {##1} } ,
        add-option-for-#1 .meta:n = { add-unit-hook-#1 = {##1} } ,
      }
  }
\cs_generate_variant:Nn \__cookingunits_new_cooking_unit:n { V }
\cs_new:Npn \__cookingunits_set_cooking_unit:nnn #1#2#3
  {
    \__cookingunits_set_cooking_unit_base_translation:n {#3}
    \bool_set_false:N \l__cookingunits_symbol_was_set_by_key_bool
    \bool_set_false:N \l__cookingunits_contains_valid_key_bool
    \IfNoValueF {#1}
      {
        \tl_if_head_is_group:nF {#1}
          { \keys_set:nn { cooking-units / definition } {#1} }
      }
    \bool_if:NF \l__cookingunits_symbol_was_set_by_key_bool
      {
        \IfNoValueTF {#1}
          { \tl_set:cn { l__cookingunits_default_unit_ #3 _tl } {#2} }
          {
            \bool_if:NTF \l__cookingunits_contains_valid_key_bool
              { \tl_set:cn { l__cookingunits_default_unit_ #3 _tl } {#2} }
              { \tl_set:cn { l__cookingunits_default_unit_ #3 _tl } {#1} }
          }
      }
    \__cookingunits_culang_def_base:nnv { unit-symbol } {#3} { l__cookingunits_default_unit_ #3 _tl }
  }
\cs_generate_variant:Nn \__cookingunits_set_cooking_unit:nnn { nnV }
\cs_new:Npn \__cookingunits_set_cooking_unit_base_translation:n #1
  {
    \__cookingunits_culang_def_base:nnn { name } {#1} \c__cookingunits_no_translation_str
    \__cookingunits_culang_def_base:nnn { name-pl } {#1} \c__cookingunits_no_translation_str
    \__cookingunits_culang_def_base:nnn { gender } {#1} { m }
  }
\NewDocumentCommand \declarecookingderivatives { m m m m }
  {
    \__cookingunits_declare_cooking_derivative:nnnn {#1} {#2} {#3} {#4}
  }
\cs_new:Npn \__cookingunits_declare_cooking_derivative:nnnn #1#2#3#4
  {
    \seq_clear:N \l__cookingunits_list_of_units_seq
    \__cookingunits_set_state_to:n { normal }
    \clist_map_inline:nn {#1}
      {
        \__cookingunits_if_unit_defined:nNTF {##1} \l__cookingunits_tmpa_tl
          {
            \__cookingunits_if_unit_has_a_key:VTF \l__cookingunits_tmpa_tl
              { \seq_put_right:NV \l__cookingunits_list_of_units_seq \l__cookingunits_tmpa_tl }
              {
                \tl_show:n { Error-no-key-defined } {##1}
                \__cookingunits_set_state_to:n { error }
              }
          } { \__cookingunits_set_state_to:n { error } }
      }
   \__cookingunits_if_state_equal:nT { error }
     { \use_none_delimit_by_q_recursion_stop:w }
    \int_set:Nn \l__cookingunits_nr_of_units_int { \seq_count:N \l__cookingunits_list_of_units_seq }
   \cs_generate_from_arg_count:NNnn \__cookingunits_create_unit:w \cs_set:Npn
     { \l__cookingunits_nr_of_units_int }
     {
       \seq_gpush:Nn \g__cookingunits_stored_derived_unit_symbol_seq {#2}
       \seq_gpush:Nn \g__cookingunits_stored_derived_unit_print_seq {#4}
     }
   \cs_generate_from_arg_count:NNnn \__cookingunits_create_formula:w \cs_set:Npn
     { \l__cookingunits_nr_of_units_int }
     {
       \seq_gpush:Nn \g__cookingunits_stored_derived_formula_seq {#3}
     }
    \__cookingunits_prepare_sequence_loop:
    \__cookingunits_step_loop_start:n { }
    \seq_get_right:NN \g__cookingunits_stored_derived_unit_symbol_seq \l__cookingunits_curr_unit_tl
    \seq_map_inline:Nn \g__cookingunits_stored_derived_unit_symbol_seq
      {
        \seq_pop:NN \g__cookingunits_stored_derived_formula_seq \l__cookingunits_tmpb_tl
        \prop_put:NnV \l__cookingunits_derived_units_prop {##1} \l__cookingunits_tmpb_tl
        \seq_pop:NN \g__cookingunits_stored_derived_unit_print_seq \l__cookingunits_tmpa_tl
        \exp_args:NNx \declarecookingunit  [ {symbol={\l__cookingunits_tmpa_tl}} ] {##1}
        \tl_set_eq:cN { l__cookingunits_base_key_unit_ ##1 _tl } \l__cookingunits_curr_unit_tl
      }
   \seq_gclear:N \g__cookingunits_stored_derived_unit_symbol_seq
   \seq_gclear:N \g__cookingunits_stored_derived_unit_print_seq
   \seq_gclear:N \g__cookingunits_stored_derived_formula_seq
    \cs_undefine:N \__cookingunits_create_unit:w
    \cs_undefine:N \__cookingunits_create_formula:w
    \use_none_delimit_by_q_recursion_stop:w
    \q_recursion_stop
  }
\cs_new:Npn \__cookingunits_prepare_sequence_loop:
  {
    \seq_map_indexed_inline:Nn \l__cookingunits_list_of_units_seq
      {
        \prop_clear_new:c { l__cookingunits_keys_ ##1 _prop }
        \seq_clear_new:c { l__cookingunits_list_ ##1 _seq }
        \tl_set_eq:Nc \l__cookingunits_curr_unit_tl { l__cookingunits_base_key_unit_ ##2 _tl }
        \prop_set_eq:cc { l__cookingunits_keys_ ##1 _prop }
          { l__cookingunits_new_cukeys_ \l__cookingunits_curr_unit_tl _prop }
        \prop_get:cnc { l__cookingunits_keys_ ##1 _prop } { Liste } { l__cookingunits_list_ ##1 _seq }
      }
  }
\cs_new:Npn \__cookingunits_step_loop_start:n #1
  {
    \tl_clear:N \l__cookingunits_stored_units_tl
    \tl_clear:N \l__cookingunits_stored_formula_tl
    \int_set:Nn \l__cookingunits_depth_int { 1 }
    \seq_map_function:cN
      { l__cookingunits_list_ \int_use:N \l__cookingunits_depth_int _seq } \__cookingunits_seq_recursive_loop_function:n
  }
\cs_new:Npn \__cookingunits_seq_recursive_loop_function:n #1
  {
    \group_begin:
    \tl_put_right:Nn \l__cookingunits_stored_units_tl { {#1} }
    \tl_set_eq:Nc \l__cookingunits_original_unit_tl { l__cookingunits_base_key_unit_ #1 _tl }
    \tl_put_right:Nx \l__cookingunits_stored_formula_tl
      { { (
        \exp_not:N \prop_item:Nn
        \exp_not:c { l__cookingunits_new_cukeys_ \l__cookingunits_original_unit_tl _prop } {#1}
      ) } }
    \int_compare:nNnTF { \l__cookingunits_depth_int } = { \l__cookingunits_nr_of_units_int }
      {
        \exp_after:wN \__cookingunits_create_unit:w \l__cookingunits_stored_units_tl
        \exp_after:wN \__cookingunits_create_formula:w \l__cookingunits_stored_formula_tl
      }{
        \int_incr:N \l__cookingunits_depth_int
        \seq_map_function:cN
          { l__cookingunits_list_ \int_use:N \l__cookingunits_depth_int _seq } \__cookingunits_seq_recursive_loop_function:n
      }
    \group_end:
  }
\keys_define:nn { cooking-units }
  {
    unknown .code:n =
      {
        \__cookingunits_if_key_ais_derived_unit:VTF \l_keys_key_str
          { \__cookingunits_convert_derived_unit:Vn \l_keys_key_str {#1} }
          {
            \msg_error:nnxx { cooking-units } { key-unknown }
              { \l_keys_path_str } { cooking-units }
          }
      }
  }
\prg_new_conditional:Npnn \__cookingunits_if_key_ais_derived_unit:n #1 { TF }
  {
    \tl_if_exist:cTF { l__cookingunits_base_key_unit_ #1 _tl }
      { \prg_return_true: }
      { \prg_return_false: }
  }
\cs_generate_variant:Nn \__cookingunits_if_key_ais_derived_unit:nTF { V }
\cs_new:Npn \__cookingunits_convert_derived_unit:nn #1#2
  {
    \tl_if_eq:ccTF
      { l__cookingunits_base_key_unit_ #1 _tl }
      { l__cookingunits_base_key_unit_ #2 _tl }
      {
        \prop_get:NnN \l__cookingunits_derived_units_prop {#1} \l__cookingunits_tmpa_tl
        \prop_get:NnN \l__cookingunits_derived_units_prop {#2} \l__cookingunits_tmpb_tl
        \prop_put:Nnn \l__cookingunits_change_unit_prop {#1} {#2}
        \__cookingunits_tl_eval:cn { l__cookingunits_unit_change_ #1 _tl }
          {
            (\l__cookingunits_tmpb_tl) / (\l__cookingunits_tmpa_tl)
          }
        \prop_gput:Nnv \g__cookingunits_master_changer_prop
          { #1 ~->~ #2 }
          { l__cookingunits_unit_change_ #1 _tl }
      }{
        \msg_error:nnnn { cooking-units } { key-no-knows-value } {#1} {#2}
      }
  }
\cs_generate_variant:Nn \__cookingunits_convert_derived_unit:nn { V }
\tl_new:N \l__cookingunits_sanitise_tl
\cs_new_protected:Npn \__cookingunits_sanitise_aux:w #1 \q_mark
  { \tl_set:Nn \l__cookingunits_sanitise_tl {#1} }
\group_begin:
  \char_set_catcode_active:n { `\< }
  \char_set_catcode_active:n { `\> }
  \cs_new:Npn \__cookingunits_sanitize_open_arrow:
    {
      \exp_after:wN \__cookingunits_sanitize_open_arrow_auxi:w \l__cookingunits_sanitise_tl
        \q_mark < \q_nil <
      \exp_after:wN \__cookingunits_sanitise_aux:w \l__cookingunits_sanitise_tl
    }
  \cs_new_protected:Npn \__cookingunits_sanitize_open_arrow_auxi:w #1 <
    {
      \tl_set:Nn \l__cookingunits_sanitise_tl {#1}
      \__cookingunits_sanitize_open_arrow_auxii:w
    }
  \cs_new_protected:Npn \__cookingunits_sanitize_open_arrow_auxii:w #1 <
    {
      \quark_if_nil:nF {#1}
        {
          \tl_set:Nx \l__cookingunits_sanitise_tl
            {
              \exp_not:V \l__cookingunits_sanitise_tl
              \token_to_str:N <
              \exp_not:n {#1}
            }
          \exp_after:wN \__cookingunits_sanitize_open_arrow_auxii:w
        }
    }
  \cs_new:Npn \__cookingunits_sanitize_close_arrow:
    {
      \exp_after:wN \__cookingunits_sanitize_close_arrow_auxi:w \l__cookingunits_sanitise_tl
        \q_mark > \q_nil >
      \exp_after:wN \__cookingunits_sanitise_aux:w \l__cookingunits_sanitise_tl
    }
  \cs_new_protected:Npn \__cookingunits_sanitize_close_arrow_auxi:w #1 >
    {
      \tl_set:Nn \l__cookingunits_sanitise_tl {#1}
      \__cookingunits_sanitize_close_arrow_auxii:w
    }
  \cs_new_protected:Npn \__cookingunits_sanitize_close_arrow_auxii:w #1 >
    {
      \quark_if_nil:nF {#1}
        {
          \tl_set:Nx \l__cookingunits_sanitise_tl
            {
              \exp_not:V \l__cookingunits_sanitise_tl
              \token_to_str:N >
              \exp_not:n {#1}
            }
          \exp_after:wN \__cookingunits_sanitize_close_arrow_auxii:w
        }
    }
\group_end:
\cs_new_protected:Npn \__cookingunits_sanitize_arrows:n #1
  {
    \tl_set:Nn \l__cookingunits_sanitise_tl {#1}
    \__cookingunits_sanitize_open_arrow:
    \__cookingunits_sanitize_close_arrow:
  }
\NewDocumentCommand \cudefinename { m m }
  {
    \tl_set:Nn \l__cookingunits_language_tl {#1}
    \__cookingunits_sanitize_arrows:n {#2}
    \exp_after:wN
    \__cookingunits_parse_definename_start_cycle: \l__cookingunits_sanitise_tl
      \q_recursion_tail \q_recursion_tail \q_recursion_stop
  }
\cs_new:Npn \__cookingunits_parse_definename_start_cycle:
  {
    \__cookingunits_set_state_to:n { normal }
    \tl_clear:N \l__cookingunits_curr_unit_tl
    \prop_clear:N \l__cookingunits_tmpa_prop
    \bool_set_false:N \l__cookingunits_tmpa_bool
    \__cookingunits_parse_definename_unit:n
  }
\cs_new:Npn \__cookingunits_parse_definename_unit:n #1
  {
    \quark_if_recursion_tail_stop:n {#1}
    \seq_if_in:NnTF \g__cookingunits_allowed_special_keys_seq {#1}
      {
        \__cookingunits_set_unit:Nn \l__cookingunits_curr_unit_tl {#1}
        \bool_set_true:N \l__cookingunits_tmpa_bool
      }{
        \__cookingunits_error_if_unit_not_defined:nNT {#1} \l__cookingunits_curr_unit_tl
          { \__cookingunits_set_state_to:n { error } }
      }
    \peek_remove_spaces:n
      {
        \peek_meaning:NTF [
          { \__cookingunits_parse_definename_optional_unitsymbol:w }
          { \__cookingunits_parse_definename_singular:n }
      }
  }
\cs_new:Npn \__cookingunits_parse_definename_optional_unitsymbol:w [#1]
  {
    \bool_if:NTF \l__cookingunits_tmpa_bool
      {
        \__cookingunits_set_state_to:n { error }
        \msg_error:nnxn { cooking-units } { symbol-and-special-keys-error }
          \l__cookingunits_curr_unit_tl {#1}
      }
      { \prop_put:Nnn \l__cookingunits_tmpa_prop { unit-symbol } {#1} }
    \__cookingunits_parse_definename_singular:n
  }
\cs_new:Npn \__cookingunits_parse_definename_singular:n #1
  {
    \quark_if_recursion_tail_stop_do:nn {#1}
      { \msg_error:nn { cooking-units } { missing-argument } }
    \prop_put:Nnn \l__cookingunits_tmpa_prop { name } {#1}
    \peek_remove_spaces:n
      {
        \peek_meaning:NTF [
          { \__cookingunits_parse_definename_optional_plural:w }
          { \__cookingunits_parse_definename_optional_plural:w [#1] }
      }
  }
\cs_new:Npn \__cookingunits_parse_definename_optional_plural:w [#1]
  {
    \prop_put:Nnn \l__cookingunits_tmpa_prop { name-pl } {#1}
    \peek_remove_spaces:n
      {
        \peek_meaning:NTF <
          { \__cookingunits_parse_definename_optional_gender:w  }
          { \__cookingunits_parse_definename_optional_gender:w <m> }
      }
  }
\cs_new:Npn \__cookingunits_parse_definename_optional_gender:w <#1>
  {
    \__cookingunits_if_gender_error:nT {#1}
      { \__cookingunits_set_state_to:n { error } }
    \prop_put:Nnn \l__cookingunits_tmpa_prop { gender } {#1}
    \__cookingunits_parse_name_finish_cycle_and_start_new:VV
      \l__cookingunits_language_tl \l__cookingunits_curr_unit_tl
  }
\cs_new:Npn \__cookingunits_parse_name_finish_cycle_and_start_new:nn #1#2
  {
    \__cookingunits_if_state_equal:nT { normal }
      {
        \prop_map_inline:Nn \l__cookingunits_tmpa_prop
          { \__cookingunits_culang_def_for:nnnn {#1} {##1} {#2} {##2} }
      }
    \__cookingunits_parse_definename_start_cycle:
  }
\cs_generate_variant:Nn \__cookingunits_parse_name_finish_cycle_and_start_new:nn { VV }
\__cookingunits_culang_def_base:nnn { pluraltest } { normal } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { pluraltest } { range } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { pluraltest } { fraction } { \c__cookingunits_no_translation_str }
\cs_set:cpn { __cookingunits_pluraltest_normal_ \c__cookingunits_no_translation_str :N } #1
  {
    \fp_compare:nNnTF {#1} = { 1.0 }
      { \bool_set_true:N  } { \bool_set_false:N }
    \l__cookingunits_cutext_use_single_bool
  }
\cs_set:cpn { __cookingunits_pluraltest_range_ \c__cookingunits_no_translation_str :NN } #1#2
  {
    \fp_compare:nNnTF {#2} = { 1.0 }
      { \bool_set_true:N  } { \bool_set_false:N }
    \l__cookingunits_cutext_use_single_bool
  }
\cs_set:cpn { __cookingunits_pluraltest_fraction_ \c__cookingunits_no_translation_str :NNN } #1#2#3
  {
    \tl_if_empty:NTF #1
      { \fp_compare:nNnTF {#2} = { 1.0 } } { \use_ii:nn }
      { \bool_set_true:N  } { \bool_set_false:N }
    \l__cookingunits_cutext_use_single_bool
  }
\cs_new:Npn \__cookingunits_pluraltest_define:nn #1#2
  {
    \__cookingunits_culang_def_for:nnnn {#1} { pluraltest } { normal } {#1}
    \cs_set:cpn { __cookingunits_pluraltest_normal_ #1 :N } ##1 {#2}
  }
\cs_new:Npn \__cookingunits_pluraltest_define_range:nn #1#2
  {
    \__cookingunits_culang_def_for:nnnn {#1} { pluraltest } { range } {#1}
    \cs_set:cpn { __cookingunits_pluraltest_range_ #1 :NN } ##1##2 {#2}
  }
\cs_new:Npn \__cookingunits_pluraltest_define_fraction:nn #1#2
  {
    \__cookingunits_culang_def_for:nnnn {#1} { pluraltest } { fraction } {#1}
    \cs_set:cpn { __cookingunits_pluraltest_fraction_ #1 :NNN } ##1##2##3 {#2}
  }
\__cookingunits_pluraltest_define:nn { French }
  {
    \fp_compare:nNnTF { \fp_abs:n {#1} } < { 2.0 }
      { \bool_set_true:N } { \bool_set_false:N }
    \l__cookingunits_cutext_use_single_bool
  }
\__cookingunits_pluraltest_define_range:nn { French }
  {
    \fp_compare:nNnTF { \fp_abs:n {#2} } < { 2.0 }
      { \bool_set_true:N } { \bool_set_false:N }
    \l__cookingunits_cutext_use_single_bool
  }
\__cookingunits_pluraltest_define_fraction:nn { French }
  {
    \quark_if_nil:NTF #1
      { \fp_compare:nNnTF { #2/#3 } < { 2.0 } }
      { \fp_compare:nNnTF { #1 + #2/#3 } < { 2.0 } }
      { \bool_set_true:N } { \bool_set_false:N }
    \l__cookingunits_cutext_use_single_bool
  }
\NewDocumentCommand \cudefinesymbol { m m }
  {
    \tl_set:Nn \l__cookingunits_language_tl {#1}
    \__cookingunits_cuprint_define_printed_unit:nn #2
    \q_recursion_tail \q_recursion_tail \q_recursion_stop
  }
\cs_new:Npn \__cookingunits_cuprint_define_printed_unit:nn #1#2
  {
    \quark_if_recursion_tail_stop:n {#1}
    \quark_if_recursion_tail_stop_do:nn {#2}
      { \msg_error:nn { cooking-units } { missing-argument } }
    \seq_if_in:NnTF \g__cookingunits_allowed_special_keys_seq {#1}
      { \__cookingunits_culang_def_for:Vnnn \l__cookingunits_language_tl { name } }
      {
        \__cookingunits_error_if_unit_not_defined:nTF {#1}
          { \use_none:nn }
          { \__cookingunits_culang_def_for:Vnnn \l__cookingunits_language_tl { unit-symbol } }
      }
     {#1} {#2}
    \__cookingunits_cuprint_define_printed_unit:nn
  }
\__cookingunits_culang_def_base:nnn { phrase } { phrase-prop } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { phrase } { phrase-lang } { Humphry-Drumphy }
\cs_new:Npn \__cookingunits_culang_get_phrase_prop:N #1
  {
    \__cookingunits_culang_let:nnN { phrase } { phrase-lang } \l__cookingunits_language_tl
    \prop_if_exist:cTF { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop }
      {
        \prop_set_eq:Nc #1 { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop }
      }
      { \tl_set_eq:NN #1 \c__cookingunits_no_translation_str  }
  }
\cs_new:Npn \__cookingunits_culang_get_phrase_prop_for:nN #1#2
  {
    \prop_set_eq:Nc #2 { l__cookingunits_ #1 _phrase_prop }
  }
\NewDocumentCommand \cudefinephrase { m m }
  {
    \__cookingunits_new_cuphrase_add:nn {#1} {#2}
  }
\cs_new:Npn \__cookingunits_new_cuphrase_add:nn #1#2
  {
    \tl_set:Nn \l__cookingunits_language_tl {#1}
    \__cookingunits_culang_if_translation_exists_for:VnnTF \l__cookingunits_language_tl
      { phrase } { phrase-lang }
      {
        \prop_set_eq:Nc \l__cookingunits_phrase_prop { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop }
        \prop_get:NnN \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq
      }{
        \prop_new:c { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop }
        \prop_clear:N \l__cookingunits_phrase_prop
        \seq_clear:N \l__cookingunits_phrase_numbers_seq
      }
    \__cookingunits_sanitize_arrows:n {#2}
    \__cookingunits_parse_phrase:V \l__cookingunits_sanitise_tl
    \__cookingunits_new_cuphrase_sort_sequence:N \l__cookingunits_phrase_numbers_seq
    \prop_put:NnV \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq
    \prop_set_eq:cN { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop } \l__cookingunits_phrase_prop
    \__cookingunits_culang_def_for:VnnV
      \l__cookingunits_language_tl { phrase } { phrase-lang } \l__cookingunits_language_tl
  }
\cs_new:Npn \__cookingunits_parse_phrase:n #1
  {
    \__cookingunits_parse_phrase_start_cycle: #1
      \q_recursion_tail \q_recursion_tail \q_recursion_stop
  }
\cs_generate_variant:Nn \__cookingunits_parse_phrase:n { V }
\cs_new:Npn \__cookingunits_parse_phrase_start_cycle:
  {
    \__cookingunits_set_state_to:n { normal }
    \bool_set_false:N \l__cookingunits_tmpa_bool
    \tl_clear:N \l__cookingunits_curr_unit_tl
    \prop_clear:N \l__cookingunits_tmpa_prop
    \__cookingunits_parse_stuff_mandatories_plus_star:nn
  }
\cs_new:Npn \__cookingunits_parse_stuff_mandatories_plus_star:nn #1#2
  {
    \quark_if_recursion_tail_stop:n {#1}
    \quark_if_recursion_tail_stop_do:nn {#2}
      { \msg_error:nn { cooking-units } { missing-argument } }
    \str_if_eq:nnTF {#2} { * }
      {
        \bool_set_true:N \l__cookingunits_tmpa_bool
        \__cookingunits_parse_stuff_mandatories_plus_star:nn {#1}
      }{
        \__cookingunits_if_evaluation_is_integer:nTF {#1}
          {
            \int_set:Nn \l__cookingunits_tmpa_int {#1}
            \tl_set:NV \l__cookingunits_curr_unit_tl \l__cookingunits_tmpa_int
            \bool_if:NT \l__cookingunits_tmpa_bool
              { \tl_put_left:Nn \l__cookingunits_curr_unit_tl { - } }
          }{
            \__cookingunits_set_state_to:n { error }
            \msg_error:nnn { cooking-units} { phrase-unit-not-an-integer } {#1}
          }
        \prop_put:Nnn \l__cookingunits_tmpa_prop { } {#2}
        \prop_put:NnV \l__cookingunits_tmpa_prop { - singlebool } \l__cookingunits_tmpa_bool
        \__cookingunits_parse_phrase_optionals:n {#2}
      }
  }
\cs_new:Npn \__cookingunits_parse_phrase_optionals:n #1
  {
    \peek_remove_spaces:n
      {
        \peek_meaning:NTF [
          { \__cookingunits_parse_stuff_plural:w }
          { \__cookingunits_parse_stuff_plural:w [#1] }
      }
  }
\cs_new:Npn \__cookingunits_parse_stuff_plural:w [#1]
  {
    \prop_put:Nnn \l__cookingunits_tmpa_prop { -pl } {#1}
    \peek_remove_spaces:n
      {
        \peek_meaning:NTF <
          { \__cookingunits_parse_stuff_gender:w }
          { \__cookingunits_parse_stuff_gender:w  <m> }
      }
  }
\cs_new:Npn \__cookingunits_parse_stuff_gender:w <#1>
  {
    \__cookingunits_if_gender_error:nTF {#1}
      { \__cookingunits_set_state_to:n { error } }
      { \prop_put:Nnn \l__cookingunits_tmpa_prop { -gender } {#1} }
    \__cookingunits_parse_phrase_finish_cycle_and_start_anew:V \l__cookingunits_curr_unit_tl
  }
\cs_new:Npn \__cookingunits_parse_phrase_finish_cycle_and_start_anew:n #1
  {
    \__cookingunits_if_state_equal:nT { normal }
      {
        \seq_if_in:NnF \l__cookingunits_phrase_numbers_seq {#1}
          { \seq_put_right:Nn \l__cookingunits_phrase_numbers_seq {#1} }
        \prop_map_inline:Nn \l__cookingunits_tmpa_prop
          {
            \prop_put:Nnn \l__cookingunits_phrase_prop { #1 ##1 } {##2}
          }
      }
    \__cookingunits_parse_phrase_start_cycle:
  }
\cs_generate_variant:Nn \__cookingunits_parse_phrase_finish_cycle_and_start_anew:n { V }
\cs_new:Npn \__cookingunits_new_cuphrase_sort_sequence:N #1
  {
    \seq_sort:Nn #1
      {
        \int_set:Nn \l__cookingunits_tmpa_int { \int_abs:n {##1} }
        \int_set:Nn \l__cookingunits_tmpb_int { \int_abs:n {##2} }
        \int_compare:nNnTF { \l__cookingunits_tmpa_int } < { \l__cookingunits_tmpb_int }
          { \sort_return_swapped: }
          {
            \int_compare:nNnTF { \l__cookingunits_tmpa_int } > { \l__cookingunits_tmpb_int }
              { \sort_return_same: }
              {
                \prop_get:NnN \l__cookingunits_phrase_prop { ##1 - singlebool } \l__cookingunits_tmpa_int
                \int_compare:nNnTF { \l__cookingunits_tmpa_int } = { 1 }
                  { \sort_return_same: }
                  { \sort_return_swapped: }
              }
          }
      }
  }
%%    \@@_cuphrase:nn {#1} {#2}
\cs_new:Npn \__cookingunits_old_cutext:nnn #1#2#3
  {
    \tl_set_eq:NN \l__cookingunits_option_unit_tl \l__cookingunits_original_unit_tl
    \__cookingunits_old_cutext_default:nnn {#1} {#2} {#3}
  }
\cs_new:Npn \__cookingunits_old_cutext_default:nnn #1#2#3
  {
    \bool_if:NTF \l__cookingunits_pckopt_draft_bool
      {#2}
      {
        \tl_set:Nn \l__cookingunits_cutext_last_value_tl {#2}
        \tl_if_in:NVTF \l__cookingunits_cutext_last_value_tl \l__cookingunits_input_range_sign_tl
          {
            \tl_replace_once:NVn \l__cookingunits_cutext_last_value_tl
              \l__cookingunits_input_range_sign_tl { \q__cookingunits_range }
            \__cookingunits_old_cutext_parse_range:Vn \l__cookingunits_cutext_last_value_tl {#3}
          }{
            \__cookingunits_old_cutext_print_input:Nn \l__cookingunits_cutext_last_value_tl {#3}
          }
      }
  }
\cs_new_protected:Npn \__cookingunits_old_cutext_print_input:Nn #1#2
  {
    \__cookingunits_old_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:NTF #1
      {
        \int_compare:nNnTF {#1} = { 1 }
          {
            \__cookingunits_culang_one_let:NnT \l__cookingunits_translation_tmpa_tl {#2}
              {
                \bool_if:NT \l__cookingunits_cutext_uppercase_word_bool
                  {
                    \text_uppercase:x { \tl_head:V \l__cookingunits_translation_tmpa_tl }
                    \tl_tail:V
                  }
              }
            \l__cookingunits_translation_tmpa_tl
          }{
            \bool_if:NTF \l__cookingunits_cutext_uppercase_word_bool
              { \__cookingunits_print_Numeral:V #1 }
              { \__cookingunits_print_numeral:V #1 }
          }
      }
      { \__cookingunits_print_numerical_input:N #1 }
  }
\prg_new_conditional:Npnn \__cookingunits_old_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:N #1 { TF }
  {
    \bool_if:NTF \l__cookingunits_lokal_numeral_bool
      {
        \__cookingunits_if_integer:VTF #1
          {
            \int_compare:nNnTF {#1} < { \l__cookingunits_print_numerals_below_int }
              { \prg_return_true: }
              { \prg_return_false: }
          }{ \prg_return_false: }
      }{ \prg_return_false: }
  }
\cs_new:Npn \__cookingunits_old_cutext_parse_range:nn #1 #2
  {
    \__cookingunits_old_cutext_parse_range_aux:nww {#2} #1 \q_stop
  }
\cs_generate_variant:Nn \__cookingunits_old_cutext_parse_range:nn { V }
\cs_new:Npn \__cookingunits_old_cutext_parse_range_aux:nww #1 #2 \q__cookingunits_range #3 \q_stop
  {
    \tl_set:Nn \l__cookingunits_tmpa_tl {#2}
    \tl_set:Nn \l__cookingunits_cutext_last_value_tl {#3}
    \__cookingunits_old_cutext_print_input:Nn \l__cookingunits_tmpa_tl {#1}
    \tl_use:N \l__cookingunits_cutext_range_sign_tl
    \__cookingunits_old_cutext_print_input:Nn \l__cookingunits_cutext_last_value_tl {#1}
  }
\cs_new:Npn \__cookingunits_cuam_old:n #1
  {
    \tl_set_rescan:Nnn \l__cookingunits_tmpa_tl
      {
        \char_set_catcode_letter:N \_ %
        \char_set_catcode_ignore:N\ %
      } {#1}
    \bool_if:NTF \l__cookingunits_pckopt_draft_bool
      { \l__cookingunits_tmpa_tl }
      { \__cookingunits_cuam_old_parse:V \l__cookingunits_tmpa_tl }
  }
\cs_new_protected:Npn \__cookingunits_cuam_old_parse:n #1
  {
    \tl_if_in:nVTF {#1} \l__cookingunits_input_range_sign_tl
      {
        \tl_set:Nn \l__cookingunits_tmpa_tl {#1}
        \tl_replace_once:NVn \l__cookingunits_tmpa_tl \l__cookingunits_input_range_sign_tl { \q__cookingunits_range }
        \__cookingunits_cuam_old_parse_range:V \l__cookingunits_tmpa_tl
      }{
        \tl_if_in:nnTF {#1} { / }
          {
            \tl_if_in:nnTF {#1} { _ }
              { \__cookingunits_cuam_old_parse_mixed_frac:www #1 \q_stop }
              { \__cookingunits_cuam_old_parse_frac:ww #1 \q_stop }
          }{
            \tl_if_in:nnTF {#1} { _ }
              { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
              { \__cookingunits_cuam_old_parse_scale:n {#1} }
          }
      }
  }
\cs_generate_variant:Nn \__cookingunits_cuam_old_parse:n { V }
\cs_new:Npn \__cookingunits_cuam_old_parse_range:n #1
  {
    \__cookingunits_cuam_old_parse_range_aux:ww #1 \q_nil
  }
\cs_generate_variant:Nn \__cookingunits_cuam_old_parse_range:n { V }
\cs_new:Npn \__cookingunits_cuam_old_parse_range_aux:ww #1 \q__cookingunits_range #2 \q_nil
  {
    #1 \l__cookingunits_cunum_range_sign_tl #2
  }
\cs_new:Npn \__cookingunits_cuam_old_parse_scale:n #1 {#1}
\cs_new:Npn \__cookingunits_cuam_old_parse_frac:ww #1/#2 \q_stop
  { \__cookingunits_frac:nn {#1} {#2} }
\cs_new:Npn \__cookingunits_cuam_old_parse_mixed_frac:www #1_#2/#3 \q_stop
  {
    #1
    \skip_horizontal:N \l__cookingunits_mixed_frac_dim
    \__cookingunits_frac:nn {#2} {#3}
  }
\NewDocumentCommand \cufrac { O{} m }
  {
    \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
    \group_begin:
    \tl_if_empty:nF {#1}
      { \keys_set:nn { cooking-units } {#1} }
    \__cookingunits_cufrac:n {#2}
    \group_end:
  }
\cs_new:Npn \__cookingunits_cufrac:n #1
  {
    \tl_set_rescan:Nnn \l__cookingunits_tmpa_tl
      {
        \char_set_catcode_letter:N \_ %
        \char_set_catcode_ignore:N\ %
      } {#1}
    \__cookingunits_cufrac_parse:V \l__cookingunits_tmpa_tl
  }
\cs_new:Npn \__cookingunits_cufrac_parse:n #1
  {
    \tl_if_in:nnTF {#1} { / }
      {
        \tl_if_in:nnTF {#1} { _ }
          { \__cookingunits_cufrac_parse_mixed_frac:www #1 \q_stop }
          { \__cookingunits_cufrac_parse_frac:ww #1 \q_stop }
      }{
        \tl_if_in:nnTF {#1} { _ }
          { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
          { \__cookingunits_cufrac_parse_scale:n {#1} }
      }
  }
\cs_generate_variant:Nn \__cookingunits_cufrac_parse:n { V }
\cs_new:Npn \__cookingunits_cufrac_parse_scale:n #1 {#1}
\cs_new:Npn \__cookingunits_cufrac_parse_frac:ww #1/#2 \q_stop
  { \__cookingunits_frac:nn {#1} {#2} }
\cs_new:Npn \__cookingunits_cufrac_parse_mixed_frac:www #1_#2/#3 \q_stop
  {
    #1
    \skip_horizontal:N \l__cookingunits_mixed_frac_dim
    \__cookingunits_frac:nn {#2} {#3}
  }
\NewDocumentCommand \cusetup { m }
  {
    \keys_set:nn { cooking-units } {#1}
  }
\newcookingunit { kg }
\newcookingunit { dag }
\newcookingunit { g }
\newcookingunit { oz }
\newcookingunit { lb }
\newcookingunit { stick }
\newcookingunit [
  symbol={\ensuremath{ \__cookingunits_frac:nn { eV } { c^2 } } } ,
  natural-unit
  ] { eVc-2 }
\newcookingunit { K }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace C ]  { C }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace F ] { F }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace R\'{e} ] { Re }
\newcookingunit { d }
\newcookingunit { h }
\newcookingunit { min }
\newcookingunit { s }
\newcookingunit [
    symbol={\ensuremath{ \__cookingunits_frac:nn { \hbar } { eV } } },
    natural-unit
  ] { hbareV-1 }
\newcookingunit { m }
\newcookingunit { cm }
\newcookingunit { dm }
\newcookingunit { mm }
\newcookingunit { in }
\newcookingunit [
    symbol={ \ensuremath{ \__cookingunits_frac:nn { c\hbar } { eV } } } ,  natural-unit
  ] { chbareV-1 }
\newcookingunit { l }
\newcookingunit { dl }
\newcookingunit { cl }
\newcookingunit { ml }
\newcookingunit [
    symbol={ \ensuremath { \__cookingunits_frac:nn { c^3 \hbar^3 } { eV^3 } } },  natural-unit
  ] { (chbareV-1)3 }
\newcookingunit { cal }
\newcookingunit { kcal }
\newcookingunit { J }
\newcookingunit { kJ }
\newcookingunit [ natural-unit ] { eV }
\newcookingunit [ pinch ] { pn }
\newcookingunit { EL }
\newcookingunit { TL }
\newcookingunit [ ssp. ] { ssp } %% saltspoonful
\newcookingunit [ csp. ] { csp } %% coffeespoonful
\newcookingunit [ dsp. ] { dsp }
\newcookingunit [ Msp. ] { Msp }
\DeclareLanguageAlias { AmericanEnglish } { American }
\cudefinename { German }
  {
    { kg } { Kilogramm } < n >
    { dag } { Dekagramm } < n >
    { g } { Gramm } < n >
    { oz } { Unze } < f >
    { lb } { Pfund } < n >
    { d } { Tag } [ Tage ]
    { h } { Stunde } [ Stunden ] < f >
    { min } { Minute } [ Minuten ] < f >
    { s } { Sekunde } [ Sekunden ] < f >
    { C } { Grad \space Celsius }
    { K } { Kelvin } < n >
    { F } { Grad \space Fahrenheit }
    { Re } { Grad \space R\'{e}amur }
    { m } { Meter } < n >
    { dm } { Dezimeter } < n >
    { cm } { Centimeter } < n >
    { mm } { Millimeter } < n >
    { in } { Zoll }
    { l } [ l ] { Liter }
    { dl } { Deziliter }
    { cl } { Centiliter }
    { ml } { Milliliter }
    { cal } { Kalorie } [ Kalorien ] < f >
    { kcal } { Kilokalorie } [ Kilokalorien ] < f >
    { J } { Joule }
    { kJ } { Kilojoule }
    { eV } { Elektronenvolt } < n >
    { Msp } [ Msp. ] { Messerspitze } [ Messerspitzen ] < f >
    { pn } [ Prise ] { Prise } [ Prisen ] < f >
    { EL } [ EL ] { Essl{\"o}ffel }
    { TL } [ TL ] { Teel{\"o}ffel }
    { csp } [ KL ] { Mokkal{\"o}ffel }
    { decimal-mark } { , }
    { one (m) } { ein }
    { one (f) } { eine }
    { one (n) } { ein }
  }
\cudefinename { English }
  {
    { kg } { kilogramme }
    { dag } { decagramme }
    { g } { gramme }
    { oz } { ounce }
    { lb } { pound } [ pounds ]
    { stick } { stick } [ sticks ]
    { d } { day } [ days ]
    { h } { hour } [ hours ]
    { min } { minute } [ minutes ]
    { s } { second } [ seconds ]
    { C } { degree \space Celsius }  [ degrees \space Celsius ]
    { F } { degree \space Fahrenheit } [ degrees \space Fahrenheit ]
    { K } { kelvin }
    { Re } { degree \space R\'{e}aumur } [ degrees \space R\'{e}aumur ]
    { m } { metre } [ metres ]
    { dm } { decimetre } [ decimetres ]
    { cm } { centimetre } [ centimetres ]
    { mm } { millimitre } [ millimitres ]
    { in } { inch } [ inches ]
    { l } [ \ensuremath { \ell } ] { litre } [ litres ]
    { dl } { decilitre } [ decilitres ]
    { cl } { centilitre } [ centilitres ]
    { ml } { millilitre } [ millilitres ]
    { cal } { calorie } [ calories ]
    { kcal } { kilocalorie } [ kilocalories ]
    { J } { joule } [ joules ]
    { kJ } { kilojoule } [ kilojoules ]
    { eV } { electron \space volt }
    { pn } [ pinch ] { pinch } [ pinches ]
    { EL } [ tbsp. ] { tablespoon } [ tablespoons ]
    { TL } [ tsp. ] { teaspoon } [ teaspoons ]
    { dsp } { dessertspoonful }
    { csp } { coffeespoonful }
    { ssp } { saltspoonful }
    { decimal-mark } { . }
    { one (m) } { one }
    { one (f) } { one }
    { one (n) } { one }
  }
\cudefinename { AmericanEnglish }
  {
    { kg } { kilogram }
    { dag } { decagram }
    { g } { gram }
    { oz } { ounce }
    { m } { meter } [ meters ]
    { dm } { decimeter } [ decimeters ]
    { cm } { centimeter } [ centimeters ]
    { mm } { millimiter } [ millimiters ]
    { in } { inch } [ inches ]
    { l } [ \ensuremath { \ell } ] { liter } [ liters ]
    { dl } { deciliter } [ deciliters ]
    { cl } { centiliter } [ centiliters ]
    { ml } { milliliter } [ milliliters ]
    { pn } [ pn. ] { pinch } [ pinches ]
  }
\cudefinename { French }
  {
    { kg } { kilogramme } [ kilogrammes ]
    { dag } { d\'{e}cagramme } [ d\'{e}cagrammes]
    { g } { gramme } [ grammes ]
    { oz } { once } [ onces ] < f >
    { lb } { livre } [ livres ] < f >
    { d } { jour } [ jours ]
    { h } { heure } [ heures ] < f >
    { min } { minute } [ minutes ] < f >
    { s } { seconde } [ secondes ] < f >
    { C } { degr\'{e} \space Celsius }  [ degr\'{e}s \space Celsius ]
    { K } { degr\'{e} \space Fahrenheit } [ degr\'{e}s \space Fahrenheit ]
    { F } { kelvin } [ kelvins ]
    { Re } { \'{e}chelle \space R\'{e}aumur } [ degr\'{e}s \space R\'{e}aumur ]
    { m } { m\`{e}tre } [ m\`{e}tres ]
    { dm } { d\'{e}cim\`{e}tre } [ d\'{e}cim\`{e}tres ]
    { cm } { centim\`{e}tre } [ centim\`{e}tres ]
    { mm } { millim\`{e}tre } [ millim\`{e}tres ]
    { in } [ po ] { pouce } [ pouces ]
    { l } [ L ] { litre } [ litres ]
    { dl } [ dL ] { d\'{e}cilitre } [ d\'{e}cilitres ]
    { cl } [ cL ] { centilitre } [ centilitres ]
    { ml } [ mL ] { millilitre } [ millilitres ]
    { cal } { calorie } [ calories ] < f >
    { kcal } { kilocalorie } [ kilocalories ] < f >
    { J } { joule } [ joules ]
    { kJ } { kilojoule } [ kilojoules ]
    { eV } { \'{e}lectron-volt } [ \'{e}lectron-volts ]
    { pn } [ pinc\'{e}e ] { pinc\'{e}e } [ pinc\'{e}es ] < f >
    { EL } [c.\`{a}.s.] { cuill\`{e}re  \space \`{a} \space  soupe } [ cuill\`{e}res  \space \`{a} \space  soupe ] < f >
    { TL } [c.\`{a}.c.] { cuill\`{e}re  \space \`{a} \space  caf\'{e} } [ cuill\`{e}res  \space \`{a} \space  caf\'{e} ] < f >
    { decimal-mark } { , }
    { one (m) } { un }
    { one (f) } { une }
    { one (n) } { un }
  }
\cudefinekeychain
  {
    { kg } { 1 }
    { dag }{ 100 }
    { g }  { 1000 }
    { lb } { 1/0.45359237 }
    { oz } { 16/0.45359237 }
    { stick } { 4/0.45359237 }
    { eVc-2 } { 560958865.0e+27 } %% (560958865.0 +- 3.5) e+27
  }
\cudefinekeys { d }
  {
    { h }  { 24 }
    { min }{ 1440 }
    { s }  { 86400 }
    { hbareV-1 } { 151926746.1e+7 * 86400 } %% (151926746.1 +- 2.1) e+7
  }
\cudefinekeys { m }
  {
    { dm } { 10 }
    { cm } { 100 }
    { mm } { 1000 }
    { in } { 36/0.9144 }
    { chbareV-1 } { 5067730.759 } %% 5067730.759 +- 0.070
  }
\cudefinekeys { l }
  {
    { dl } { 10 }
    { cl } { 100 }
    { ml }{ 1000 }
    { (chbareV-1)3 } { 130148929.5e+12 * 1e-3 } %% (130148929.5 +- 5.4 e+12)*1e-3
  }
\cudefinekeys { J }
  {
    { kJ }{ 1e-3 }
    { cal }{ 0.2388459 }
    { kcal }{ 0.2388459e-3 }
    { eV }{ 624150912.6e+10 } %% (624150912.6 +- 3.9) e+10
  }
\fp_const:Nn \c__cookingunits_kb_eV_fp {  8.617 330 3 e-5  }
\cudefinesinglekey { C }
  {
    { K } { #1 + 273.15 }
    { F } { #1 * 1.8 + 32 }
    { Re } { #1 * 0.8 }
    { eV } { ( #1 + 273.15 ) * \c__cookingunits_kb_eV_fp }
  }
\cudefinesinglekey { F }
  {
    { C } { ( #1 - 32 ) *  5/9 }
    { K } { ( #1 + 459.67 ) *  5/9 }
    { Re } { ( #1 - 32 ) * 4/9 }
    { eV } {( #1 + 459.67 ) *  5/9 * \c__cookingunits_kb_eV_fp }
  }
\cudefinesinglekey { K }
  {
    { C } { #1 - 273.15 }
    { F } { #1 * 1.8 - 459.67 }
    { Re } { ( #1 - 273.15 ) * 0.8 }
    { eV } { #1 * \c__cookingunits_kb_eV_fp }
  }
\cudefinesinglekey { Re }
  {
    { K } { #1 * 1.25 + 273.15 }
    { C } { #1  * 1.25 }
    { F } { #1 * 2.25 + 32 }
    { eV } { ( #1 * 1.25 + 273.15 ) * \c__cookingunits_kb_eV_fp }
  }
\cudefinephrase { German }
  {
    { 12 } { Dutzend } < n >
  }
\cudeclareunitgroup { weight } { kg , dag, g, oz, lb, stick }
\cudeclareunitgroup { length } { m , dm , cm , mm , in }
\cudeclareunitgroup { volume } { l , dl , cl  , ml }
\cudeclareunitgroup { temperature } { C , F , K , Re }
\cudeclareunitgroup { energy } { cal, kcal , J , kJ , eV }
\cudeclareunitgroup { time } { d , h , min , s }
\cusetoptionfor { F , C , K , Re } { round-precision = 0 }
\cusetup
  {
    curef-add-forbidden-unit = { F , C , K , Re } ,
    add-temperature-to-check =
      {
        K = 0,
        C = -273.15 ,
        F = -459.67 ,
        Re = -218.52
      } ,
    round-precision = 2 ,
  }


\endinput
%%
%% End of file `cooking-units.sty'.
