/ main program and parsing rule interpreter
sef=sec^sec; clf=clc^clc; bfs=bcs^bcs; bfc=bcc^bcc /fail indicator
.globl flush,obuild,putch,iget,kput
.globl cfile,dfile,ofile,input
.globl main,succ,fail,errcom,pbundle,parse,diag
.globl alt,salt,stop,goto
/ get arguments from shell
/ arg2 is output file (standard output if missing)
/ initialize stack, for definitions see tmgc.s
/ go interpret beginning at "start"
/write a two letter message on diagnostic file
/ all functions that succeed come here
/ test the exit indicator, and leave the rule if on
/ get interpreted instruction
/ save its exit bit (bit 0) on stack
/ distinguish type of instruction by ranges of value
<bad address in parsing\0>;.even
/ tmg-coded rule, execute and test its success
/ bfc = branch on fail clear
/ all functions and rules that fail come here
/ if exit bit is on do a fail return
/ if following instruction is an alternate (recognized literally)
/ do a goto, if a success alternate, do a nop
/ otherwise do a fail return
/ bundle translations delivered to this rule,
/ restore interpreted instruction counter (i)
/ update input cursor (j) for invoking rule
/ update high water mark (k) in ktable
/ if there was a translation delivered, add to stack frame
/ restore interpreted instruction counter
/ diag and parse builtins
/ set current file to diagnostic or output
/ save and restore ktable water mark around parse-translate
/ also current file and next frame pointer (g)
/ if it delivered translation, put it in ktable and set
/ instruction counter for
/ translation generator to point there
/ advance stack frame to invoke a parsing rule
/ copy corsor, watr mark, ignored class to new frame
/ set intial frame length to default (g1)
/ r0,r1 are new i,environment
/pbundle entered with pointer to earliest element of bunlde
/to reduce from the top of stack in r0
/exit with pointer to bundle in r0, or zero if bundle is empty
/ tmg translation rule interpreter (generator)
/ see tmgc.s for definitions
.globl x,si,ek,ep,ek.fs,ep.fs,fs
.globl start,end,tables,ktab,ktat
/ if exit bit is on pop stack frame restore inst counter and return
/ get interpreted instruction, decode by range of values
<bad address in translation\0>;.even
/ builtin translation function
/ tmg-coded translation subroutine
/ execute it in current environment
/ delivered compound translation
/ instruction counter is in ktable
/ set the k environment for understanding 1, 2 ...
/ to designate this frame
/ execute rule called for by 1 2 ...
/ found relative to instruction counter in the k environment
/ this frame becomes th p environment for
/ any parameters passed with this invocation
/ e.g. for 1(x) see also .tq
/element is 1.1, 1.2, .. 2.1,...
/ tmg output routines/ and iget
.globl putch,obuild,iget,flush
/ adds 1 or 2 characters in r0 to output
/ r0 points to string to put out on current output file (cfile)
/ if last file differed from current file, flush output buffer first
/ in any case flush output buffer when its write pointer (outw)
/ copy output buffer onto last output file and clear buffer
/ get interpreted instruction for a parsing rule
/ negative instruction is a pointer to a parameter in this
/ stack fromae, fetch that instead
/ put environment pointer in r1
mov r0,-(sp) /save the exit bit
/there followeth the driving tables