summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-09-22 22:26:18 +0000
committerKarl Berry <karl@freefriends.org>2015-09-22 22:26:18 +0000
commitaa040bf06e9ffb30895fc92178a8f1aa44fda1de (patch)
tree468f61c3dca995cdd41e9ff4ecc6ae1dd3d0b294 /Master/texmf-dist/tex/latex
parentf1f4767bbed8d529512166e9ebc17c398bf22888 (diff)
unravel (22sep15)
git-svn-id: svn://tug.org/texlive/trunk@38435 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/unravel/unravel.sty1030
1 files changed, 611 insertions, 419 deletions
diff --git a/Master/texmf-dist/tex/latex/unravel/unravel.sty b/Master/texmf-dist/tex/latex/unravel/unravel.sty
index 1665ce3acf4..630584380a7 100644
--- a/Master/texmf-dist/tex/latex/unravel/unravel.sty
+++ b/Master/texmf-dist/tex/latex/unravel/unravel.sty
@@ -11,7 +11,7 @@
%% Communicate any suggestions for changing this package
%% to Bruno Le Floch (blflatex@gmail.com).
%%
-%% File: unravel.dtx Copyright (C) 2013 Bruno Le Floch
+%% File: unravel.dtx Copyright (C) 2013, 2015 Bruno Le Floch
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -21,80 +21,21 @@
%% http://www.latex-project.org/lppl.txt
%%
%% -----------------------------------------------------------------------
-\RequirePackage{expl3}[2013/07/01]
-\RequirePackage{l3str}[2013/04/24]
-\RequirePackage{gtl}[2013/07/28]
+\RequirePackage{expl3,xparse}[2015/09/11]
+\RequirePackage{gtl}[2015/09/21]
\ProvidesExplPackage
- {unravel} {2013/07/28} {0.0a} {Watching TeX digest tokens}
-\ior_new:N \g__unravel_prompt_ior
-\tl_new:N \g__unravel_prompt_before_tl
-\int_new:N \l__unravel_prompt_tmpa_int
-\int_new:N \g__unravel_nonstop_int
-\int_new:N \g__unravel_noise_int
-\int_gset_eq:NN \g__unravel_noise_int \c_one
-\bool_new:N \l__unravel_debug_bool
-\int_new:N \g__unravel_step_int
-\str_new:N \g__unravel_action_text_str
-\int_new:N \g__unravel_max_action_int
-\int_new:N \g__unravel_max_output_int
-\int_new:N \g__unravel_max_prev_int
-\int_new:N \g__unravel_max_input_int
-\int_gset:Nn \g__unravel_max_action_int { 50 }
-\int_gset:Nn \g__unravel_max_output_int { 300 }
-\int_gset:Nn \g__unravel_max_prev_int { 300 }
-\int_gset:Nn \g__unravel_max_input_int { 300 }
-\bool_new:N \g__unravel_speedup_macros_bool
-\bool_gset_true:N \g__unravel_speedup_macros_bool
-\int_new:N \l__unravel_print_int
-\int_new:N \g__unravel_input_int
-\int_new:N \g__unravel_input_tmpa_int
-\tl_new:N \l__unravel_input_tmpa_tl
-\seq_new:N \g__unravel_prev_input_seq
-\tl_new:N \l__unravel_prev_input_tl
-\gtl_new:N \l__unravel_prev_input_gtl
-\gtl_new:N \g__unravel_output_gtl
-\gtl_new:N \l__unravel_head_gtl
-\tl_new:N \l__unravel_head_tl
-\token_new:Nn \l__unravel_head_token { ? }
-\int_new:N \l__unravel_head_cmd_int
-\int_new:N \l__unravel_head_char_int
-\tl_new:N \l__unravel_head_meaning_tl
-\tl_new:N \l__unravel_tmpa_tl
-\gtl_new:N \l__unravel_tmpb_gtl
-\tl_new:N \g__unravel_tmpc_tl
-\seq_new:N \l__unravel_tmpa_seq
-\tl_new:N \l__unravel_defined_tl
-\tl_new:N \l__unravel_defining_tl
-\cs_new_eq:NN \__unravel_inaccessible:w ?
-\gtl_new:N \g__unravel_after_assignment_gtl
-\bool_new:N \g__unravel_set_box_allowed_bool
-\bool_new:N \g__unravel_name_in_progress_bool
-\group_begin:
- \char_set_lccode:nn { `* } { `# }
- \tex_lowercase:D
- { \tl_const:Nn \c__unravel_parameters_tl { ^*1*2*3*4*5*6*7*8*9 } }
-\group_end:
-\int_new:N \g__unravel_val_level_int
-\tl_const:Nn \c__unravel_plus_tl { + }
-\tl_const:Nn \c__unravel_minus_tl { - }
-\tl_const:Nn \c__unravel_times_tl { * }
-\tl_const:Nn \c__unravel_over_tl { / }
-\tl_const:Nn \c__unravel_lq_tl { ` }
-\tl_const:Nn \c__unravel_rq_tl { ' }
-\tl_const:Nn \c__unravel_dq_tl { " }
-\tl_const:Nn \c__unravel_lp_tl { ( }
-\tl_const:Nn \c__unravel_rp_tl { ) }
-\tl_const:Nn \c__unravel_eq_tl { = }
-\tl_const:Nn \c__unravel_comma_tl { , }
-\tl_const:Nn \c__unravel_point_tl { . }
-\tl_new:N \g__unravel_if_limit_tl
-\int_new:N \g__unravel_if_limit_int
-\int_new:N \g__unravel_if_depth_int
-\int_new:N \l__unravel_if_nesting_int
-\seq_new:N \l__unravel_leaders_box_seq
-\int_new:N \g__unravel_ends_int
-\int_gset:Nn \g__unravel_ends_int { 3 }
-\gtl_const:Nx \c__unravel_frozen_relax_gtl { \if_int_compare:w 0 = 0 \fi: }
+ {unravel} {2015/09/22} {0.1} {Watching TeX digest tokens}
+\cs_if_exist:NF \str_range:nnn { \RequirePackage{l3str} }
+\cs_new_eq:NN \__unravel_currentgrouptype: \etex_currentgrouptype:D
+\cs_new_protected_nopar:Npn \__unravel_set_escapechar:n
+ { \int_set:Nn \tex_escapechar:D }
+\cs_new_eq:NN \__unravel_everyeof:w \etex_everyeof:D
+\cs_new_eq:NN \__unravel_everypar:w \tex_everypar:D
+\cs_new_eq:NN \__unravel_hbox:w \tex_hbox:D
+\cs_new_eq:NN \__unravel_nullfont: \tex_nullfont:D
+\cs_new_eq:NN \__unravel_the:w \tex_the:D
+\cs_new_eq:NN \c__unravel_prompt_ior \c_sixteen
+\cs_new_eq:NN \c__unravel_noprompt_ior \c_minus_one
\cs_if_exist:NF \exp_last_unbraced:NNn
{ \cs_new_eq:NN \exp_last_unbraced:NNn \use:nnn }
\cs_generate_variant:Nn \exp_last_unbraced:NNn { NNv }
@@ -121,21 +62,19 @@
\cs_generate_variant:Nn \gtl_gset:Nn { c }
\cs_generate_variant:Nn \gtl_gconcat:NNN { ccc , cNc }
\cs_generate_variant:Nn \gtl_gclear:N { c }
+\cs_generate_variant:Nn \gtl_gclear_new:N { c }
+\cs_new_protected_nopar:Npn \__unravel_tmp:w { }
\cs_new_protected:Npn \__unravel_tl_gset_input:Nnn #1#2#3
{
\group_begin:
- \etex_everyeof:D \exp_after:wN { \token_to_str:N @ @ #1 }
+ \__unravel_everyeof:w \exp_after:wN { \token_to_str:N @ @ #1 }
#2
\tl_gclear:N #1
- \str_if_eq_x:nnF
- { \token_to_meaning:N \tex_input:D }
- { \token_to_str:N \input }
- { \msg_unravel:nnx { unravel } { internal } { input-prim } }
\exp_after:wN \__unravel_tl_gset_input_aux:wN
\exp_after:wN \prg_do_nothing:
\tex_input:D \tl_to_str:n {#3} \scan_stop:
\group_end:
- \tl_gput_right:NV #1 \etex_everyeof:D
+ \tl_gput_right:NV #1 \__unravel_everyeof:w
}
\cs_generate_variant:Nn \__unravel_tl_gset_input:Nnn { Nno }
\use:x
@@ -143,7 +82,6 @@
\cs_new_protected:Npn \exp_not:N \__unravel_tl_gset_input_aux:wN
##1 \token_to_str:N @ @ ##2
} { \tl_gset:No #2 {#1} }
-\cs_new_eq:NN \__unravel_cs_case:NnF \tl_case:NnF
\cs_new_nopar:Npn \__unravel_strip_escape:w
{
\tex_romannumeral:D
@@ -153,15 +91,6 @@
\cs_new:Npn \__unravel_strip_escape_aux:N #1 { \c_zero }
\cs_new:Npn \__unravel_strip_escape_aux:w #1#2
{ - \__int_value:w #1 \c_zero }
-\cs_new:Npn \__unravel_meaning_to_char:n #1
- { \__unravel_meaning_to_char_auxi:w #1 \q_mark ~ {} ~ \q_mark \q_stop }
-\cs_new:Npn \__unravel_meaning_to_char_auxi:w #1 ~ #2 ~ #3 \q_mark #4 \q_stop
- { \__unravel_meaning_to_char_auxii:w #3 ~ #3 ~ \q_stop }
-\cs_new:Npn \__unravel_meaning_to_char_auxii:w #1 ~ #2 ~ #3 \q_stop
- { \tl_if_empty:nTF {#2} { ~ } {#2} }
-\cs_generate_variant:Nn \__unravel_meaning_to_char:n { o }
-\cs_new:Npn \__unravel_token_to_char:N #1
- { \__unravel_meaning_to_char:o { \token_to_meaning:N #1 } }
\cs_new:Npn \__unravel_to_str:n #1
{
\tl_if_head_eq_meaning:nNTF {#1} \scan_stop:
@@ -177,28 +106,64 @@
#1 tl \q_mark \q_stop
}
\cs_new:Npn \__unravel_to_str_auxii:w ##1 #1 ##2 \q_mark ##3 \q_stop
- { \cs_if_exist_use:cF { ##2 _to_str:n } { \tl_to_str:n } }
+ { \cs_if_exist_use:cF { __unravel_ ##2 _to_str:n } { \tl_to_str:n } }
}
\exp_args:No \__unravel_tmp:w { \tl_to_str:n { s__ } }
-\cs_new_protected:Npn \__unravel_prev_input_silent:n #1
+\cs_new:Npn \__unravel_gtl_to_str:n #1 { \__gtl_to_str:w #1 }
+\cs_new:Npn \__unravel_str_truncate_left:nn #1#2
{
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_prev_input_tl
- \tl_put_right:Nn \l__unravel_prev_input_tl {#1}
- \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_prev_input_tl
+ \exp_args:Nf \__unravel_str_truncate_left_aux:nnn
+ { \str_count:n {#1} } {#1} {#2}
}
-\cs_generate_variant:Nn \__unravel_prev_input_silent:n { V , x }
-\cs_new_protected:Npn \__unravel_prev_input:n #1
+\cs_new:Npn \__unravel_str_truncate_left_aux:nnn #1#2#3
{
- \__unravel_prev_input_silent:n {#1}
- \__unravel_print_action:x { \tl_to_str:n {#1} }
+ \int_compare:nNnTF {#1} > {#3}
+ {
+ ( \int_eval:n { #1 - #3 + 25 } ~ more~chars ) ~
+ \str_range:nnn {#2} { #1 - #3 + 26 } {#1}
+ }
+ { \tl_to_str:n {#2} }
}
-\cs_generate_variant:Nn \__unravel_prev_input:n { V , x }
-\cs_new_protected:Npn \__unravel_prev_input_gtl:N #1
+\cs_new:Npn \__unravel_str_truncate_right:nn #1#2
{
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_prev_input_gtl
- \gtl_concat:NNN \l__unravel_prev_input_gtl \l__unravel_prev_input_gtl #1
- \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_prev_input_gtl
+ \exp_args:Nf \__unravel_str_truncate_right_aux:nnn
+ { \str_count:n {#1} } {#1} {#2}
+ }
+\cs_new:Npn \__unravel_str_truncate_right_aux:nnn #1#2#3
+ {
+ \int_compare:nNnTF {#1} > {#3}
+ {
+ \str_range:nnn {#2} { 1 } { #3 - 25 } ~
+ ( \int_eval:n { #1 - #3 + 25 } ~ more~chars )
+ }
+ { \tl_to_str:n {#2} }
+ }
+\cs_new_eq:NN \__unravel_exit_point: \prg_do_nothing:
+\cs_new:Npn \__unravel_exit:w #1 \__unravel_exit_point: { }
+\cs_new_eq:NN \__unravel_break_point: \prg_do_nothing:
+\cs_new:Npn \__unravel_break:w #1 \__unravel_break_point: { }
+\prg_new_conditional:Npnn \__unravel_cmd_if_internal: { TF }
+ {
+ \int_compare:nNnTF
+ \l__unravel_head_cmd_int < { \__unravel_tex_use:n { min_internal } }
+ { \prg_return_false: }
+ {
+ \int_compare:nNnTF
+ \l__unravel_head_cmd_int
+ > { \__unravel_tex_use:n { max_internal } }
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
}
+\cs_new:Npn \__unravel_meaning_to_char:n #1
+ { \__unravel_meaning_to_char_auxi:w #1 \q_mark ~ {} ~ \q_mark \q_stop }
+\cs_new:Npn \__unravel_meaning_to_char_auxi:w #1 ~ #2 ~ #3 \q_mark #4 \q_stop
+ { \__unravel_meaning_to_char_auxii:w #3 ~ #3 ~ \q_stop }
+\cs_new:Npn \__unravel_meaning_to_char_auxii:w #1 ~ #2 ~ #3 \q_stop
+ { \tl_if_empty:nTF {#2} { ~ } {#2} }
+\cs_generate_variant:Nn \__unravel_meaning_to_char:n { o }
+\cs_new:Npn \__unravel_token_to_char:N #1
+ { \__unravel_meaning_to_char:o { \token_to_meaning:N #1 } }
\prg_new_conditional:Npnn \__unravel_token_if_expandable:N #1
{ p , T , F , TF }
{
@@ -223,18 +188,16 @@
}
{ \prg_return_true: }
}
-\cs_new_eq:NN \__unravel_exit_point: \prg_do_nothing:
-\cs_new:Npn \__unravel_exit:w #1 \__unravel_exit_point: { }
-\cs_new_eq:NN \__unravel_break_point: \prg_do_nothing:
-\cs_new:Npn \__unravel_break:w #1 \__unravel_break_point: { }
\group_begin:
\char_set_catcode_active:n { `Z }
\prg_new_protected_conditional:Npnn \__unravel_token_if_definable:N #1
{ TF }
{
\group_begin:
- \int_set:Nn \tex_escapechar:D { 92 }
- \exp_args:No \tl_if_single:nTF { \token_to_str:N #1 }
+ \__unravel_set_escapechar:n { 92 }
+ \tl_set:Nx \l__unravel_tmpa_tl
+ { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
+ \tl_if_empty:NTF \l__unravel_tmpa_tl
{
\exp_args:Nx \char_set_lccode:nn
{ ` \str_head:n {#1} } { `Z }
@@ -261,6 +224,123 @@
}
{ \prg_return_false: }
}
+\cs_new_protected:Npn \__unravel_prev_input_silent:n #1
+ {
+ \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_prev_input_tl
+ \tl_put_right:Nn \l__unravel_prev_input_tl {#1}
+ \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_prev_input_tl
+ }
+\cs_generate_variant:Nn \__unravel_prev_input_silent:n { V , x }
+\cs_new_protected:Npn \__unravel_prev_input:n #1
+ {
+ \__unravel_prev_input_silent:n {#1}
+ \__unravel_print_action:x { \tl_to_str:n {#1} }
+ }
+\cs_generate_variant:Nn \__unravel_prev_input:n { V , x }
+\cs_new_protected:Npn \__unravel_prev_input_gtl:N #1
+ {
+ \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_prev_input_gtl
+ \gtl_concat:NNN \l__unravel_prev_input_gtl \l__unravel_prev_input_gtl #1
+ \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_prev_input_gtl
+ }
+\cs_new_protected:Npn \__unravel_prev_input_join_get:nN #1
+ {
+ \int_case:nnF {#1}
+ {
+ { 2 } { \__unravel_join_get_aux:NNN \skip_eval:n \etex_glueexpr:D }
+ { 3 } { \__unravel_join_get_aux:NNN \muskip_eval:n \etex_muexpr:D }
+ }
+ {
+ \msg_error:nnn { unravel } { internal } { join-factor }
+ \__unravel_join_get_aux:NNN \use:n \prg_do_nothing:
+ }
+ }
+\cs_new_protected:Npn \__unravel_join_get_aux:NNN #1#2#3
+ {
+ \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
+ \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_tmpa_tl
+ \tl_set:Nx #3 { #1 { \l__unravel_tmpa_tl #2 \l__unravel_head_tl } }
+ }
+\tl_new:N \g__unravel_before_print_state_tl
+\tl_new:N \g__unravel_before_prompt_tl
+\int_new:N \l__unravel_prompt_tmpa_int
+\int_new:N \g__unravel_nonstop_int
+\int_new:N \g__unravel_noise_int
+\int_gset_eq:NN \g__unravel_noise_int \c_one
+\bool_new:N \g__unravel_default_explicit_prompt_bool
+\bool_new:N \g__unravel_default_internal_debug_bool
+\bool_new:N \g__unravel_default_number_steps_bool
+\bool_gset_true:N \g__unravel_default_number_steps_bool
+\bool_new:N \g__unravel_default_welcome_message_bool
+\bool_gset_true:N \g__unravel_default_welcome_message_bool
+\bool_new:N \g__unravel_explicit_prompt_bool
+\bool_new:N \g__unravel_internal_debug_bool
+\bool_new:N \g__unravel_number_steps_bool
+\bool_new:N \g__unravel_welcome_message_bool
+\int_new:N \g__unravel_step_int
+\str_new:N \g__unravel_action_text_str
+\int_new:N \g__unravel_default_max_action_int
+\int_new:N \g__unravel_default_max_output_int
+\int_new:N \g__unravel_default_max_input_int
+\int_gset:Nn \g__unravel_default_max_action_int { 50 }
+\int_gset:Nn \g__unravel_default_max_output_int { 300 }
+\int_gset:Nn \g__unravel_default_max_input_int { 300 }
+\int_new:N \g__unravel_max_action_int
+\int_new:N \g__unravel_max_output_int
+\int_new:N \g__unravel_max_input_int
+\bool_new:N \g__unravel_speedup_macros_bool
+\bool_gset_true:N \g__unravel_speedup_macros_bool
+\int_new:N \l__unravel_print_int
+\int_new:N \g__unravel_input_int
+\int_new:N \g__unravel_input_tmpa_int
+\tl_new:N \l__unravel_input_tmpa_tl
+\seq_new:N \g__unravel_prev_input_seq
+\tl_new:N \l__unravel_prev_input_tl
+\gtl_new:N \l__unravel_prev_input_gtl
+\gtl_new:N \g__unravel_output_gtl
+\gtl_new:N \l__unravel_head_gtl
+\tl_new:N \l__unravel_head_tl
+\token_new:Nn \l__unravel_head_token { ? }
+\int_new:N \l__unravel_head_cmd_int
+\int_new:N \l__unravel_head_char_int
+\tl_new:N \l__unravel_head_meaning_tl
+\tl_new:N \l__unravel_tmpa_tl
+\gtl_new:N \l__unravel_unused_gtl
+\gtl_new:N \l__unravel_tmpb_gtl
+\tl_new:N \g__unravel_tmpc_tl
+\seq_new:N \l__unravel_tmpa_seq
+\tl_new:N \l__unravel_defined_tl
+\tl_new:N \l__unravel_defining_tl
+\cs_new_eq:NN \__unravel_inaccessible:w ?
+\gtl_new:N \g__unravel_after_assignment_gtl
+\bool_new:N \g__unravel_set_box_allowed_bool
+\bool_new:N \g__unravel_name_in_progress_bool
+\group_begin:
+ \cs_set:Npx \__unravel_tmp:w #1 { \c_hash_str #1 }
+ \tl_const:Nx \c__unravel_parameters_tl
+ { ^ \tl_map_function:nN { 123456789 } \__unravel_tmp:w }
+\group_end:
+\int_new:N \g__unravel_val_level_int
+\tl_new:N \g__unravel_if_limit_tl
+\int_new:N \g__unravel_if_limit_int
+\int_new:N \g__unravel_if_depth_int
+\int_new:N \l__unravel_if_nesting_int
+\seq_new:N \l__unravel_leaders_box_seq
+\int_new:N \g__unravel_ends_int
+\int_gset:Nn \g__unravel_ends_int { 3 }
+\tl_const:Nn \c__unravel_plus_tl { + }
+\tl_const:Nn \c__unravel_minus_tl { - }
+\tl_const:Nn \c__unravel_times_tl { * }
+\tl_const:Nn \c__unravel_over_tl { / }
+\tl_const:Nn \c__unravel_lq_tl { ` }
+\tl_const:Nn \c__unravel_rq_tl { ' }
+\tl_const:Nn \c__unravel_dq_tl { " }
+\tl_const:Nn \c__unravel_lp_tl { ( }
+\tl_const:Nn \c__unravel_rp_tl { ) }
+\tl_const:Nn \c__unravel_eq_tl { = }
+\tl_const:Nn \c__unravel_comma_tl { , }
+\tl_const:Nn \c__unravel_point_tl { . }
+\gtl_const:Nx \c__unravel_frozen_relax_gtl { \if_int_compare:w 0 = 0 \fi: }
\cs_new_protected:Npn \__unravel_tex_const:nn #1#2
{ \int_const:cn { c__unravel_tex_#1_int } {#2} }
\cs_new:Npn \__unravel_tex_use:n #1 { \int_use:c { c__unravel_tex_#1_int } }
@@ -683,7 +763,7 @@
\__unravel_tex_primitive:nnn { lefthyphenmin } { assign_int } { 51 }
\__unravel_tex_primitive:nnn { righthyphenmin } { assign_int } { 52 }
\__unravel_tex_primitive:nnn { holdinginserts } { assign_int } { 53 }
-\__unravel_tex_primitive:nnn { errorcontegtlines } { assign_int } { 54 }
+\__unravel_tex_primitive:nnn { errorcontextlines } { assign_int } { 54 }
\__unravel_tex_primitive:nnn { pdfoutput } { assign_int } { 55 }
\__unravel_tex_primitive:nnn { pdfcompresslevel } { assign_int } { 56 }
\__unravel_tex_primitive:nnn { pdfdecimaldigits } { assign_int } { 57 }
@@ -1158,14 +1238,16 @@
\cs_new_protected:Npn \__unravel_input_split_auxiii:w
#1 \__unravel_input_split_end:
{
+ \gtl_gclear_new:c
+ { g__unravel_input_ \int_use:N \g__unravel_input_tmpa_int _gtl }
\gtl_gset:cn
{ g__unravel_input_ \int_use:N \g__unravel_input_tmpa_int _gtl } {#1}
\int_gdecr:N \g__unravel_input_tmpa_int
}
\cs_new_protected_nopar:Npn \__unravel_input_gset:n
{
- \int_gset_eq:NN \g__unravel_input_int \c_one
- \gtl_gset:cn { g__unravel_input_1_gtl }
+ \int_gzero:N \g__unravel_input_int
+ \__unravel_back_input:n
}
\cs_new_protected:Npn \__unravel_input_get:N #1
{
@@ -1262,6 +1344,7 @@
\cs_new_protected_nopar:Npn \__unravel_back_input:n
{
\int_gincr:N \g__unravel_input_int
+ \gtl_gclear_new:c { g__unravel_input_ \int_use:N \g__unravel_input_int _gtl }
\gtl_gset:cn { g__unravel_input_ \int_use:N \g__unravel_input_int _gtl }
}
\cs_generate_variant:Nn \__unravel_back_input:n { x , V , o }
@@ -1308,21 +1391,20 @@
\msg_error:nn { unravel } { missing-dollar }
\__unravel_print_action:
}
-\group_begin:
- \char_set_lccode:nn { `. } { `: }
- \tex_lowercase:D
- {
- \cs_new:Npn \__unravel_macro_split_do:NN #1
- {
- \exp_after:wN \__unravel_macro_split_do:wN
- \token_to_meaning:N #1 \q_mark { } . -> \q_mark \use_none:nnnn
- \q_stop
- }
- \cs_new:Npn \__unravel_macro_split_do:wN
- #1 . #2 -> #3 \q_mark #4 #5 \q_stop #6
- { #4 #6 {#1} {#2} {#3} }
- }
-\group_end:
+\use:x
+ {
+ \exp_not:n { \cs_new:Npn \__unravel_macro_split_do:NN #1 }
+ {
+ \exp_not:n { \exp_after:wN \__unravel_macro_split_do:wN }
+ \exp_not:n { \token_to_meaning:N #1 \q_mark { } }
+ \tl_to_str:n { : } \exp_not:n { -> \q_mark \use_none:nnnn }
+ \exp_not:N \q_stop
+ }
+ \exp_not:n { \cs_new:Npn \__unravel_macro_split_do:wN }
+ \exp_not:n {#1} \tl_to_str:n { : } \exp_not:n { #2 -> }
+ \exp_not:n { #3 \q_mark #4 #5 \q_stop #6 }
+ { \exp_not:n { #4 #6 {#1} {#2} {#3} } }
+ }
\cs_new:Npn \__unravel_macro_prefix:N #1
{ \__unravel_macro_split_do:NN #1 \use_i:nnn }
\cs_new:Npn \__unravel_macro_parameter:N #1
@@ -1349,22 +1431,28 @@
}
\cs_new_protected_nopar:Npn \__unravel_macro_call_quick:
{
- \exp_after:wN \__unravel_macro_call_quick_loop:NN \l__unravel_tmpa_tl
+ \exp_after:wN \__unravel_macro_call_quick_loop:NNN \l__unravel_tmpa_tl
{ ? \use_none_delimit_by_q_stop:w } \q_stop
}
-\cs_new_protected_nopar:Npn \__unravel_macro_call_quick_loop:NN #1#2
+\cs_new_protected:Npn \__unravel_macro_call_quick_loop:NNN #1#2#3
{
\use_none:n #2
\__unravel_input_gpop_item:NF \l__unravel_tmpa_tl
- { \msg_error:nn { unravel } { runaway-macro-parameter } }
+ { \__unravel_macro_call_quick_runaway:Nw #3 }
\tl_put_right:Nx \l__unravel_head_tl
{ { \exp_not:V \l__unravel_tmpa_tl } }
- \__unravel_macro_call_quick_loop:NN
+ \__unravel_macro_call_quick_loop:NNN
+ #3
+ }
+\cs_new_protected:Npn \__unravel_macro_call_quick_runaway:Nw #1#2 \q_stop
+ {
+ \msg_error:nnxx { unravel } { runaway-macro-parameter }
+ { \tl_to_str:N \l__unravel_head_tl } { \tl_to_str:n {#1} }
}
\cs_new_protected_nopar:Npn \__unravel_expand:
{
\__unravel_set_action_text:
- \bool_if:NT \l__unravel_debug_bool
+ \bool_if:NT \g__unravel_internal_debug_bool
{
\__unravel_set_cmd:
\iow_term:x { Exp:~\int_use:N \l__unravel_head_cmd_int }
@@ -1527,7 +1615,7 @@
}
{
\msg_error:nn { unravel } { missing-font-id }
- \__unravel_prev_input:n { \tex_nullfont:D }
+ \__unravel_prev_input:n { \__unravel_nullfont: }
\__unravel_back_error:
}
}
@@ -1573,7 +1661,7 @@
\__unravel_prev_input_silent:V \l__unravel_tmpa_tl
\__unravel_set_action_text:
\__unravel_set_action_text:x
- { \g__unravel_action_text_str = ~ \tl_to_str:N \l__unravel_tmpa_tl }
+ { \g__unravel_action_text_str \use:n { ~ => ~ } \tl_to_str:N \l__unravel_tmpa_tl }
\int_compare:nNnF {#3} > { 3 } { \__unravel_print_action: }
\int_gset:Nn \g__unravel_val_level_int {#1}
}
@@ -1592,7 +1680,7 @@
{ 76 } { 3 } % assign_mu_glue
{ 77 } { 1 \__unravel_scan_font_dimen: } % assign_font_dimen
{ 78 } { 0 \__unravel_scan_font_int: } % assign_font_int
- { 79 } { 0 } % set_aux
+ { 79 } { \__unravel_thing_set_aux: } % set_aux
{ 80 } { 0 } % set_prev_graf
{ 81 } { 1 } % set_page_dimen
{ 82 } { 0 } % set_page_int
@@ -1606,6 +1694,8 @@
}
{ 8 }
}
+\cs_new_nopar:Npn \__unravel_thing_set_aux:
+ { \int_compare:nNnTF \l__unravel_head_char_int = { 1 } { 1 } { 0 } }
\cs_new_nopar:Npn \__unravel_thing_last_item:
{
\int_compare:nNnTF \l__unravel_head_char_int < { 26 }
@@ -1669,7 +1759,7 @@
{ 2 } \skip_eval:n
{ 3 } \muskip_eval:n
}
- { \tex_the:D }
+ { \__unravel_the:w }
}
\cs_new_protected:Npn \__unravel_scan_expr:N #1
{ \__unravel_scan_expr_aux:NN #1 \c_false_bool }
@@ -1760,16 +1850,9 @@
{
\__unravel_scan_signs:
\__unravel_set_cmd:
- \int_compare:nNnTF
- \l__unravel_head_cmd_int < { \__unravel_tex_use:n { min_internal } }
+ \__unravel_cmd_if_internal:TF
+ { \__unravel_scan_something_internal:n { 0 } }
{ \__unravel_scan_int_char: }
- {
- \int_compare:nNnTF
- \l__unravel_head_cmd_int
- > { \__unravel_tex_use:n { max_internal } }
- { \__unravel_scan_int_char: }
- { \__unravel_scan_something_internal:n { 0 } }
- }
}
\cs_new_protected_nopar:Npn \__unravel_scan_int_char:
{
@@ -1825,50 +1908,43 @@
}
}
\cs_new_protected_nopar:Npn \__unravel_scan_normal_dimen:
- { \__unravel_scan_dimen:NN \c_false_bool \c_false_bool }
-\cs_new_protected:Npn \__unravel_scan_dimen:NN #1#2
+ { \__unravel_scan_dimen:nN { 2 } \c_false_bool }
+\cs_new_protected:Npn \__unravel_scan_dimen:nN #1#2
{
\__unravel_scan_signs:
\seq_gput_right:Nn \g__unravel_prev_input_seq { }
\__unravel_set_cmd:
- \int_compare:nNnTF
- \l__unravel_head_cmd_int < { \__unravel_tex_use:n { min_internal } }
- { \__unravel_scan_dimen_char:NN #1#2 }
+ \__unravel_cmd_if_internal:TF
{
- \int_compare:nNnTF
- \l__unravel_head_cmd_int
- > { \__unravel_tex_use:n { max_internal } }
- { \__unravel_scan_dimen_char:NN #1#2 }
+ \int_compare:nNnTF {#1} = { 3 }
{
- \bool_if:NTF #1
+ \__unravel_scan_something_internal:n { 3 }
+ \int_case:nnF \g__unravel_val_level_int
{
- \__unravel_scan_something_internal:n { 3 }
- \int_case:nnF \g__unravel_val_level_int
- {
- { 0 } { \__unravel_scan_dim_unit:NN #1 #2 }
- { 3 } { }
- }
- {
- \msg_error:nn { unravel } { incompatible-units }
- % ^^A todo: error recovery
- }
+ { 0 } { \__unravel_scan_dim_unit:nN {#1} #2 }
+ { 3 } { }
}
{
- \__unravel_scan_something_internal:n { 2 }
- \int_case:nnF \g__unravel_val_level_int
- {
- { 0 } { \__unravel_scan_dim_unit:NN #1#2 }
- { 3 } % ^^A todo: error recovery
- { \msg_error:nn { unravel } { incompatible-units } }
- }
- { }
+ \msg_error:nn { unravel } { incompatible-units }
+ % ^^A todo: error recovery
}
}
+ {
+ \__unravel_scan_something_internal:n { 1 }
+ \int_case:nnF \g__unravel_val_level_int
+ {
+ { 0 } { \__unravel_scan_dim_unit:nN {#1} #2 }
+ { 3 } % ^^A todo: error recovery
+ { \msg_error:nn { unravel } { incompatible-units } }
+ }
+ { }
+ }
}
+ { \__unravel_scan_dimen_char:nN {#1} #2 }
\seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
\__unravel_prev_input_silent:V \l__unravel_head_tl
}
-\cs_new_protected:Npn \__unravel_scan_dimen_char:NN #1#2
+\cs_new_protected:Npn \__unravel_scan_dimen_char:nN #1#2
{
\tl_if_eq:NNT \l__unravel_head_tl \c__unravel_comma_tl
{ \tl_set_eq:NN \l__unravel_head_tl \c__unravel_point_tl }
@@ -1896,9 +1972,9 @@
\__unravel_scan_int:
}
}
- \__unravel_scan_dim_unit:NN #1#2
+ \__unravel_scan_dim_unit:nN {#1} #2
}
-\cs_new_protected:Npn \__unravel_scan_dim_unit:NN #1#2
+\cs_new_protected:Npn \__unravel_scan_dim_unit:nN #1#2
{
\bool_if:NT #2
{
@@ -1910,35 +1986,16 @@
}
\__unravel_get_x_non_blank:
\__unravel_set_cmd:
- \int_compare:nNnTF
- \l__unravel_head_cmd_int < { \__unravel_tex_use:n { min_internal } }
- { \__unravel_back_input: }
+ \__unravel_cmd_if_internal:TF
{
- \int_compare:nNnTF
- \l__unravel_head_cmd_int
- > { \__unravel_tex_use:n { max_internal } }
- { \__unravel_back_input: }
- {
- \seq_gput_right:Nn \g__unravel_prev_input_seq { }
- \bool_if:NTF #1
- { \__unravel_scan_something_internal:n { 3 } }
- { \__unravel_scan_something_internal:n { 2 } }
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_tmpa_tl
- \tl_set:Nx \l__unravel_tmpa_tl
- {
- \bool_if:NTF #1 \muskip_eval:n \skip_eval:n
- {
- \l__unravel_tmpa_tl
- \bool_if:NTF #1 \etex_muexpr:D \etex_glueexpr:D
- \l__unravel_head_tl
- }
- }
- \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_tmpa_tl
- \__unravel_break:w
- }
+ \seq_gput_right:Nn \g__unravel_prev_input_seq { }
+ \__unravel_scan_something_internal:n {#1}
+ \__unravel_prev_input_join_get:nN {#1} \l__unravel_tmpa_tl
+ \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_tmpa_tl
+ \__unravel_break:w
}
- \bool_if:NT #1
+ { \__unravel_back_input: }
+ \int_compare:nNnT {#1} = { 3 }
{
\__unravel_scan_keyword:nT { mM uU } { \__unravel_break:w }
\msg_error:nn { unravel } { missing-mudim }
@@ -1985,47 +2042,34 @@
{ \__unravel_scan_glue:n { 3 } }
\cs_new_protected:Npn \__unravel_scan_glue:n #1
{
- \int_compare:nNnTF {#1} = { 2 }
- { \__unravel_scan_glue_aux:nN {#1} \c_false_bool }
- { \__unravel_scan_glue_aux:nN {#1} \c_true_bool }
- }
-\cs_new_protected:Npn \__unravel_scan_glue_aux:nN #1#2
- {
+ \seq_gput_right:Nn \g__unravel_prev_input_seq { }
\__unravel_scan_signs:
\seq_gput_right:Nn \g__unravel_prev_input_seq { }
\__unravel_set_cmd:
- \int_compare:nNnTF
- \l__unravel_head_cmd_int < { \__unravel_tex_use:n { min_internal } }
- { \__unravel_back_input: \__unravel_scan_dimen:NN #2 \c_false_bool }
+ \__unravel_cmd_if_internal:TF
{
- \int_compare:nNnTF
- \l__unravel_head_cmd_int
- > { \__unravel_tex_use:n { max_internal } }
+ \__unravel_scan_something_internal:n {#1}
+ \int_case:nnF \g__unravel_val_level_int
{
- \__unravel_back_input:
- \__unravel_scan_dimen:NN #2 \c_false_bool
+ { 0 } { \__unravel_scan_dimen:nN {#1} \c_false_bool }
+ {#1} { \__unravel_break:w }
}
{
- \__unravel_scan_something_internal:n {#1}
- \int_case:nnF \g__unravel_val_level_int
- {
- { 0 } { \__unravel_scan_dimen:NN #2 \c_false_bool }
- { 1 } { \bool_if:NT #2 { \msg_error: } } % ^^A todo: ??
- }
- {
- \int_compare:nNnF \g__unravel_val_level_int = {#1}
- { \msg_error:nn { unravel } { incompatible-units } }
- \__unravel_break:w
- }
+ \int_compare:nNnF { \g__unravel_val_level_int + #1 } = 3
+ { \msg_error:nn { unravel } { incompatible-units } }
}
}
+ { \__unravel_back_input: \__unravel_scan_dimen:nN {#1} \c_false_bool }
+ \__unravel_prev_input_join_get:nN {#1} \l__unravel_tmpa_tl
+ \seq_gput_right:Nn \g__unravel_prev_input_seq { }
+ \seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_tmpa_tl
\__unravel_scan_keyword:nT { pP lL uU sS }
- { \__unravel_scan_dimen:NN #2 \c_true_bool }
+ { \__unravel_scan_dimen:nN {#1} \c_true_bool }
\__unravel_scan_keyword:nT { mM iI nN uU sS }
- { \__unravel_scan_dimen:NN #2 \c_true_bool }
+ { \__unravel_scan_dimen:nN {#1} \c_true_bool }
\__unravel_break_point:
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
- \__unravel_prev_input_silent:V \l__unravel_head_tl
+ \__unravel_prev_input_join_get:nN {#1} \l__unravel_tmpa_tl
+ \__unravel_prev_input_silent:V \l__unravel_tmpa_tl
}
\cs_new_protected_nopar:Npn \__unravel_scan_file_name:
{
@@ -2235,11 +2279,12 @@
{
\bool_if:NTF #1
{
- \__unravel_cs_case:NnF \l__unravel_head_token
+ \int_case:nnTF \l__unravel_head_cmd_int
{
- \tex_hrule:D { \__unravel_do_leaders_rule: }
- \tex_vrule:D { \__unravel_do_leaders_rule: }
+ { \__unravel_tex_use:n { hrule } } { }
+ { \__unravel_tex_use:n { vrule } } { }
}
+ { \__unravel_do_leaders_rule: }
{ \__unravel_do_box_error: }
}
{ \__unravel_do_box_error: }
@@ -2304,7 +2349,7 @@
}
\cs_new_protected:Npn \__unravel_do_box_explicit:N #1
{
- \token_if_eq_meaning:NNTF \l__unravel_head_token \tex_hbox:D
+ \token_if_eq_meaning:NNTF \l__unravel_head_token \__unravel_hbox:w
{ \__unravel_box_hook:N \tex_everyhbox:D }
{ \__unravel_box_hook:N \tex_everyvbox:D }
% ^^A todo: TeX calls |normal_paragraph| here.
@@ -2339,7 +2384,7 @@
\__unravel_print_action:
\__unravel_back_input:o {##1}
\__unravel_set_action_text:x
- { \token_to_meaning:N #1 \tl_to_str:o {##1} }
+ { \token_to_meaning:N #1 = \tl_to_str:o {##1} }
\tl_if_empty:oF {##1} { \__unravel_print_action: }
}
}
@@ -2363,42 +2408,29 @@
{ \prg_return_true: }
{ \prg_return_false: }
}
-\group_begin:
- \char_set_catcode_other:n { 0 }
- \cs_new_protected:Npn \__unravel_char:n #1
- {
- \tex_char:D #1 \scan_stop:
- \__unravel_charcode_if_safe:nTF {#1}
- {
- \group_begin:
- \char_set_lccode:nn { 0 } {#1}
- \tex_lowercase:D
- { \group_end: \tl_set:Nn \l__unravel_tmpa_tl { ^^@ } }
- }
- {
- \tl_set:Nx \l__unravel_tmpa_tl
- { \exp_not:N \char \int_eval:n {#1} ~ }
- }
- \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_tmpa_tl
- \__unravel_print_action:x { \tl_to_str:N \l__unravel_tmpa_tl }
- }
-\group_end:
+\cs_new_protected:Npn \__unravel_char:n #1
+ {
+ \tex_char:D #1 \scan_stop:
+ \__unravel_charcode_if_safe:nTF {#1}
+ { \tl_set:Nx \l__unravel_tmpa_tl { \char_generate:nn {#1} { 12 } } }
+ {
+ \tl_set:Nx \l__unravel_tmpa_tl
+ { \exp_not:N \char \int_eval:n {#1} ~ }
+ }
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_tmpa_tl
+ \__unravel_print_action:x { \tl_to_str:N \l__unravel_tmpa_tl }
+ }
\cs_generate_variant:Nn \__unravel_char:n { V , x }
-\group_begin:
- \char_set_catcode_other:n { 0 }
- \cs_new_protected:Npn \__unravel_char_in_mmode:n #1
- {
- \int_compare:nNnTF { \tex_mathcode:D #1 } = { "8000 }
- { % math active
- \group_begin:
- \char_set_lccode:nn { 0 } { \l__unravel_tmpa_tl }
- \tex_lowercase:D
- { \group_end: \gtl_set:Nn \l__unravel_head_gtl { ^^@ } }
- \__unravel_back_input:
- }
- { \__unravel_char:n {#1} }
- }
-\group_end:
+\cs_new_protected:Npn \__unravel_char_in_mmode:n #1
+ {
+ \int_compare:nNnTF { \tex_mathcode:D #1 } = { "8000 }
+ { % math active
+ \gtl_set:Nx \l__unravel_head_gtl
+ { \char_generate:nn {#1} { 12 } }
+ \__unravel_back_input:
+ }
+ { \__unravel_char:n {#1} }
+ }
\cs_generate_variant:Nn \__unravel_char_in_mmode:n { V , x }
\cs_new_protected:Npn \__unravel_mathchar:n #1
{
@@ -2411,10 +2443,10 @@
\cs_generate_variant:Nn \__unravel_mathchar:n { x }
\cs_new_protected:Npn \__unravel_new_graf:N #1
{
- \tl_set:NV \l__unravel_tmpa_tl \tex_everypar:D
- \tex_everypar:D { }
+ \tl_set:NV \l__unravel_tmpa_tl \__unravel_everypar:w
+ \__unravel_everypar:w { }
\bool_if:NTF #1 { \tex_indent:D } { \tex_noindent:D }
- \exp_args:NV \tex_everypar:D \l__unravel_tmpa_tl
+ \exp_args:NV \__unravel_everypar:w \l__unravel_tmpa_tl
\__unravel_back_input:V \l__unravel_tmpa_tl
\__unravel_print_action:x
{
@@ -2435,7 +2467,7 @@
}
\cs_new_protected_nopar:Npn \__unravel_handle_left_brace:
{
- \int_case:nnF \etex_currentgrouptype:D
+ \int_case:nnF \__unravel_currentgrouptype:
{
{ 1 } { \__unravel_end_simple_group: } % simple
{ 2 } { \__unravel_end_box_group: } % hbox
@@ -2445,7 +2477,7 @@
{ 6 } { \__unravel_end_align_group: } % align
{ 7 } { \__unravel_end_no_align_group: } % no_align
{ 8 } { \__unravel_end_output_group: } % output
- { 9 } { \__unravel_end_math_group: } % math
+ { 9 } { \__unravel_end_simple_group: } % math
{ 10 } { \__unravel_end_disc_group: } % disc
{ 11 } { \__unravel_end_graf: \__unravel_end_simple_group: } % insert
{ 12 } { \__unravel_end_graf: \__unravel_end_simple_group: } % vcenter
@@ -2487,14 +2519,14 @@
}
\cs_new_protected_nopar:Npn \__unravel_off_save:
{
- \int_compare:nNnTF \etex_currentgrouptype:D = { 0 }
+ \int_compare:nNnTF \__unravel_currentgrouptype: = { 0 }
{ % bottom-level
\msg_error:nnx { unravel } { extra-close }
{ \token_to_meaning:N \l__unravel_head_token }
}
{
\__unravel_back_input:
- \int_case:nnF \etex_currentgrouptype:D
+ \int_case:nnF \__unravel_currentgrouptype:
{
{ 14 } % semi_simple_group
{ \gtl_set:Nn \l__unravel_head_gtl { \group_end: } }
@@ -2542,10 +2574,44 @@
\__unravel_back_input:
}
}
+\cs_new_protected_nopar:Npn \__unravel_goto_inner_math:
+ {
+ \__unravel_box_hook:N \tex_everymath:D
+ $ % $
+ \__unravel_box_hook_end:
+ }
+\cs_new_protected_nopar:Npn \__unravel_goto_display_math:
+ {
+ \__unravel_box_hook:N \tex_everydisplay:D
+ $ $
+ \__unravel_box_hook_end:
+ }
+\cs_new_protected_nopar:Npn \__unravel_after_math:
+ {
+ \mode_if_inner:TF
+ {
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
+ $ % $
+ }
+ {
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
+ \__unravel_get_x_next:
+ \token_if_eq_catcode:NNF
+ \l__unravel_head_token \c_math_toggle_token
+ {
+ \__unravel_back_input:
+ \tl_set:Nn \l__unravel_head_tl { $ } % $
+ \msg_error:nn { unravel } { missing-dollar }
+ }
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
+ $ $
+ }
+ \__unravel_print_action:
+ }
\cs_new_protected_nopar:Npn \__unravel_do_step:
{
\__unravel_set_action_text:
- \bool_if:NT \l__unravel_debug_bool
+ \bool_if:NT \g__unravel_internal_debug_bool
{ \iow_term:x { Cmd:~\int_use:N \l__unravel_head_cmd_int } }
\cs_if_exist_use:cF
{ __unravel_cmd_ \int_use:N \l__unravel_head_cmd_int : }
@@ -2569,18 +2635,23 @@
\mode_if_math:TF
{
\int_compare:nNnTF
- \etex_currentgrouplevel:D = { 15 } % math_shift_group
+ \__unravel_currentgrouptype: = { 15 } % math_shift_group
{ \__unravel_after_math: }
{ \__unravel_off_save: }
}
{
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
\__unravel_get_next:
\token_if_eq_catcode:NNTF
\l__unravel_head_token \c_math_toggle_token
{
\mode_if_inner:TF
{ \__unravel_back_input: \__unravel_goto_inner_math: }
- { \__unravel_goto_display_math: }
+ {
+ \gtl_gput_right:NV
+ \g__unravel_output_gtl \l__unravel_head_tl
+ \__unravel_goto_display_math:
+ }
}
{ \__unravel_back_input: \__unravel_goto_inner_math: }
}
@@ -2600,10 +2671,45 @@
{
\seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_head_tl
\__unravel_print_action:
- \__unravel_scan_math:
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
- \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
- \tl_use:N \l__unravel_head_tl \scan_stop:
+ \__unravel_get_x_non_relax:
+ \__unravel_set_cmd:
+ \int_case:nnTF \l__unravel_head_cmd_int
+ {
+ { \__unravel_tex_use:n { the_char } }
+ { \__unravel_prev_input:V \l__unravel_head_tl }
+ { \__unravel_tex_use:n { other_char } }
+ { \__unravel_prev_input:V \l__unravel_head_tl }
+ { \__unravel_tex_use:n { char_given } }
+ { \__unravel_prev_input:V \l__unravel_head_tl }
+ { \__unravel_tex_use:n { char_num } }
+ {
+ \__unravel_prev_input:V \l__unravel_head_tl
+ \__unravel_scan_int:
+ }
+ { \__unravel_tex_use:n { math_char_num } }
+ {
+ \__unravel_prev_input:V \l__unravel_head_tl
+ \__unravel_scan_int:
+ }
+ { \__unravel_tex_use:n { math_given } }
+ { \__unravel_prev_input:V \l__unravel_head_tl }
+ { \__unravel_tex_use:n { delim_num } }
+ { \__unravel_prev_input:V \l__unravel_head_tl \__unravel_scan_int: }
+ }
+ {
+ \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
+ \tl_use:N \l__unravel_head_tl \scan_stop:
+ }
+ {
+ \__unravel_back_input:
+ \__unravel_scan_left_brace:
+ \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
+ \gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
+ \gtl_gconcat:NNN \g__unravel_output_gtl
+ \g__unravel_output_gtl \c_group_begin_gtl
+ \tl_use:N \l__unravel_head_tl \c_group_begin_token
+ }
\__unravel_print_action:x { \tl_to_str:N \l__unravel_head_tl }
}
\__unravel_new_tex_cmd:nn { endv } % 9
@@ -2657,7 +2763,7 @@
\__unravel_back_input:
\__unravel_back_input:n
{
- \tex_hbox:D to \tex_hsize:D { }
+ \__unravel_hbox:w to \tex_hsize:D { }
\tex_vfill:D
\tex_penalty:D - '10000000000 ~
}
@@ -2823,8 +2929,8 @@
\seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_head_tl
\__unravel_print_action:
\token_if_eq_meaning:NNTF \l__unravel_head_token \tex_kern:D
- { \__unravel_scan_dimen:NN \c_true_bool \c_false_bool }
- { \__unravel_scan_dimen:NN \c_false_bool \c_false_bool }
+ { \__unravel_scan_dimen:nN { 2 } \c_false_bool }
+ { \__unravel_scan_dimen:nN { 3 } \c_false_bool }
\seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
\tl_use:N \l__unravel_head_tl \scan_stop:
\__unravel_print_action:x { \tl_to_str:N \l__unravel_head_tl }
@@ -2908,7 +3014,7 @@
{
\int_compare:nNnT \l__unravel_head_char_int = { 1 } % indent
{
- \tex_hbox:D width \tex_parindent:D { }
+ \__unravel_hbox:w width \tex_parindent:D { }
\gtl_gput_right:NV \g__unravel_output_gtl \l__unravel_head_tl
}
\__unravel_print_action:
@@ -3563,7 +3669,7 @@
{ \__unravel_scan_font_int: } { \__unravel_scan_int: }
}
\__unravel_prefixed_new:nn { set_aux } % 79
- { % prevdepth = 1, spacefactor = 0
+ { % prevdepth = 1, spacefactor = 102
\int_compare:nNnTF \l__unravel_head_char_int = \c_one
{ \__unravel_assign_value:nn { } { \__unravel_scan_normal_dimen: } }
{ \__unravel_assign_value:nn { } { \__unravel_scan_int: } }
@@ -3737,25 +3843,34 @@
\__unravel_prefixed_new:nn { set_interaction } % 100
{
\seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_tmpa_tl
- \tl_put_right:NV \l__unravel_head_tl \l__unravel_tmpa_tl
+ \tl_put_left:NV \l__unravel_head_tl \l__unravel_tmpa_tl
\tl_use:N \l__unravel_head_tl \scan_stop:
\__unravel_print_action:x { \tl_to_str:N \l__unravel_head_tl }
}
\__unravel_prefixed_new:nn { letterspace_font } % 101
{
- % ^^A todo...
- % new_letterspaced_font(a);
- \msg_error:nnx { unravel } { not-implemented } { letterspace-font }
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
- \__unravel_omit_after_assignment:w
+ \__unravel_prev_input_silent:V \l__unravel_head_tl
+ \__unravel_set_action_text:x { \tl_to_str:N \l__unravel_head_tl }
+ \__unravel_scan_r_token:
+ \__unravel_print_action:x
+ { \g__unravel_action_text_str \tl_to_str:N \l__unravel_defined_tl }
+ \exp_after:wN \cs_set_eq:NN \l__unravel_defined_tl \__unravel_nullfont:
+ \__unravel_scan_optional_equals:
+ \__unravel_scan_font_ident:
+ \__unravel_scan_int:
+ \__unravel_assign_token:n { }
}
\__unravel_prefixed_new:nn { pdf_copy_font } % 102
{
- % ^^A todo...
- % make_font_copy(a);
- \msg_error:nnx { unravel } { not-implemented } { pdf-copy-font }
- \seq_gpop_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
- \__unravel_omit_after_assignment:w
+ \__unravel_prev_input_silent:V \l__unravel_head_tl
+ \__unravel_set_action_text:x { \tl_to_str:N \l__unravel_head_tl }
+ \__unravel_scan_r_token:
+ \__unravel_print_action:x
+ { \g__unravel_action_text_str \tl_to_str:N \l__unravel_defined_tl }
+ \exp_after:wN \cs_set_eq:NN \l__unravel_defined_tl \__unravel_nullfont:
+ \__unravel_scan_optional_equals:
+ \__unravel_scan_font_ident:
+ \__unravel_assign_token:n { }
}
\__unravel_prefixed_new:nn { register } % 89
{ \__unravel_do_register:N \c_zero }
@@ -3938,7 +4053,7 @@
{
\int_case:nnF \l__unravel_head_char_int
{
- { 1 } { \__unravel_print_action: } % \endinput
+ { 1 } { \__unravel_endinput: } % \endinput
{ 2 } { \__unravel_scantokens: } % \scantokens
}
{ % 0=\input
@@ -3946,6 +4061,11 @@
{ \__unravel_insert_relax: } { \__unravel_input: }
}
}
+\cs_new_protected_nopar:Npn \__unravel_endinput:
+ {
+ \msg_warning:nn { unravel } { endinput-ignored }
+ \__unravel_print_action:
+ }
\cs_new_protected_nopar:Npn \__unravel_scantokens:
{
\seq_gput_right:Nn \g__unravel_prev_input_seq { }
@@ -4142,7 +4262,7 @@
\fi:
\int_incr:N \l__unravel_if_nesting_int
\fi:
- \__unravel_input_gpop:N \l__unravel_tmpa_gtl
+ \__unravel_input_gpop:N \l__unravel_unused_gtl
\int_compare:nNnTF \l__unravel_if_nesting_int = \c_zero
{ \__unravel_pass_text: }
{ \__unravel_pass_text_nested: }
@@ -4334,7 +4454,7 @@
{
\seq_gput_right:NV \g__unravel_prev_input_seq \l__unravel_head_tl
\__unravel_print_action:
- \bool_if:NT \l__unravel_debug_bool { \iow_term:n { {\ifcase level~#1} } }
+ \bool_if:NT \g__unravel_internal_debug_bool { \iow_term:n { {\ifcase level~#1} } }
\__unravel_scan_int:
\seq_get_right:NN \g__unravel_prev_input_seq \l__unravel_head_tl
\tl_set:Nx \l__unravel_head_tl { \tl_tail:N \l__unravel_head_tl }
@@ -4433,7 +4553,7 @@
\cs_new_protected:Npn \__unravel_set_action_text:x #1
{
\group_begin:
- \int_set:Nn \tex_escapechar:D { 92 }
+ \__unravel_set_escapechar:n { 92 }
\str_gset:Nx \g__unravel_action_text_str {#1}
\group_end:
}
@@ -4449,7 +4569,8 @@
\cs_new_protected:Npn \__unravel_print_state:
{
\group_begin:
- \int_set:Nn \tex_escapechar:D { 92 }
+ \__unravel_set_escapechar:n { 92 }
+ \tl_use:N \g__unravel_before_print_state_tl
\int_compare:nNnT \g__unravel_noise_int > \c_zero
{
\exp_args:Nx \__unravel_print_state_output:n
@@ -4469,66 +4590,16 @@
{
\tl_if_empty:nF {#1}
{
- \int_set:Nn \l__unravel_print_int { \str_count:n {#1} }
\__unravel_print_message:nn { <| ~ }
- {
- \int_compare:nNnTF
- \l__unravel_print_int > \g__unravel_max_output_int
- {
- (
- \int_eval:n
- {
- \l__unravel_print_int
- - \g__unravel_max_output_int + 14
- } ~
- chars
- )~
- ...
- \str_substr:nnn {#1}
- { \l__unravel_print_int - \g__unravel_max_output_int + 15 }
- { \l__unravel_print_int }
- }
- {#1}
- }
+ { \__unravel_str_truncate_left:nn {#1} { \g__unravel_max_output_int } }
}
}
\cs_new_protected:Npn \__unravel_print_state_prev:n #1
- {
- % \int_set:Nn \l__unravel_print_int { \str_count:n {#1} }
- \__unravel_print_message:nn { || ~ } {#1}
- % {
- % \int_compare:nNnTF \l__unravel_print_int > \g__unravel_max_prev_int
- % {
- % (
- % \int_eval:n
- % { \l__unravel_print_int - \g__unravel_max_prev_int + 14 } ~
- % chars
- % )~
- % ...
- % \str_substr:nnn {#1}
- % { \l__unravel_print_int - \g__unravel_max_prev_int + 15 }
- % { \l__unravel_print_int }
- % }
- % {#1}
- % }
- }
+ { \__unravel_print_message:nn { || ~ } {#1} }
\cs_new_protected:Npn \__unravel_print_state_input:n #1
{
- \int_set:Nn \l__unravel_print_int { \str_count:n {#1} }
\__unravel_print_message:nn { |> ~ }
- {
- \int_compare:nNnTF \l__unravel_print_int > \g__unravel_max_input_int
- {
- \str_substr:nnn {#1} { 1 } { \g__unravel_max_input_int - 14 }
- ...~
- (
- \int_eval:n
- { \l__unravel_print_int - \g__unravel_max_input_int + 14 } ~
- chars
- )
- }
- {#1}
- }
+ { \__unravel_str_truncate_right:nn {#1} { \g__unravel_max_input_int } }
}
\cs_new_protected:Npn \__unravel_print_meaning:
{
@@ -4546,21 +4617,20 @@
\cs_new_protected:Npn \__unravel_print_action:
{
\int_gincr:N \g__unravel_step_int
- \__unravel_print_message:nn { }
+ \__unravel_print:x
{
- % \\
- [=====~ Step~ \int_use:N \g__unravel_step_int \ =====]~
+ [=====
+ \bool_if:NT \g__unravel_number_steps_bool
+ { ~ Step ~ \int_use:N \g__unravel_step_int \ }
+ =====]~
\int_compare:nNnTF
{ \str_count:N \g__unravel_action_text_str }
> { \g__unravel_max_action_int }
{
- \str_substr:Nnn \g__unravel_action_text_str
+ \str_range:Nnn \g__unravel_action_text_str
{ 1 } { \g__unravel_max_action_int - 3 } ...
}
{ \g__unravel_action_text_str }
- % \\
- % \ \ < \int_use:N \g__unravel_input_int > % ^^A todo: remove
- % \ < \seq_count:N \g__unravel_prev_input_seq > % ^^A todo: remove
}
\__unravel_print_state:
}
@@ -4592,7 +4662,7 @@
Set~ \exp_after:wN \token_to_str:N \l__unravel_defined_tl
\tl_if_single:NT \l__unravel_defined_tl
{ ( \exp_after:wN \token_to_meaning:N \l__unravel_defined_tl ) }
- = \exp_after:wN \tex_the:D \l__unravel_defined_tl
+ = \exp_after:wN \__unravel_the:w \l__unravel_defined_tl
}
\__unravel_omit_after_assignment:w
}
@@ -4600,44 +4670,47 @@
{
\__unravel_print_message:nn { }
{
- \\
- ========~ Welcome~ to~ the~ unravel~ package~ ========\\
- \iow_indent:n
+ \bool_if:NTF \g__unravel_welcome_message_bool
{
- "<|"~ denotes~ the~ output~ to~ TeX's~ stomach. \\
- "||"~ denotes~ tokens~ waiting~ to~ be~ used. \\
- "|>"~ denotes~ tokens~ that~ we~ will~ act~ on. \\
- Press~<enter>~to~continue;~'h'~<enter>~for~help. \\
+ \\
+ ========~ Welcome~ to~ the~ unravel~ package~ ========\\
+ \iow_indent:n
+ {
+ "<|"~ denotes~ the~ output~ to~ TeX's~ stomach. \\
+ "||"~ denotes~ tokens~ waiting~ to~ be~ used. \\
+ "|>"~ denotes~ tokens~ that~ we~ will~ act~ on. \\
+ Press~<enter>~to~continue;~'h'~<enter>~for~help. \\
+ }
}
+ { [=====~Start~=====] }
}
\__unravel_print_state:
}
\cs_new_protected_nopar:Npn \__unravel_print_outcome:
- {
- % \int_gset_eq:NN \g__unravel_max_input_int \c_max_int
- % \int_gset_eq:NN \g__unravel_max_prev_int \c_max_int
- % \int_gset_eq:NN \g__unravel_max_output_int \c_max_int
- % \__unravel_print_state:
- \__unravel_print_message:nn { } { [=====~The~end!~=====] \\ }
- }
+ { \__unravel_print:n { [=====~End~=====] } }
\cs_new_protected_nopar:Npn \__unravel_prompt:
{
\int_gdecr:N \g__unravel_nonstop_int
\int_compare:nNnF \g__unravel_nonstop_int > \c_zero
{
\group_begin:
- \int_set_eq:NN \tex_escapechar:D \c_minus_one
+ \__unravel_set_escapechar:n { -1 }
\int_set_eq:NN \tex_endlinechar:D \c_minus_one
- \tl_use:N \g__unravel_prompt_before_tl
- \tl_gclear:N \g__unravel_prompt_before_tl
+ \tl_use:N \g__unravel_before_prompt_tl
\__unravel_prompt_aux:
\group_end:
}
}
\cs_new_protected_nopar:Npn \__unravel_prompt_aux:
{
- \ior_get_str:Nc \g__unravel_prompt_ior { Your~input }
- \exp_args:Nv \__unravel_prompt_treat:n { Your~input }
+ \int_compare:nNnT { \etex_interactionmode:D } = { 3 }
+ {
+ \bool_if:NTF \g__unravel_explicit_prompt_bool
+ { \ior_get_str:Nc \c__unravel_prompt_ior }
+ { \ior_get_str:Nc \c__unravel_noprompt_ior }
+ { Your~input }
+ \exp_args:Nv \__unravel_prompt_treat:n { Your~input }
+ }
}
\cs_new_protected:Npn \__unravel_prompt_treat:n #1
{
@@ -4669,6 +4742,9 @@
{ \tl_gclear:N \g__unravel_tmpc_tl }
\group_insert_after:N \g__unravel_tmpc_tl
}
+ { | } { \__unravel_prompt_scan_int:nn {#1}
+ \__unravel_prompt_vert:n }
+ { a } { \__unravel_prompt_all: }
}
{ \__unravel_prompt_help: }
}
@@ -4676,7 +4752,9 @@
\cs_new_protected:Npn \__unravel_prompt_scan_int:nn #1
{
\tex_afterassignment:D \__unravel_prompt_scan_int_after:wn
- \l__unravel_prompt_tmpa_int = 0 \use_none:n #1 \scan_stop:
+ \l__unravel_prompt_tmpa_int =
+ \tl_if_head_eq_charcode:fNF { \use_none:n #1 } - { 0 }
+ \use_ii:nn #1 \scan_stop:
}
\cs_new_protected:Npn \__unravel_prompt_scan_int_after:wn #1 \scan_stop: #2
{
@@ -4686,44 +4764,159 @@
\cs_new_protected:Npn \__unravel_prompt_help:
{
\__unravel_print:n { "m":~meaning~of~first~token }
- \__unravel_print:n { "q":~semi-quiet }
- \__unravel_print:n { "x":~exit~this~instance~of~unravel }
- \__unravel_print:n { "X":~try~harder~to~exit }
+ \__unravel_print:n { "q":~semi-quiet~(same~as~"o1") }
+ \__unravel_print:n { "x"/"X":~exit~this~instance~of~unravel/TeX }
\__unravel_print:n { "s<num>":~do~<num>~steps~silently }
\__unravel_print:n
- { "o<num>":~0~=>~only~log~not~online,~1~=>~both,~-1~=>~neither.}
- \__unravel_print:n { "C<code>":~run~some~code~immediately }
+ { "o<num>":~1~=>~log~and~terminal,~0~=>~only~log,~-1~=>~neither.}
+ \__unravel_print:n { "C<code>":~run~some~expl3~code~immediately }
+ \__unravel_print:n { "|<num>":~silent~steps~until~<num>~fewer~"||" }
+ \__unravel_print:n { "a":~print~state~again,~without~truncating }
\__unravel_prompt_aux:
}
\cs_new_protected:Npn \__unravel_prompt_silent_steps:n #1
{
+ \int_compare:nNnF {#1} < \c_zero
+ {
+ \int_gset_eq:NN \g__unravel_noise_int \c_minus_one
+ \tl_gset:Nn \g__unravel_before_prompt_tl
+ {
+ \int_gset_eq:NN \g__unravel_noise_int \c_one
+ \tl_gclear:N \g__unravel_before_prompt_tl
+ }
+ \int_gset:Nn \g__unravel_nonstop_int {#1}
+ }
+ }
+\cs_new_protected:Npn \__unravel_prompt_vert:n #1
+ {
+ \int_compare:nNnTF {#1} < { 0 }
+ { \__unravel_prompt_vert:Nn > {#1} }
+ { \__unravel_prompt_vert:Nn < {#1} }
+ }
+\cs_new_protected:Npn \__unravel_prompt_vert:Nn #1#2
+ {
\int_gset_eq:NN \g__unravel_noise_int \c_minus_one
- \tl_gset:Nn \g__unravel_prompt_before_tl
- { \int_gset_eq:NN \g__unravel_noise_int \c_one }
- \int_gset:Nn \g__unravel_nonstop_int {#1}
+ \tl_gset:Nf \g__unravel_before_print_state_tl
+ {
+ \exp_args:NNf \exp_stop_f: \int_compare:nNnTF
+ { \int_eval:n { \seq_count:N \g__unravel_prev_input_seq - #2 } }
+ #1 { \seq_count:N \g__unravel_prev_input_seq }
+ {
+ \int_gset:Nn \g__unravel_nonstop_int
+ { \int_max:nn { \g__unravel_nonstop_int } { 2 } }
+ }
+ {
+ \int_gset_eq:NN \g__unravel_noise_int \c_one
+ \tl_gclear:N \g__unravel_before_print_state_tl
+ }
+ }
}
-\cs_new_protected:Npn \unravel #1 { \__unravel_unravel:n {#1} }
-\cs_new_protected_nopar:Npn \UnravelDebug
+\cs_new_protected_nopar:Npn \__unravel_prompt_all:
{
- \bool_set_true:N \l__unravel_debug_bool
+ \tl_gset:Nx \g__unravel_tmpc_tl
+ {
+ \exp_not:n
+ {
+ \tl_gclear:N \g__unravel_tmpc_tl
+ \int_gset_eq:NN \g__unravel_max_output_int \c_max_int
+ \int_gset_eq:NN \g__unravel_max_input_int \c_max_int
+ \__unravel_print_state:
+ }
+ \__unravel_prompt_all_aux:N \g__unravel_max_output_int
+ \__unravel_prompt_all_aux:N \g__unravel_max_input_int
+ }
+ \group_insert_after:N \g__unravel_tmpc_tl
}
-\cs_new_protected:Npn \__unravel_unravel:n #1
+\cs_new:Npn \__unravel_prompt_all_aux:N #1
+ { \exp_not:n { \int_gset:Nn #1 } { \int_use:N #1 } }
+\keys_define:nn { unravel/defaults }
+ {
+ explicit-prompt .bool_gset:N = \g__unravel_default_explicit_prompt_bool ,
+ internal-debug .bool_gset:N = \g__unravel_default_internal_debug_bool ,
+ max-action .int_gset:N = \g__unravel_default_max_action_int ,
+ max-output .int_gset:N = \g__unravel_default_max_output_int ,
+ max-input .int_gset:N = \g__unravel_default_max_input_int ,
+ number-steps .bool_gset:N = \g__unravel_default_number_steps_bool ,
+ welcome-message .bool_gset:N = \g__unravel_default_welcome_message_bool ,
+ }
+\keys_define:nn { unravel }
+ {
+ explicit-prompt .bool_gset:N = \g__unravel_explicit_prompt_bool ,
+ internal-debug .bool_gset:N = \g__unravel_internal_debug_bool ,
+ max-action .int_gset:N = \g__unravel_max_action_int ,
+ max-output .int_gset:N = \g__unravel_max_output_int ,
+ max-input .int_gset:N = \g__unravel_max_input_int ,
+ number-steps .bool_gset:N = \g__unravel_number_steps_bool ,
+ welcome-message .bool_gset:N = \g__unravel_welcome_message_bool ,
+ }
+\tl_map_inline:nn { { /defaults } { } }
+ {
+ \keys_define:nn { unravel #1 }
+ {
+ machine .meta:nn =
+ { unravel #1 }
+ {
+ explicit-prompt = false ,
+ internal-debug = false ,
+ max-action = \c_max_int ,
+ max-output = \c_max_int ,
+ max-input = \c_max_int ,
+ number-steps = false ,
+ welcome-message = false ,
+ } ,
+ }
+ }
+\NewDocumentCommand \unravel { O { } m } { \unravel:nn {#1} {#2} }
+\NewDocumentCommand \unravelsetup { m } { \unravel_setup:n {#1} }
+\cs_new_protected:Npn \unravel_setup:n #1
+ {
+ \keys_set:nn { unravel/defaults } {#1}
+ \keys_set:nn { unravel } {#1}
+ }
+\cs_new_protected:Npn \unravel:nn #1#2
+ {
+ \__unravel_init_key_vars:
+ \keys_set:nn { unravel } {#1}
+ \__unravel_init_vars:
+ \__unravel_input_gset:n {#2}
+ \__unravel_print_welcome:
+ \__unravel_main_loop:
+ \__unravel_exit_point:
+ \__unravel_print_outcome:
+ \__unravel_final_test:
+ \__unravel_exit_point:
+ }
+\cs_new_protected_nopar:Npn \__unravel_init_key_vars:
+ {
+ \bool_gset_eq:NN \g__unravel_explicit_prompt_bool \g__unravel_default_explicit_prompt_bool
+ \bool_gset_eq:NN \g__unravel_internal_debug_bool \g__unravel_default_internal_debug_bool
+ \bool_gset_eq:NN \g__unravel_number_steps_bool \g__unravel_default_number_steps_bool
+ \bool_gset_eq:NN \g__unravel_welcome_message_bool \g__unravel_default_welcome_message_bool
+ \int_gset_eq:NN \g__unravel_max_action_int \g__unravel_default_max_action_int
+ \int_gset_eq:NN \g__unravel_max_output_int \g__unravel_default_max_output_int
+ \int_gset_eq:NN \g__unravel_max_input_int \g__unravel_default_max_input_int
+ }
+\cs_new_protected_nopar:Npn \__unravel_init_vars:
{
- \int_gzero:N \g__unravel_step_int
- \__unravel_input_gset:n {#1}
\seq_gclear:N \g__unravel_prev_input_seq
\gtl_gclear:N \g__unravel_output_gtl
+ \int_gzero:N \g__unravel_step_int
\tl_gclear:N \g__unravel_if_limit_tl
\int_gzero:N \g__unravel_if_limit_int
\int_gzero:N \g__unravel_if_depth_int
\gtl_gclear:N \g__unravel_after_assignment_gtl
\bool_gset_true:N \g__unravel_set_box_allowed_bool
\bool_gset_false:N \g__unravel_name_in_progress_bool
- \cs_gset_eq:NN \g__unravel_prompt_ior \c_minus_one % ^^A todo:?
- \__unravel_print_welcome:
+ }
+\cs_new_protected_nopar:Npn \__unravel_main_loop:
+ {
+ \__unravel_get_x_next:
+ \__unravel_set_cmd:
+ \__unravel_do_step:
\__unravel_main_loop:
- \__unravel_exit_point:
- \__unravel_print_outcome:
+ }
+\cs_new_protected_nopar:Npn \__unravel_final_test:
+ {
\bool_if:nTF
{
\tl_if_empty_p:N \g__unravel_if_limit_tl
@@ -4731,22 +4924,14 @@
&& \int_compare_p:nNn \g__unravel_if_depth_int = \c_zero
&& \seq_if_empty_p:N \g__unravel_prev_input_seq
}
- { \__unravel_input_if_empty:TF { } { \__unravel_bad_finish: } }
- { \__unravel_bad_finish: }
- \__unravel_exit_point:
+ { \__unravel_input_if_empty:TF { } { \__unravel_final_bad: } }
+ { \__unravel_final_bad: }
}
-\cs_new_protected_nopar:Npn \__unravel_bad_finish:
+\cs_new_protected_nopar:Npn \__unravel_final_bad:
{
\msg_error:nnx { unravel } { internal }
{ the-last-unravel-finished-badly }
}
-\cs_new_protected_nopar:Npn \__unravel_main_loop:
- {
- \__unravel_get_x_next:
- \__unravel_set_cmd:
- \__unravel_do_step:
- \__unravel_main_loop:
- }
\msg_new:nnn { unravel } { unknown-primitive }
{ Internal~error:~the~primitive~'#1'~is~not~known. }
\msg_new:nnn { unravel } { extra-fi-or-else }
@@ -4804,14 +4989,21 @@
{ Missing~\iow_char:N\\endcsname~inserted. }
\msg_new:nnn { unravel } { runaway-if }
{ Runaway~\iow_char:N\\if... }
+\msg_new:nnn { unravel } { runaway-macro-parameter }
+ {
+ Runaway~macro~parameter~\# #2~after \\\\
+ \iow_indent:n {#1}
+ }
\msg_new:nnn { unravel } { extra-or }
{ Extra~\iow_char:N\\or. }
\msg_new:nnn { unravel } { missing-equals }
{ Missing~equals~for~\iow_char:N\\ifnum~or~\iow_char:N\\ifdim. }
\msg_new:nnn { unravel } { internal }
- { Internal~error:~'#1'.~\ Please report. }
+ { Internal~error:~'#1'.~\ Please~report. }
\msg_new:nnn { unravel } { not-implemented }
{ The~following~feature~is~not~implemented:~'#1'. }
+\msg_new:nnn { unravel } { endinput-ignored }
+ { The~primitive~\iow_char:N\\endinput~was~ignored. }
%%
%%
%% End of file `unravel.sty'.