diff options
author | Hans Hagen <pragma@wxs.nl> | 2002-03-04 00:00:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2002-03-04 00:00:00 +0100 |
commit | 6a8becf936f346438dfcb463bbb195bf4dd45d7d (patch) | |
tree | c9409681dfad52e714480dcf041a144a861ef1dd /tex/context/base/verb-jv.tex | |
parent | 492154026fb3d8fa46a58ed89edce6a596e341ad (diff) | |
download | context-6a8becf936f346438dfcb463bbb195bf4dd45d7d.tar.gz |
stable 2002.03.04
Diffstat (limited to 'tex/context/base/verb-jv.tex')
-rw-r--r-- | tex/context/base/verb-jv.tex | 203 |
1 files changed, 126 insertions, 77 deletions
diff --git a/tex/context/base/verb-jv.tex b/tex/context/base/verb-jv.tex index 4de1a92b3..a7bad3c43 100644 --- a/tex/context/base/verb-jv.tex +++ b/tex/context/base/verb-jv.tex @@ -1,8 +1,8 @@ %D \module -%D [ file=verb-pl, -%D version=1998.02.7, +%D [ file=verb-jv, +%D version=2002.2.27, %D title=\CONTEXT\ Verbatim Macros, -%D subtitle=Pretty \JAVASCRIPT\ Verbatim, +%D subtitle=Pretty \JAVA\ Verbatim, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] @@ -11,65 +11,40 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{Context Support Macros / Pretty JavaScript Verbatim} +\writestatus{loading}{Context Support Macros / Pretty Java Verbatim} -%D In \CONTEXT\ we support \JAVASCRIPT\ inclusion in \PDF\ -%D documents and thereby enter the field of authoring. Of -%D course we also want to pretty print such scripts, that look -%D like: -%D -%D \startJS -%D alfa = beta*2 ; // both alfa and beta are numbers // indeed -%D if (odd(alfa)) -%D { do_something() } -%D else -%D { do_nothing() } /* As we can see /* in this example */ there -%D how_about(alfa) ; is no fi needed. Also no semicolons are -%D or_about(beta) ; needed after a right brace. */ -%D \stopJS -%D -%D Because \JAVASCRIPT\ looks much like \PERL, we will use -%D a slightly adapted \PERL\ visualization. First we load the -%D \PERL\ module: +%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. \ifx\undefined\setupprettyPLtype \input verb-pl \relax \fi \unprotect -%D The main difference between the \JAVASCRIPT\ and \PERL\ -%D interpreters concern comments. Where \TEX, \METAPOST\ and -%D \PERL\ have one comment symbol (\type{%}, \type{%} and -%D \type{#}), \JAVA\ has the one line comment sequence -%D \type{//} and the multi line comment delimiters \type{/*} -%D and \type{*/}. -%D -%D We need a counter to keep track of multi line comment -%D nesting. - \newcount\JVcommentlevel -%D We handle both \type{%} and \type{#} a bit different: - -\gdef\JVsetspecials% +\gdef\JVsetspecials {\PLsetspecials \setpretty`\#=32 \setpretty`\%=41 + \setpretty`\-=45 \setpretty`\/=43 \setpretty`\*=44 } -%D We also need a few more handlers: one for \type{//} and -%D \type{/*} and one for \type{*/}. - -\gdef\JVsethandlers% +\gdef\JVsethandlers {\PLsethandlers \installprettyhandler 43 \JVtypefourthree - \installprettyhandler 44 \JVtypefourfour } + \installprettyhandler 44 \JVtypefourfour + \installprettyhandler 45 \JVtypefourfive } -%D We can inherit most of the settings: - -\gdef\JVsetcontrols% +\gdef\JVsetcontrols {\PLsetcontrols - \def\flushrestofverbatimline% + \def\flushrestofverbatimline {\endPLtypesix \ifcase\JVcommentlevel \inPLcommentfalse \fi \PLverbosefalse @@ -79,36 +54,36 @@ {\PLsetvariables \global\JVcommentlevel=0 } -\gdef\setupprettyJVtype% +\gdef\setupprettyJVtype {\def\prettyidentifier{JV}% - \let\PLidentifiers=\JVidentifiers - \let\PLvariables=\JVvariables + \let\PLidentifiers\JVidentifiers + \let\PLvariables\JVvariables \JVsetvariables \JVsetcontrols \JVsethandlers \JVsetspecials \PLsetdiagnostics} -%D The main complication is that we have to look upto four -%D characters ahead. Such macros are hard to understand but -%D they do work! - -\gdef\JVtypefourthree% +\gdef\JVtypefourthree {\handlenextnextpretty\doJVtypefourthree\PLtypefourtwo} -\gdef\doJVtypefourthree#1#2% +\gdef\doJVtypefourthree#1#2#3% {\getprettydata{#2}% \ifnum\prettytype=43 - \let\next=\dodoJVtypefourthree + \let\next\dodoJVtypefourthree \else\ifnum\prettytype=44 - \global\advance\JVcommentlevel by 1 + \global\advance\JVcommentlevel 1 \global\inPLcommenttrue \PLverbosecorrection - \let\next=\JVtogglecomment + \getprettydata{#3}% + \ifnum\prettytype=44 + \inPLdoctrue + \fi + \let\next\JVtogglecomment \else - \let\next=\PLtypefourtwo + \let\next\PLtypefourtwo \fi\fi - \next{#1}#2} + \next{#1}#2#3} \gdef\JVtogglecomment#1#2% {\ifnum\JVcommentlevel=1 @@ -117,11 +92,11 @@ \getpretties{#1}{#2}% \fi} -\gdef\dodoJVtypefourthree% #1% +\gdef\dodoJVtypefourthree {\endPLtypesix \handlenextnextpretty\dododoJVtypefourthree\dodododoPLtypefourthree} -\gdef\dododoJVtypefourthree% +\gdef\dododoJVtypefourthree {\ifnewpretty\expandafter\handlenewpretty\fi\dodododoJVtypefourthree} \gdef\dodododoJVtypefourthree#1#2% @@ -138,14 +113,36 @@ \expandafter\next \fi} -\gdef\JVtypefourfour% - {\handlenextnextpretty\doJVtypefourfour\PLtypefourtwo} +\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% - \global\advance\JVcommentlevel by -1 + \inPLdocfalse + \global\advance\JVcommentlevel -1 \ifcase\JVcommentlevel \global\inPLcommentfalse \fi \else \endPLtypesix @@ -153,21 +150,73 @@ \expandafter#2% \fi} -%D We need different (less) reserved words. This list replaces -%D the \PERL\ one. +\gdef\JVtypefourfive % permit - in javadoc @tags + {\ifinPLdoc + \@EA\PLtypesixtwo + \else + \@EA\PLtypefourone + \fi} \useprettyidentifiers \JVidentifiers \JVsetspecials - abstract boolean break byte case catch char class const - continue default delete do double else extends false final - finally float for function goto if implements import in - instanceof int interface long native new null package - private protected public return short static super switch - synchronized this throw throws transient true try var void - while with - + 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 - not-yet-defined + @author @docRoot @deprecated @exception @inheritDoc @link + @linkplain @param @return @see @serial @serialData @serialField + @since @throws @value @version -\protect - -\endinput +%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 |