summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/verb-jv.mkii
blob: 2149c3a4abca0717c4193a977eba802a5cb43865 (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
%D \module
%D   [       file=verb-jv,
%D        version=2002.02.27,
%D          title=\CONTEXT\ Verbatim Macros,
%D       subtitle=Pretty \JAVA\ Verbatim,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Verbatim Macros / Pretty Java Verbatim}

%D This module differs from the \JAVASCRIPT\ driver in its
%D handling of comments. We also need a few more handlers: one
%D for \type {//} and \type {/*} and one for \type {*/} as
%D well as the \JAVA doc trigger \type {/**}.

%D We build this driver on top of the \PERL\ one. Since this
%D driver looks much like the \JAVASCRIPT\ one, we don't
%D comment it extensively.

\ifdefined\setupprettyPLtype \else \loadmarkfile{verb-pl} \fi

\unprotect

\newcount\JVcommentlevel

\gdef\JVsetspecials
  {\PLsetspecials
   \setpretty`\#=32
   \setpretty`\%=41
   \setpretty`\-=45
   \setpretty`\/=43
   \setpretty`\*=44 }

\gdef\JVsethandlers
  {\PLsethandlers
   \installprettyhandler 43 \JVtypefourthree
   \installprettyhandler 44 \JVtypefourfour
   \installprettyhandler 45 \JVtypefourfive }

\gdef\JVsetcontrols
  {\PLsetcontrols
   \def\flushrestofverbatimline
     {\endPLtypesix
      \ifcase\JVcommentlevel \inPLcommentfalse \fi
      \PLverbosefalse
      \PLverboseskipped=0}}

\gdef\JVsetvariables
  {\PLsetvariables
   \global\JVcommentlevel=0 }

\gdef\setupprettyJVtype
  {\def\prettyidentifier{JV}%
   \let\PLidentifiers\JVidentifiers
   \let\PLvariables\JVvariables
   \JVsetvariables
   \JVsetcontrols
   \JVsethandlers
   \JVsetspecials
   \PLsetdiagnostics}

\gdef\JVtypefourthree
  {\handlenextnextpretty\doJVtypefourthree\PLtypefourtwo}

\gdef\doJVtypefourthree#1#2#3%
  {\getprettydata{#2}%
   \ifnum\prettytype=43
     \let\next\dodoJVtypefourthree
   \else\ifnum\prettytype=44
     \global\advance\JVcommentlevel 1
     \global\inPLcommenttrue
     \PLverbosecorrection
     \getprettydata{#3}%
     \ifnum\prettytype=44
       \inPLdoctrue
     \fi
     \let\next\JVtogglecomment
   \else
     \let\next\PLtypefourtwo
   \fi\fi
   \next{#1}#2#3}

\gdef\JVtogglecomment#1#2%
  {\ifnum\JVcommentlevel=1
     \beginofpretty[\!!prettyone]\getpretties{#1}{#2}\endofpretty
   \else
     \getpretties{#1}{#2}%
   \fi}

\gdef\dodoJVtypefourthree
  {\endPLtypesix
   \handlenextnextpretty\dododoJVtypefourthree\dodododoPLtypefourthree}

\gdef\dododoJVtypefourthree
  {\ifnewpretty\expandafter\handlenewpretty\fi\dodododoJVtypefourthree}

\gdef\dodododoJVtypefourthree#1#2%
  {\ifinPLcomment
     \getpretties{#1}{#2}%
   \else
     \global\inPLcommenttrue
     \PLverbosecorrection
     \ifnaturaltextext
       \let\next\naturaltextext
     \else
       \def\next{\beginofpretty[\!!prettyone]\getpretties{#1}{#2}\endofpretty}%
     \fi
     \expandafter\next
   \fi}

\gdef\JVtypefourfour
  {\ifinPLdoc
     \@EA\noJVtypefourfour
   \else
     \@EA\handlenextnextpretty\@EA\doJVtypefourfour\@EA\PLtypefourtwo
   \fi}

\gdef\noJVtypefourfour#1#2%
  {\getprettydata{#2}%
   \ifnum\prettytype=43
     \JVtogglecomment{#1}#2%
     \inPLdocfalse
     \global\advance\JVcommentlevel -1
     \ifcase\JVcommentlevel \global\inPLcommentfalse \fi
   \else
     \ifPLdocdone
       \getpretty{#1}%
     \else
       \beginofpretty[\!!prettyone]\getpretty{#1}\endofpretty
       \PLdocdonetrue
     \fi
     \expandafter#2%
   \fi}

\gdef\doJVtypefourfour#1#2%
  {\getprettydata{#2}%
   \ifnum\prettytype=43
     \JVtogglecomment{#1}#2%
     \inPLdocfalse
     \global\advance\JVcommentlevel -1
     \ifcase\JVcommentlevel \global\inPLcommentfalse \fi
   \else
     \endPLtypesix
     \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
     \expandafter#2%
   \fi}

\gdef\JVtypefourfive % permit - in javadoc @tags
  {\ifinPLdoc
     \@EA\PLtypesixtwo
   \else
     \@EA\PLtypefourone
   \fi}

\useprettyidentifiers \JVidentifiers \JVsetspecials
  abstract assert boolean break byte case catch char class const
  continue default do double else extends false final
  finally float for goto if implements import instanceof
  int interface long native new null package private protected
  public return short static strictfp super switch synchronized
  this throw throws transient true try void volatile while

\useprettyidentifiers \JVvariables \JVsetspecials
  @author @docRoot @deprecated @exception @inheritDoc @link
  @linkplain @param @return @see @serial @serialData @serialField
  @since @throws @value @version

%D The \JAVA doc feature was requested by Robert F.~Beeger,
%D who also provided this test class:
%D
%D \startJV
%D package de.jwamalpha.handling.web.rbdipl;
%D
%D import java.io.IOException;
%D import java.io.PrintWriter;
%D import javax.servlet.http.HttpServlet;
%D import javax.servlet.http.HttpServletRequest;
%D import javax.servlet.http.HttpServletResponse;
%D import javax.servlet.ServletException;
%D
%D /**
%D  * The simple login servlet
%D  *
%D  * @author Robert F. Beeger
%D  * @version 1.0
%D  */
%D
%D public class LoginServlet extends HttpServlet
%D {
%D   //
%D   // public interface
%D   //
%D   /**
%D    * Process the get-request.
%D    *
%D    * @param request the request
%D    * @param response the response.
%D    */
%D   protected void doGet (HttpServletRequest request, HttpServletResponse response)
%D      throws ServletException, IOException
%D   {
%D     response.setContentType("text/html");
%D     PrintWriter writer = response.getWriter();
%D     writer.println("<html>");
%D     writer.println("  <head>");
%D     writer.println("    <title>Login</title>");
%D     writer.println("  </head>");
%D     writer.println("  <body>");
%D     writer.println("    Hallo, Benutzer " + request.getParameter("username") + "!");
%D     writer.println("  </body>");
%D     writer.println("</html>");
%D     writer.flush();
%D   }
%D }
%D \stopJV

\protect \endinput