diff options
Diffstat (limited to 'pkg/utilities/nttools/texpand/mkrules.x')
-rw-r--r-- | pkg/utilities/nttools/texpand/mkrules.x | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/texpand/mkrules.x b/pkg/utilities/nttools/texpand/mkrules.x new file mode 100644 index 00000000..c1dd3aad --- /dev/null +++ b/pkg/utilities/nttools/texpand/mkrules.x @@ -0,0 +1,48 @@ +define SZ_COLVAL SZ_LINE + +# MKRULES -- Add a new rule to the target and action tables +# +# B.Simon 25-Apr-88 Original + +procedure mkrules (work, target, action) + +pointer work # i: Table containing parser results +pointer target # i: Table containing patterns to be matched +pointer action # i: Table containing possible expansions +#-- +int nwork, naction, ntarget, iwork, iaction + +int numstack() + +errchk movtbrow, putstacki + +begin + # Check for null rules + + nwork = numstack (work) + if (nwork <= 0) + return + + # Move the first row from the work table to the target table + + call pushstack (target) + naction = numstack (action) + ntarget = numstack (target) + + call movtbrow (work, 1, target, ntarget) + call putstacki (target, "_FIRST", naction+1) + call putstacki (target, "_LAST", naction+nwork-1) + call putstacki (target, "_USED", NO) + + # Move the remaining rows to the action table + + iaction = naction + do iwork = 2, nwork { + call pushstack (action) + iaction = iaction + 1 + call movtbrow (work, iwork, action, iaction) + } + + call tbrdel (work, 1, nwork) + +end |