File: overword.plt

package info (click to toggle)
tralics 2.14.4-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch, wheezy
  • size: 17,152 kB
  • ctags: 8,260
  • sloc: cpp: 49,403; xml: 18,145; sh: 140; makefile: 118
file content (143 lines) | stat: -rw-r--r-- 3,946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
%%  -*- latex -*-

% This file is part of Tralics
%% Copyright (C) INRIA/Apics (Jose' Grimm) 2007
%% $Id: overword.plt,v 2.1 2008/02/19 16:21:17 grimm Exp $
%% Copyright (C) 1996, 1997 Frank Bennett, Jr. for the original tex file

\ProvidesPackage{overword}[2007/12/29 v1.0  overword package for Tralics]


\def\:{\let\@sptoken= } \:  % this makes \@sptoken a space token

\long\def\@ifoverword#1#2#3#4{%
  \let\reserved@a=#1%
  \def\reserved@d{#4}\def\reserved@b{#2}\def\reserved@c{#3}%
  \global\let\@overword\relax%
  \futurelet\@let@token\@ifowd}

\long\def\@ifowd{%
  \ifx\@let@token\@sptoken%
    \gdef\@preoverwordspace{ }%
    \let\reserved@e\@xifowd%
  \else%
    \ifx\@let@token\end%
      \let\reserved@e\reserved@d%
    \else%
      \ifx\@let@token\par%
        \let\reserved@e\@xifpargobble%
      \else%
        \long\def\reserved@e##1 {\long\gdef\@overword{##1}\@@ifowd}%
      \fi%
    \fi%
  \fi%
  \reserved@e}

\long\def\@xifpargobble#1{\futurelet\@let@token\@ifowd}
\def\:{\@xifowd} \expandafter\def\: {\futurelet\@let@token\@ifowd}
\def\@@ifowd{\futurelet\@let@token\@ifnparnch}
\long\def\@ifnextnparchar#1#2#3#4{%
  \let\reserved@a=#1%
  \def\reserved@b{#2}\def\reserved@c{#3}\def\reserved@d{#4}%
  \futurelet\@let@token\@ifnparnch}
\long\def\@ifnparnch{%
  \ifx\@let@token\@sptoken%
    \let\reserved@e\@xifnparnch%
  \else%
    \ifx\@let@token\end%
      \let\reserved@e\reserved@d%
    \else%
      \ifx\@let@token\par%
        \let\reserved@e\@xifpargobblench%
      \else%
        \ifx\@let@token\reserved@a%
          \let\reserved@e\reserved@b%
        \else%
          \let\reserved@e\reserved@c%
        \fi%
      \fi%
    \fi%
  \fi%
  \reserved@e}
\long\def\@xifpargobblench#1{\futurelet\@let@token\@ifnparnch}
\def\:{\@xifnparnch}
\expandafter\def\: {\futurelet\@let@token\@ifnparnch}
\endinput

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Start of testfile
\documentclass{minimal}
\show\:
\usepackage{overword}

\begin{document}

\show\:
\makeatletter
\show\@sptoken
\message{foo}\message{bar}


\newtoks\registerone
\newtoks\registertwo
\def\list{}

\def\stashonright{%
  \registerone=\expandafter{\@overword}
  \registertwo=\expandafter{\list}
  \edef\list{%
    \noexpand\\{\the\registerone}\the\registertwo}}

\def\showlist{%
  \def\\##1{\message{##1}}
  \message{\space\space -> }
  \list
  \message{^^J}}

\def\readlistagain{%
  \def\\##1{ ##1 }
  \edef\listtext{\list}
\message{\listtext}
  \expandafter\store\listtext\enditall}

\def\storeandshow{%
  \@ifoverword\enditall
   {\message{Ran into \string\enditall!^^J}
    \stashonright
    \expandafter\showlist\@gobble}
   {\stashonright
    \storeandshow}
   {\message{Ran into \string\end!^^J}
    \stashonright
    \showlist}}

\message{^^J----------------------------------------------------------------------}
\message{This file demonstrates the operation of the Overword package for LaTeX}
\message{Ordinarily, TeX reads and inteprets printable characters one by one.}
\message{With this package, it is possible to read input word by word.  This}
\message{capability makes it possible to design user interfaces which are more}
\message{intuitive to users.  The Calendar bundle is one example of such an}
\message{interface.  Below, a phrase is printed to the terminal twice, once in}
\message{reverse word order, and once in re-reversed (normal) word order.  Each}
\message{message is triggered by a control sequence found just beyond the last}
\message{word read --- \string\enditall in the first instance, \string\end\space in the second.}
\message{This file produces no printed output.}
\message{^^J----------------------------------------------------------------------}



\storeandshow This is a demonstration of the overword package \enditall

\let\listclone\list
\def\list{}
\def\\#1{ #1 }
\edef\listtext{\listclone}
\expandafter\storeandshow\listtext


\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: