Skip to content

Commit

Permalink
Added topologies_, switch/case/break/default/endswitch, #timeoutafter…
Browse files Browse the repository at this point in the history
… -z, -Z ordered sets.
  • Loading branch information
vermaseren committed Oct 3, 2018
1 parent 247d829 commit 689b72d
Show file tree
Hide file tree
Showing 33 changed files with 3,927 additions and 109 deletions.
28 changes: 28 additions & 0 deletions doc/manual/prepro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,34 @@ \section{\#terminate}
no return value is specified, the value -1 will be returned.

%--#] terminate :
%--#[ timeoutafter :

\section{\#timeoutafter}
\label{pretimeoutafter}

\noindent Syntax:

\#timeoutafter $<$Number of seconds$>$

\noindent This instruction starts a timer. When the given time expires the
current program will be terminated, unless the timer is reset before this
time. Resetting the timer is dome with the "\#timeoutafter 0" instruction.

The purpose of this instruction is to prevent runaway programs, because a
given subpart takes much more time than it should. Example:
\begin{verbatim}
.sort
#timeoutafter 1000
#call problematicprocedure
.sort
#timeoutafter 0
\end{verbatim}
If one runs many diagrams with a make-like facility like minos, diagrams
that behave in an unexpected way can be killed this way and minos can
continue with the next diagram. Later one can see which diagrams caused
problems and one may study what the problem was.

%--#] timeoutafter :
%--#[ toexternal :

\section{\#toexternal}
Expand Down
3 changes: 3 additions & 0 deletions doc/manual/setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ \chapter{The setup}

\leftvitem{4.0cm}{InsideFirst\index{setup!insidefirst}\index{insidefirst}}
\rightvitem{12.6cm}{Not having any effect at the moment.}

\leftvitem{4.0cm}{JumpRatio\index{setup!jumpratio}\index{jumpratio}}
\rightvitem{12.6cm}{See the endswitch (\ref{substaendswitch}} statement.}

\leftvitem{4.0cm}{MaxNumberSize\index{setup!maxnumbersize}\index{maxnumbersize}}
\rightvitem{12.6cm}{Allows the setting of the maximum size of the numbers
Expand Down
4 changes: 4 additions & 0 deletions doc/manual/startup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ \chapter{Running FORM}
\item[-W] Turn on the wall-clock time mode in the statistics.
See the `\texttt{On wtimestats}' statement~\ref{substaon}.
\item[-y] Run only the preprocessor and dump its output.
\item[-z] The number following is a timelimit for the program in second.
\item[-Z] Removes the .str file on crash, whatever its contents. Under
ordinary circumstances at a crash a .str file will not be removed if
it has a nonzero content.
\end{description}

\noindent The log\index{log} file\index{file!log} is a file in which all
Expand Down
147 changes: 144 additions & 3 deletions doc/manual/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,50 @@ \section{bracket}
\vspace{10mm}

%--#] bracket :
%--#[ break :
%
\section{break}
\label{substabreak}

\noindent \begin{tabular}{ll}
Type & Executable statement\\
Syntax & break; \\
\\ See also & case (\ref{substacase}), switch (\ref{substaswitch}),
default(\ref{substadefault}), endswitch (\ref{substaendswitch}).
\end{tabular} \vspace{4mm}

\noindent When a break statement is reached in a switch construction the
next statement to be executed is the first statement after the
corresponding endswitch statement.

\vspace{10mm}
%
%--#] break :
%--#[ case :
%
\section{case}
\label{substacase}

\noindent \begin{tabular}{ll}
Type & Executable statement\\
Syntax & case,number; \\
\\ See also & switch (\ref{substaswitch}), break (\ref{substabreak}),
default(\ref{substadefault}), endswitch (\ref{substaendswitch}).
\end{tabular} \vspace{4mm}

\noindent The cases in a switch construction are marked by a number. This
number must be an interger that can be represented inside a {\FORM} word.
On a 64-bit processor this would be an integer in the range $-2^{31}$ to
$2^{31}-1$. If the dollar variable in the switch statement has the same
value as the integer in the case statement, the next statement to be
executed is the first statement after the case statement. Usually cases are
terminated by break statements, but if there is no break statement 'fall
through' may occur in which execution continues with the first statement
after the next case statement or default statement.

\vspace{10mm}
%
%--#] case :
%--#[ cfunctions :

\section{cfunctions}
Expand Down Expand Up @@ -883,6 +927,23 @@ \section{deallocatetable}
has been used. \vspace{10mm}

%--#] deallocatetable :
%--#[ default :
%
\section{default}
\label{substadefault}

\noindent \begin{tabular}{ll}
Type & Executable statement\\
Syntax & default; \\
\\ See also & case (\ref{substacase}), break (\ref{substabreak}),
switch(\ref{substaswitch}), endswitch (\ref{substaendswitch}).
\end{tabular} \vspace{4mm}

\noindent This is the default case in a switch construction.

\vspace{10mm}
%
%--#] default :
%--#[ delete :

\section{delete}
Expand Down Expand Up @@ -1355,6 +1416,29 @@ \section{endrepeat}
repeat environments). \vspace{10mm}

%--#] endrepeat :
%--#[ endswitch :
%
\section{endswitch}
\label{substaendswitch}

\noindent \begin{tabular}{ll}
Type & Executable statement\\
Syntax & endswitch; \\
\\ See also & case (\ref{substacase}), break (\ref{substabreak}),
default(\ref{substadefault}), switch (\ref{substaswitch}).
\end{tabular} \vspace{4mm}

\noindent Ends a switch construction. It collects the various cases, puts
them in order and decides whether the lookup of cases should be done by
means of a jumptable, or by binary searching. The ratio (spread in
cases)/(number of cases) determines whether a jumptable is constructed. The
default value below which a jumptable is constructed is 4. This value can
be changed in the setups (see the section on the setups \ref{setup}) with
the variable jumpratio.

\vspace{10mm}
%
%--#] endswitch :
%--#[ endterm :

\section{endterm}
Expand Down Expand Up @@ -4863,7 +4947,7 @@ \section{set}

\noindent \begin{tabular}{ll}
Type & Declaration statement\\
Syntax & set {\tt<}set to be declared{\tt>}:{\tt<}element{\tt>} [{\tt<}more elements{\tt>}];
Syntax & set {\tt<}set to be declared{\tt>}[(option)]:{\tt<}element{\tt>} [{\tt<}more elements{\tt>}];
\end{tabular} \vspace{4mm}

\noindent Declares a single set\index{set} and specifies its
Expand All @@ -4878,7 +4962,17 @@ \section{set}
element is a symbolic index or a number that cannot be a fixed index (like
a negative number). If the status does not get resolved the set can be used
in the wildcarding of both symbols and indices. Normally sets of numbers
can be used only in the wildcarding of symbols. \vspace{10mm}
can be used only in the wildcarding of symbols.

Currently the only option is the ordered
set\index{set!ordered}\index{ordered set}, indicated by
\begin{verbatim}
Set name(ordered):x4,x3,x1,x6,x2;
\end{verbatim}
which would be stored as x1,x2,x3,x4,x6 if that would be the order of
declaration.

\vspace{10mm}

%--#] set :
%--#[ setexitflag :
Expand Down Expand Up @@ -5235,6 +5329,53 @@ \section{sum}
\vspace{10mm}

%--#] sum :
%--#[ switch :
%
\section{switch}
\label{substaswitch}

\noindent \begin{tabular}{ll}
Type & Executable statement\\
Syntax & switch,\$-variable; \\
\\ See also & case (\ref{substacase}), break (\ref{substabreak}),
default(\ref{substadefault}), endswitch (\ref{substaendswitch}).
\end{tabular} \vspace{4mm}

\noindent The argument of the switch statement should be a dollar variable
which evaluates into an integer that first inside a {\FORM} word.
On a 64-bit processor this would be an integer in the range $-2^{31}$ to
$2^{31}-1$. The switch statement should be paired with an endswitch
statement. Between the two there will be a number of cases, each marked by
an integer. If the value of the dollar variable corresponds to the value of
one of these cases, execution will continue with the first statement after
the corresponding case statement. Example:
\begin{verbatim}
id f(x?$x) = f(x);
switch $x;
case -1;
some statements
break;
case 3;
more statements
break;
case 4;
case 5;
and a few more
break;
default;
and the default action
break;
endswitch;
\end{verbatim}
In principle the action is the same as in any computer language that has a
switch construction, including the fall-through between case 4 and case 5.
Whether the selection of the cases goes by binary search in a sorted list
or by jumptable is determined by the endswitch statement.


\vspace{10mm}
%
%--#] switch :
%--#[ symbols :

\section{symbols}
Expand Down Expand Up @@ -6016,7 +6157,7 @@ \section{transform}

\vspace{10mm}

%--#] transform :
%--#] transform :
%--#[ tryreplace :

\section{tryreplace}
Expand Down
4 changes: 4 additions & 0 deletions sources/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SRCBASE = \
comtool.c \
comtool.h \
declare.h \
diagrams.c \
dict.c \
dollar.c \
execute.c \
Expand All @@ -18,6 +19,8 @@ SRCBASE = \
fsizes.h \
ftypes.h \
function.c \
gentopo.cc \
gentopo.h \
if.c \
index.c \
inivar.h \
Expand Down Expand Up @@ -58,6 +61,7 @@ SRCBASE = \
tables.c \
token.c \
tools.c \
topowrap.cc \
transform.c \
variable.h \
wildcard.c \
Expand Down

0 comments on commit 689b72d

Please sign in to comment.