-
Notifications
You must be signed in to change notification settings - Fork 0
/
jodscripts.tex
128 lines (114 loc) · 5.52 KB
/
jodscripts.tex
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
\section{JOD Scripts}
\subsection{Generated Script Structure}\label{ss:genscripts}
To use dictionary words it is necessary to generate scripts. JOD scripts come in three flavors:
\begin{enumerate}
\item Arbitrary J scripts
\item Header and list scripts
\item Dump scripts\index{dump scripts}
\end{enumerate}
JOD test, macro and group/suite headers are arbitrary J scripts. There are no restrictions on
these scripts. Group and suite scripts generated by
\hyperlink{il:make}{\texttt{make}}, \hyperlink{il:mls}{\texttt{mls}} and
\hyperlink{il:lg}{\texttt{lg}}, (see pages~\pageref{ss:make}, \pageref{ss:mls},
\pageref{ss:lg}), are header and list scripts. \texttt{make} produces dump scripts.
JOD script structure mirrors what you typically do in a J application script. With most J application scripts you:
\begin{enumerate}
\item Setup the application's runtime environment.
\item Load the classes, words and data that comprise the application.
\item Start the application.
\end{enumerate}
This pattern of \emph{setup}, \emph{load} and \emph{start} is seen over and over in J scripts: see
Table~\ref{tab:genscripts} on page~\pageref{tab:genscripts}.
\begin{table}[htbp]
\centering
\scriptsize
\begin{tabular}{|l|l|p{1.5in}|p{3.0in}|} \hline
\multicolumn{4}{|c|}{\textbf{\normalsize Generated Script Structure\T\B}} \\ \hline
\multicolumn{1}{|c|}{\textbf{\normalsize Section\T}} &
\multicolumn{1}{|c|}{\textbf{\normalsize Type}} &
\multicolumn{1}{|c|}{\textbf{\normalsize Description}} &
\multicolumn{1}{|c|}{\textbf{\normalsize Example\B}} \\ \hline
\textbf{\normalsize Setup} & \textsl{\normalsize Active} & \begin{minipage}{1.5in}
Define group and Suite headers. Headers
may contain one dependent section: see page~\pageref{ss:depsec}. \end{minipage}
& \begin{minipage}{2.9in}
\begin{tabular}{l}
\textcolor{CodeComment}{\ttfamily\textsl{NB. define a group header}} \\
\verb|2 1 put 'groupname';' ... script text ... '| \\
\\
\textcolor{CodeComment}{\ttfamily\textsl{NB. define a suite header}} \\
\verb|3 1 put 'suitename';' ... suite text ... '| \\
\end{tabular}
\end{minipage} \\ \hline
\textbf{\normalsize Load} & \textsl{\normalsize Passive} & \begin{minipage}{1.5in}
Load lists of words or tests. \emph{Only word lists are passive.} Tests are typically active scripts. \end{minipage}
& \begin{minipage}{2.9in}
\begin{tabular}{l}
\textcolor{CodeComment}{\ttfamily\textsl{NB. form group from stored words}} \\
\verb|grp 'groupname' ; ;:'words in group'| \\
\\
\textcolor{CodeComment}{\ttfamily\textsl{NB. form suite from stored tests}} \\
\verb|3 grp 'suitename' ; ;:'stored tests'| \\
\end{tabular}
\end{minipage} \\ \hline
\textbf{\normalsize Start} & \textsl{\normalsize Active} & \begin{minipage}{1.5in}
Associate a postprocessor\index{postprocessor} macro with a group or suite. Postprocessors
are prefixed with \verb|POST_| \end{minipage}
& \begin{minipage}{2.9in}
\begin{tabular}{l}
\textcolor{CodeComment}{\ttfamily\textsl{NB. group postprocessor}} \\
\verb|4 put 'POST_groupname';21;' ... script ... '| \\
\\
\textcolor{CodeComment}{\ttfamily\textsl{NB. test suite postprocessor}} \\
\verb|4 put 'POST_suitename';21;' ... script ... '| \\
\end{tabular}
\end{minipage} \\ \hline
\end{tabular}
\caption{JOD generated script\index{scripts!generation!structure} structure}
\label{tab:genscripts}
\end{table}
\subsection{Dependent Section}\label{ss:depsec}
A dependent section\index{dependent section} is a delimited subsection of a
group or suite header, (see
\hyperlink{il:grp}{\texttt{grp}} on page~\pageref{ss:grp}), that is used to define related words and runtime globals. \emph{Global words defined in a dependent section are removed from group lists when groups are generated with \hyperlink{il:make}{\texttt{make}},
\hyperlink{il:mls}{\texttt{mls}} and \hyperlink{il:lg}{\texttt{lg}}: see pages~\pageref{ss:make},
\pageref{ss:mls} and~\pageref{ss:lg}}. This insures that the values assigned in the dependent section are maintained when the group script loads.
A dependent section is delimited with \textcolor{CodeComment}{\texttt{\textsl{NB.*dependents}}} and \textcolor{CodeComment}{\texttt{\textsl{NB.*enddependents}}} and only one dependent section per group header is allowed. The following is the dependent section in the \texttt{jod} class group header. Globals in a dependent section are returned by \hyperlink{il:gdeps}{\texttt{gdeps}}, see page~\pageref{ss:gdeps}.
\begin{lstlisting}[frame=single,framerule=0pt,basicstyle=\ttfamily\footnotesize]
NB.*dependents x-- words defined in this section have related definitions
NB. host specific z locale nouns set during J profile loading
NB. (*)=: IFWIN UNAME
LF=:10{a.
CR=:13{a.
TAB=:9{a.
CRLF=:CR,LF
NB. option codes - to add more add a new object code
NB. and modify the following definition of MACROTYPE
JSCRIPT=:21
LATEX=:22
HTML=:23
XML=:24
TEXT=:25
BYTE=:26
UTF8=:28
NB. macro text types, depends on: JSCRIPT,LATEX,HTML,XML,TEXT,BYTE,UTF8
MACROTYPE=:JSCRIPT,LATEX,HTML,XML,TEXT,BYTE,UTF8
NB. object codes
WORD=:0
TEST=:1
GROUP=:2
SUITE=:3
MACRO=:4
NB. object name class, depends on: WORD,TEST,GROUP,SUITE,MACRO
OBJECTNC=:WORD,TEST,GROUP,SUITE,MACRO
NB. bad object code, depends on: OBJECTNC
badobj=:[: -. [: *./ [: , ] e. OBJECTNC"_
NB. path delimiter character & path punctuation characters
PATHDEL=: IFWIN { '/\'
PATHCHRS=:' :.-',PATHDEL
NB. default master profile user locations
JMASTER=:jodsystempath 'jmaster'
JODPROF=:jodsystempath 'jodprofile.ijs'
JODUSER=:jodsystempath 'joduserconfig.ijs'
NB.*enddependents
\end{lstlisting}