Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions check/features.frm
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,19 @@ assert stdout =~ exact_pattern("Generated terms = 1001 ( 1 K )")
assert stdout =~ exact_pattern("Terms in output = 1001 ( 1 K )")
assert stdout =~ exact_pattern("Bytes used = 199172 (199 KiB)")
*--#] humanstats :
*--#[ ModuleOption_dollar_order :
$a = 0;
ModuleOption sum,$a;
$b = 0;
ModuleOption maximum,$b;
$c = 0;
ModuleOption minimum,$c;
$d = 0;
ModuleOption local,$d;
discard;
.end
assert succeeded?
*--#] ModuleOption_dollar_order :
*--#[ Issue49 :
* Add mul_ function for polynomial multiplications
Symbols x,y,z;
Expand Down
7 changes: 7 additions & 0 deletions check/fixes.frm
Original file line number Diff line number Diff line change
Expand Up @@ -4437,6 +4437,13 @@ assert result("testCF1") =~ expr("putfirst_(f,2,mu1)*putfirst_(e,2,mu1)*putfirst
assert result("testCF2") =~ expr("d(mu2,mu1)*e(mu2,mu1)*f(mu2,mu1)")
assert result("testCF3") =~ expr("d(mu2,mu1,mu3)*e(mu2,mu1,mu3)*f(mu2,mu1,mu3)")
*--#] Issue750 :
*--#[ Issue766 :
CF f(s,s);
ModuleOption local,$a;
.end
assert warning?("Excess information in symmetric properties")
assert warning?("Undefined $-variable")
*--#] Issue766 :
*--#[ PullReq535 :
* This test requires more than the specified 50K workspace.
#:maxtermsize 200
Expand Down
29 changes: 26 additions & 3 deletions doc/manual/module.tex
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,42 @@ \chapter{Modules}
\item [Definitions\index{definitions}] These define new expressions.
\item [Executable\index{executable statements} statements] The operations
on all active expressions.
\item [OutputSpecifications\index{output specifications}] These specify the
\item [Output specifications\index{output specifications}] These specify the
output representation.
\item [End-of-module specifications\index{end of module specifications}]
Extra settings that are for this module only.
\item [Mixed statements\index{mixed statements}] They can occur in various
classes. Most notably the print statement.
\end{description}
Statements must occur in such an order that no statement follows a
statement of a later category. The only exception is formed by the mixed
statements, which can occur anywhere. This is different from earlier
statement of a later category, except as described bellow.
This is different from earlier
versions of \FORM\ in which the order of the statements was not fixed. This
did cause a certain amount of confusion about the workings of \FORM\@.

The exceptions are:
\begin{itemize}
\item Mixed statements are permitted in the executable statements,
output specifications, and end-of-module specifications parts of a module.
\item \texttt{Format}\index{format} statements are permitted anywhere.
\item \texttt{ModuleOption}\index{moduleoption} statements that control how \$-variables are handled
during parallel execution are permitted anywhere.
\end{itemize}
The last exception allows such \texttt{ModuleOption} statements to appear inside procedures
that use \$-variables and do not contain a \texttt{.sort}.
For example, the following structure is valid:
\begin{verbatim}
#procedure SortlessProc
$procLocalDollar = ...
ModuleOption local $procLocalDollar;
* more executable statements here
#endprocedure

#call SortlessProc
* more executable statements here
.sort
\end{verbatim}

There are several types of modules.
\begin{description}
\item[.sort\index{.sort}] \label{instrsort} The general end-of-module.
Expand Down
25 changes: 23 additions & 2 deletions sources/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
*/

#include "form3.h"
#include "comtool.h"

/*
com1commands are the commands of which only part of the word has to
Expand Down Expand Up @@ -617,8 +618,28 @@ int CompileStatement(UBYTE *in)
}
else if ( k->type == MIXED2 ) {}
else if ( k->type > AC.compiletype ) {
if ( StrCmp((UBYTE *)(k->name),(UBYTE *)"format") != 0 )
AC.compiletype = k->type;
/*
* We intentionally do NOT update "compiletype" for:
* - Format statements (type = TOOUTPUT)
* - ModuleOption statements (type = ATENDOFMODULE)
* with sum/maximum/minimum/local (i.e., $-variable-related options)
*
* This relaxes the ordering constraint, allowing statements with
* type >= the current "compiletype" to follow.
*/
if ( StrCmp((UBYTE *)(k->name),(UBYTE *)"format") == 0 )
goto NoUpdateCompileType;
if ( StrCmp((UBYTE *)(k->name),(UBYTE *)"moduleoption") == 0 ) {
UBYTE *ss = s;
SkipSpaces(&ss);
if ( ConsumeOption(&ss,"sum")
|| ConsumeOption(&ss,"maximum")
|| ConsumeOption(&ss,"minimum")
|| ConsumeOption(&ss,"local") ) goto NoUpdateCompileType;
}
AC.compiletype = k->type;
NoUpdateCompileType:
;
}
else if ( k->type < AC.compiletype ) {
switch ( k->type ) {
Expand Down
11 changes: 9 additions & 2 deletions sources/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,14 @@ Error2:;
AR.PolyFunExp = 0;
AC.PolyRatFunChanged = 1;
*t = c;
if ( *t == '+' ) {
if ( *t == '+' || *t == ',' ) {
if ( *t == ',' ) {
/*
* Somehow "+" is not checked by CoModuleOption, and the word
* after "+" is ignored. We take advantage of this.
*/
*t = '+';
}
t++; s = t;
t = EndOfToken(s);
c = *t; *t = 0;
Expand Down Expand Up @@ -672,7 +679,7 @@ UBYTE * DoModDollar(UBYTE *s, int type)
number = GetDollar(name);
if ( number < 0 ) {
number = AddDollar(s,0,0,0);
Warning("&Undefined $-variable in module statement");
Warning("Undefined $-variable in module statement");
}
md = (MODOPTDOLLAR *)FromList(&AC.ModOptDolList);
md->number = number;
Expand Down
6 changes: 3 additions & 3 deletions sources/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ illegsym: *s = cc;
else goto illegsym;
*s = cc;
if ( *s != ')' || ( s[1] && s[1] != ',' && s[1] != '<' ) ) {
Warning("&Excess information in symmetric properties currently ignored");
Warning("Excess information in symmetric properties currently ignored");
s = SkipField(s,1);
}
else s++;
Expand All @@ -1547,7 +1547,7 @@ retry:;
if ( ( StrICont(par,(UBYTE *)"arguments") == 0 )
|| ( StrICont(par,(UBYTE *)"args") == 0 ) ) {}
else {
Warning("&Illegal information in number of arguments properties currently ignored");
Warning("Illegal information in number of arguments properties currently ignored");
error = 1;
}
*s = cc;
Expand All @@ -1571,7 +1571,7 @@ retry:;
if ( ( StrICont(par,(UBYTE *)"arguments") == 0 )
|| ( StrICont(par,(UBYTE *)"args") == 0 ) ) {}
else {
Warning("&Illegal information in number of arguments properties currently ignored");
Warning("Illegal information in number of arguments properties currently ignored");
error = 1;
}
*s = cc;
Expand Down
Loading