Skip to content

Commit a7990f7

Browse files
committed
feat: relax ordering constraints for $-variable ModuleOptions
1 parent 73a6a14 commit a7990f7

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

sources/compiler.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
*/
4444

4545
#include "form3.h"
46+
#include "comtool.h"
4647

4748
/*
4849
com1commands are the commands of which only part of the word has to
@@ -617,8 +618,28 @@ int CompileStatement(UBYTE *in)
617618
}
618619
else if ( k->type == MIXED2 ) {}
619620
else if ( k->type > AC.compiletype ) {
620-
if ( StrCmp((UBYTE *)(k->name),(UBYTE *)"format") != 0 )
621-
AC.compiletype = k->type;
621+
/*
622+
* We intentionally do NOT update "compiletype" for:
623+
* - Format statements (type = TOOUTPUT)
624+
* - ModuleOption statements (type = ATENDOFMODULE)
625+
* with sum/maximum/minimum/local (i.e., $-variable-related options)
626+
*
627+
* This relaxes the ordering constraint, allowing statements with
628+
* type >= the current "compiletype" to follow.
629+
*/
630+
if ( StrCmp((UBYTE *)(k->name),(UBYTE *)"format") == 0 )
631+
goto NoUpdateCompileType;
632+
if ( StrCmp((UBYTE *)(k->name),(UBYTE *)"moduleoption") == 0 ) {
633+
UBYTE *ss = s;
634+
SkipSpaces(&ss);
635+
if ( ConsumeOption(&ss,"sum")
636+
|| ConsumeOption(&ss,"maximum")
637+
|| ConsumeOption(&ss,"minimum")
638+
|| ConsumeOption(&ss,"local") ) goto NoUpdateCompileType;
639+
}
640+
AC.compiletype = k->type;
641+
NoUpdateCompileType:
642+
;
622643
}
623644
else if ( k->type < AC.compiletype ) {
624645
switch ( k->type ) {

0 commit comments

Comments
 (0)