summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/unravel/unravel.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-16 22:15:42 +0000
committerKarl Berry <karl@freefriends.org>2019-11-16 22:15:42 +0000
commitf5771bdcad46793d095405812d90b49792c91248 (patch)
treeaa583646486d80bcd0375e4090bb6cfb72739c8a /Master/texmf-dist/tex/latex/unravel/unravel.sty
parent6e66e3002d88a17461a8ab9c0e88d089cc7081ea (diff)
unravel (16nov19)
git-svn-id: svn://tug.org/texlive/trunk@52822 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/unravel/unravel.sty')
-rw-r--r--Master/texmf-dist/tex/latex/unravel/unravel.sty175
1 files changed, 117 insertions, 58 deletions
diff --git a/Master/texmf-dist/tex/latex/unravel/unravel.sty b/Master/texmf-dist/tex/latex/unravel/unravel.sty
index b09b7fa0de5..ec8a48459e8 100644
--- a/Master/texmf-dist/tex/latex/unravel/unravel.sty
+++ b/Master/texmf-dist/tex/latex/unravel/unravel.sty
@@ -153,7 +153,7 @@
{%
\csname __unravel_setup_restore:\endcsname
\ProvidesExplPackage
- {unravel} {2019/03/23} {0.2g} {Watching TeX digest tokens}%
+ {unravel} {2019/11/15} {0.2h} {Watching TeX digest tokens}%
\csname __unravel_setup_unravel:\endcsname
}%
\cs_new_eq:NN \__unravel_currentgrouptype: \tex_currentgrouptype:D
@@ -324,11 +324,6 @@
}
\cs_new_eq:NN \__unravel_exit_point: \prg_do_nothing:
\cs_new:Npn \__unravel_exit:w #1 \__unravel_exit_point: { }
-\cs_new:Npn \__unravel_exit_error:w #1 \__unravel_exit_point: #2 \__unravel_final_bad:
- {
- \__unravel_error:nnnnn { runaway-unravel } { } { } { } { }
- #2
- }
\cs_new:Npn \__unravel_exit_hard:w #1 \__unravel_exit_point: #2 \__unravel_exit_point: { }
\cs_new_eq:NN \__unravel_break_point: \prg_do_nothing:
\cs_new:Npn \__unravel_break:w #1 \__unravel_break_point: { }
@@ -473,23 +468,23 @@
\gtl_concat:NNN \l__unravel_prev_input_gtl \l__unravel_prev_input_gtl #1
\__unravel_prev_input_gpush_gtl:N \l__unravel_prev_input_gtl
}
-\cs_new_protected:Npn \__unravel_prev_input_join_get:nN #1
+\cs_new_protected:Npn \__unravel_prev_input_join_get:nnN #1
{
\int_case:nnF {#1}
{
- { 2 } { \__unravel_join_get_aux:NNN \skip_eval:n \tex_glueexpr:D }
- { 3 } { \__unravel_join_get_aux:NNN \muskip_eval:n \tex_muexpr:D }
+ { 2 } { \__unravel_join_get_aux:NNnN \skip_eval:n \tex_glueexpr:D }
+ { 3 } { \__unravel_join_get_aux:NNnN \muskip_eval:n \tex_muexpr:D }
}
{
\__unravel_error:nnnnn { internal } { join-factor } { } { } { }
- \__unravel_join_get_aux:NNN \use:n \prg_do_nothing:
+ \__unravel_join_get_aux:NNnN \use:n \prg_do_nothing:
}
}
-\cs_new_protected:Npn \__unravel_join_get_aux:NNN #1#2#3
+\cs_new_protected:Npn \__unravel_join_get_aux:NNnN #1#2#3#4
{
\__unravel_prev_input_gpop:N \l__unravel_head_tl
\__unravel_prev_input_gpop:N \l__unravel_tmpa_tl
- \tl_set:Nx #3 { #1 { \l__unravel_tmpa_tl #2 \l__unravel_head_tl } }
+ \tl_set:Nx #4 { #1 { \l__unravel_tmpa_tl #2 \l__unravel_head_tl #3 } }
}
\tl_new:N \g__unravel_before_print_state_tl
\tl_new:N \g__unravel_before_prompt_tl
@@ -499,6 +494,7 @@
\bool_new:N \g__unravel_default_internal_debug_bool
\bool_new:N \g__unravel_default_number_steps_bool
\int_new:N \g__unravel_default_online_int
+\clist_new:N \g__unravel_default_prompt_input_clist
\bool_new:N \g__unravel_default_trace_assigns_bool
\bool_new:N \g__unravel_default_trace_expansion_bool
\bool_new:N \g__unravel_default_trace_other_bool
@@ -513,6 +509,7 @@
\bool_new:N \g__unravel_internal_debug_bool
\bool_new:N \g__unravel_number_steps_bool
\int_new:N \g__unravel_online_int
+\clist_new:N \g__unravel_prompt_input_clist
\bool_new:N \g__unravel_trace_assigns_bool
\bool_new:N \g__unravel_trace_expansion_bool
\bool_new:N \g__unravel_trace_other_bool
@@ -1263,11 +1260,10 @@
\__unravel_tex_primitive:nnn { pdfximagebbox } { convert } { 31 }
\__unravel_tex_primitive:nnn { jobname } { convert } { 32 }
\sys_if_engine_luatex:T
- {
- \__unravel_tex_primitive:nnn { directlua } { convert } { 33 }
- \__unravel_tex_primitive:nnn { expanded } { convert } { 34 }
- \__unravel_tex_primitive:nnn { luaescapestring } { convert } { 35 }
- }
+ { \__unravel_tex_primitive:nnn { directlua } { convert } { 33 } }
+\__unravel_tex_primitive:nnn { expanded } { convert } { 34 }
+\sys_if_engine_luatex:T
+ { \__unravel_tex_primitive:nnn { luaescapestring } { convert } { 35 } }
\sys_if_engine_xetex:T
{
\__unravel_tex_primitive:nnn { Ucharcat } { convert } { 40 }
@@ -1288,20 +1284,22 @@
\cs_new_protected:Npn \__unravel_get_next:
{
\__unravel_input_if_empty:TF
- { \__unravel_exit_error:w }
{
- \__unravel_input_gpop:N \l__unravel_head_gtl
- \gtl_head_do:NN \l__unravel_head_gtl \__unravel_get_next_aux:w
- \gtl_if_tl:NTF \l__unravel_head_gtl
- {
- \tl_set:Nx \l__unravel_head_tl
- { \gtl_head:N \l__unravel_head_gtl }
- \token_if_eq_meaning:NNT
- \l__unravel_head_token \__unravel_special_relax:
- \__unravel_get_next_notexpanded:
- }
- { \tl_clear:N \l__unravel_head_tl }
+ \__unravel_error:nnnnn { runaway-unravel } { } { } { } { }
+ \__unravel_back_input_gtl:N \c__unravel_frozen_relax_gtl
}
+ { }
+ \__unravel_input_gpop:N \l__unravel_head_gtl
+ \gtl_head_do:NN \l__unravel_head_gtl \__unravel_get_next_aux:w
+ \gtl_if_tl:NTF \l__unravel_head_gtl
+ {
+ \tl_set:Nx \l__unravel_head_tl
+ { \gtl_head:N \l__unravel_head_gtl }
+ \token_if_eq_meaning:NNT
+ \l__unravel_head_token \__unravel_special_relax:
+ \__unravel_get_next_notexpanded:
+ }
+ { \tl_clear:N \l__unravel_head_tl }
}
\cs_new_protected:Npn \__unravel_get_next_aux:w
{ \cs_set_eq:NN \l__unravel_head_token }
@@ -1470,6 +1468,7 @@
{ char } { \__unravel_set_cmd_aux_given:n { char_given } }
{ kchar } { \__unravel_set_cmd_aux_given:n { char_given } }
{ mathchar } { \__unravel_set_cmd_aux_given:n { math_given } }
+ { omathchar } { \__unravel_set_cmd_aux_given:n { math_given } }
}
{
\__unravel_set_cmd_aux_primitive:nTF {#1}
@@ -2386,11 +2385,14 @@
{
\__unravel_prev_input_gpush:
\__unravel_scan_something_internal:n {#1}
- \__unravel_prev_input_join_get:nN {#1} \l__unravel_tmpa_tl
+ \int_compare:nNnTF \g__unravel_val_level_int = { 0 }
+ { \__unravel_prev_input_join_get:nnN {#1} { sp } \l__unravel_tmpa_tl }
+ { \__unravel_prev_input_join_get:nnN {#1} { } \l__unravel_tmpa_tl }
\__unravel_prev_input_gpush:N \l__unravel_tmpa_tl
- \__unravel_break:w
+ \exp_after:wN \use_none:n \__unravel_break:w
}
- { \__unravel_back_input: }
+ { }
+ \__unravel_back_input:
\int_compare:nNnT {#1} = { 3 }
{
\__unravel_scan_keyword:nT { mMuU } { \__unravel_break:w }
@@ -2417,6 +2419,7 @@
\__unravel_tex_error:nV { missing-pt } \l__unravel_head_tl
\__unravel_prev_input:n { pt }
\__unravel_break_point:
+ \__unravel_skip_optional_space:
}
\cs_new_protected:Npn \__unravel_scan_inf_unit_loop:
{ \__unravel_scan_keyword:nT { lL } { \__unravel_scan_inf_unit_loop: } }
@@ -2457,7 +2460,7 @@
{ \__unravel_break:w }
}
{ \__unravel_back_input: \__unravel_scan_dimen:nN {#1} \c_false_bool }
- \__unravel_prev_input_join_get:nN {#1} \l__unravel_tmpa_tl
+ \__unravel_prev_input_join_get:nnN {#1} { } \l__unravel_tmpa_tl
\__unravel_prev_input_gpush:
\__unravel_prev_input_gpush:N \l__unravel_tmpa_tl
\__unravel_scan_keyword:nT { pPlLuUsS }
@@ -2465,7 +2468,7 @@
\__unravel_scan_keyword:nT { mMiInNuUsS }
{ \__unravel_scan_dimen:nN {#1} \c_true_bool }
\__unravel_break_point:
- \__unravel_prev_input_join_get:nN {#1} \l__unravel_tmpa_tl
+ \__unravel_prev_input_join_get:nnN {#1} { } \l__unravel_tmpa_tl
\__unravel_prev_input_silent:V \l__unravel_tmpa_tl
}
\cs_new_protected:Npn \__unravel_scan_file_name:
@@ -3002,15 +3005,8 @@
}
\__unravel_print_action:
}
-\cs_new_protected:Npn \__unravel_do_step:
- {
- \__unravel_set_action_text:
- \bool_if:NT \g__unravel_internal_debug_bool
- { \__unravel_exp_args:Nx \iow_term:n { Cmd:~\int_to_arabic:n { \l__unravel_head_cmd_int } } }
- \cs_if_exist_use:cF
- { __unravel_cmd_ \int_use:N \l__unravel_head_cmd_int : }
- { \__unravel_error:nxxxx { internal } { unknown-command } { } { } { } }
- }
+\cs_new_protected:Npn \__unravel_forbidden_case:
+ { \__unravel_tex_error:nV { forbidden-case } \l__unravel_head_tl }
\__unravel_new_tex_cmd:nn { relax } % 0
{
\token_if_eq_meaning:NNT \l__unravel_head_token \__unravel_special_relax:
@@ -4730,7 +4726,8 @@
\cs_if_eq:NNTF #1 \__unravel_get_token_xdef:
{
\tl_put_right:NV \l__unravel_defining_tl \l__unravel_head_tl
- \__unravel_prev_input:V \l__unravel_head_tl
+ \__unravel_prev_input_silent:x { \l__unravel_head_tl }
+ \__unravel_print_action:
}
{
\cs_if_eq:NNTF #1 \__unravel_get_token_x:
@@ -4905,7 +4902,7 @@
\__unravel_print_expansion:x
{
\g__unravel_action_text_str = false ~
- => ~ skipped ~ to ~ \iow_char:N\\fi
+ => ~ skip ~ to ~ \tl_to_str:N \l__unravel_head_tl
}
}
\cs_new_protected:Npn \__unravel_cond_false_loop:n #1
@@ -4980,7 +4977,10 @@
\gtl_if_head_is_group_begin:NTF #1 { \c_group_begin_token }
{
\gtl_if_head_is_group_end:NTF #1 { \c_group_end_token }
- { \exp_not:N \exp_not:N \gtl_head_do:NN #1 \exp_not:N }
+ {
+ \exp_not:N \exp_not:N
+ \exp_not:f { \gtl_head_do:NN #1 \exp_stop_f: }
+ }
}
}
}
@@ -5106,10 +5106,9 @@
\__unravel_set_action_text:x
{
\g__unravel_action_text_str \c_space_tl
- => ~ skipped ~ to ~ \tl_to_str:N \l__unravel_head_tl
+ => ~ skip ~ to ~ \tl_to_str:N \l__unravel_head_tl
}
}
- % ^^A todo: in the terminal output the token itself is missing.
\__unravel_print_expansion:
\__unravel_cond_pop:
}
@@ -5347,13 +5346,28 @@
}
\cs_new_protected:Npn \__unravel_prompt_aux:
{
- \int_compare:nNnT { \tex_interactionmode:D } = { 3 }
+ \clist_if_empty:NTF \g__unravel_prompt_input_clist
{
- \bool_if:NTF \g__unravel_explicit_prompt_bool
- { \__unravel_ior_str_get:Nc \c__unravel_prompt_ior }
- { \__unravel_ior_str_get:Nc \c__unravel_noprompt_ior }
- { Your~input }
- \exp_args:Nv \__unravel_prompt_treat:n { Your~input }
+ \int_compare:nNnT { \tex_interactionmode:D } = { 3 }
+ {
+ \bool_if:NTF \g__unravel_explicit_prompt_bool
+ { \__unravel_ior_str_get:Nc \c__unravel_prompt_ior }
+ { \__unravel_ior_str_get:Nc \c__unravel_noprompt_ior }
+ { Your~input }
+ \exp_args:Nv \__unravel_prompt_treat:n { Your~input }
+ }
+ }
+ {
+ \clist_gpop:NN \g__unravel_prompt_input_clist \l__unravel_tmpa_tl
+ \group_begin:
+ \__unravel_set_escapechar:n { 92 }
+ \__unravel_print:x
+ {
+ \bool_if:NT \g__unravel_explicit_prompt_bool { Your~input= }
+ \tl_to_str:N \l__unravel_tmpa_tl
+ }
+ \group_end:
+ \exp_args:NV \__unravel_prompt_treat:n \l__unravel_tmpa_tl
}
}
\cs_new_protected:Npn \__unravel_prompt_treat:n #1
@@ -5373,7 +5387,11 @@
\group_end:
\__unravel_exit_hard:w
}
- { X } { \tex_batchmode:D \tex_end:D }
+ { X }
+ {
+ \tex_batchmode:D
+ \tex_read:D -1 to \l__unravel_tmpa_tl
+ }
{ s } { \__unravel_prompt_scan_int:nn {#1}
\__unravel_prompt_silent_steps:n }
{ o } { \__unravel_prompt_scan_int:nn {#1}
@@ -5496,6 +5514,7 @@
{ \exp_not:N \__unravel:nn \tl_to_str:N \g__unravel_until_tl }
}
{
+ \int_gzero:N \g__unravel_nonstop_int
\int_gset:Nn \g__unravel_online_int { 1 }
\tl_gclear:N \g__unravel_before_print_state_tl
}
@@ -5552,6 +5571,7 @@
max-input .int_gset:N = \g__unravel_default_max_input_int ,
number-steps .bool_gset:N = \g__unravel_default_number_steps_bool ,
online .int_gset:N = \g__unravel_default_online_int ,
+ prompt-input .clist_gset:N = \g__unravel_default_prompt_input_clist ,
trace-assigns .bool_gset:N = \g__unravel_default_trace_assign_bool ,
trace-expansion .bool_gset:N = \g__unravel_default_trace_expansion_bool ,
trace-other .bool_gset:N = \g__unravel_default_trace_other_bool ,
@@ -5566,6 +5586,7 @@
max-input .int_gset:N = \g__unravel_max_input_int ,
number-steps .bool_gset:N = \g__unravel_number_steps_bool ,
online .int_gset:N = \g__unravel_online_int ,
+ prompt-input .clist_gset:N = \g__unravel_prompt_input_clist ,
trace-assigns .bool_gset:N = \g__unravel_trace_assigns_bool ,
trace-expansion .bool_gset:N = \g__unravel_trace_expansion_bool ,
trace-other .bool_gset:N = \g__unravel_trace_other_bool ,
@@ -5617,6 +5638,7 @@
\__unravel_exit_point:
\__unravel_print_outcome:
\__unravel_final_test:
+ \__unravel_final_after_assignment:
\__unravel_exit_point:
}
\cs_new_protected:Npn \unravel_get:nnN #1#2#3
@@ -5630,6 +5652,7 @@
\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
\int_gset_eq:NN \g__unravel_online_int \g__unravel_default_online_int
+ \clist_gset_eq:NN \g__unravel_prompt_input_clist \g__unravel_default_prompt_input_clist
\bool_gset_eq:NN \g__unravel_trace_assigns_bool \g__unravel_default_trace_assigns_bool
\bool_gset_eq:NN \g__unravel_trace_expansion_bool \g__unravel_default_trace_expansion_bool
\bool_gset_eq:NN \g__unravel_trace_other_bool \g__unravel_default_trace_other_bool
@@ -5666,6 +5689,15 @@
\__unravel_do_step:
\__unravel_main_loop:
}
+\cs_new_protected:Npn \__unravel_do_step:
+ {
+ \__unravel_set_action_text:
+ \bool_if:NT \g__unravel_internal_debug_bool
+ { \__unravel_exp_args:Nx \iow_term:n { Cmd:~\int_to_arabic:n { \l__unravel_head_cmd_int } } }
+ \cs_if_exist_use:cF
+ { __unravel_cmd_ \int_use:N \l__unravel_head_cmd_int : }
+ { \__unravel_error:nxxxx { internal } { unknown-command } { } { } { } }
+ }
\cs_new_protected:Npn \__unravel_final_test:
{
\bool_if:nTF
@@ -5683,6 +5715,11 @@
\__unravel_error:nnnnn { internal }
{ the-last-unravel-finished-badly } { } { } { }
}
+\cs_new_protected:Npn \__unravel_final_after_assignment:
+ {
+ \gtl_if_empty:NF \g__unravel_after_assignment_gtl
+ { \gtl_head_do:NN \g__unravel_after_assignment_gtl \tex_afterassignment:D }
+ }
\msg_new:nnn { unravel } { unknown-primitive }
{ Internal~error:~the~primitive~'#1'~is~not~known. }
\msg_new:nnn { unravel } { extra-fi-or-else }
@@ -5731,12 +5768,14 @@
\msg_new:nnn { unravel } { bad-unless }
{ \iow_char:N\\unless~not~followed~by~conditional. }
\msg_new:nnn { unravel } { runaway-if }
- { Runaway~\iow_char:N\\if... }
+ { Runaway~\iow_char:N\\if...~Exiting~\iow_char:N\\unravel }
\msg_new:nnn { unravel } { runaway-macro-parameter }
{
Runaway~macro~parameter~\# #2~after \\\\
\iow_indent:n {#1}
}
+\msg_new:nnn { unravel } { runaway-text }
+ { Runaway~braced~argument~for~TeX~primitive.~Exiting~\iow_char:N\\unravel }
\msg_new:nnn { unravel } { extra-or }
{ Extra~\iow_char:N\\or. }
\msg_new:nnn { unravel } { missing-equals }
@@ -5765,8 +5804,28 @@
{ TeX~provides~no~further~help~for~this~error. }
{ TeX's~advice~is:\\\\ \iow_indent:n {#3} }
}
-\msg_new:nnn { unravel } { runaway-unravel }
- { Runaway~\iow_char:N\\unravel }
+\msg_new:nnnn { unravel } { runaway-unravel }
+ { Runaway~\iow_char:N\\unravel,~so~\iow_char:N\\relax~inserted. }
+ {
+ Some~TeX~command~expects~input~beyond~the~end~of~
+ the~argument~of~\iow_char:N\\unravel.
+ }
+\__unravel_tex_msg_new:nnn { forbidden-case }
+ {
+ You~can't~use~`\exp_after:wN \token_to_str:N \l__unravel_head_tl'~in~
+ \mode_if_vertical:TF { vertical }
+ {
+ \mode_if_horizontal:TF { horizontal }
+ { \mode_if_math:TF { math } { no } }
+ } ~ mode.
+ }
+ {
+ Sorry,~but~I'm~not~programmed~to~handle~this~case;~
+ I'll~just~pretend~that~you~didn't~ask~for~it.~
+ If~you're~in~the~wrong~mode,~you~might~be~able~to~
+ return~to~the~right~one~by~typing~`I\iow_char:N\}'~or~
+ `I\iow_char:N\$'~or~`I\iow_char:N\\par'.
+ }
\__unravel_tex_msg_new:nnn { incompatible-mag }
{
Incompatible~magnification~