On Mon, Aug 01, 2011 at 01:07:07AM +0200, Don Simons wrote:
> 
> I'm not sure how any of the programs know when they come to the end of the
> file.
> 

M-Tx keeps a boolean `eofAll` that can be set only at one point
but is tested for in several places.

1. The main loop asks for a complete paragraph; if this paragraph
    contains no non-empty lines, that sets eofAll.
2. The paragraph reader asks for one line at a time; if an empty
    line is found (except right at the top of the file), that's the
    end of the paragraph.  It then skips all further blank lines.
3. The line reader keeps a one-line buffer `nextData` which it
    serves up if not empty; otherwise it tries to read another
    line and returns it whether empty or not.  
4. The routine that skips blank lines stores the first non-blank
    line it finds in `nextData` for later use.

The whole of M-Tx contains exactly one statement that actually reads 
from an input .mtx file.  That statement is a call to the system 
routine `readln`, which is supposed to strip off whatever the system
uses for end-of-line before returning the result.  The Pascal system
is also supposed to know how many characters a string may contain:
M-Tx doesn't know your system's rules and can't check whether you
obey them.

This solution should be feasible in PMX too, replacing 'paragraph'
by 'block'.  Some fancy footwork may be necessary to take into account
that ' / ' may legally appear in TeX strings (or simply prohibit that).  
`nextData` would then on occasion contain the unprocessed part
of line after ' / '.  

Dirk
-------------------------------
TeX-music@tug.org mailing list
If you want to unsubscribe or look at the archives, go to 
http://tug.org/mailman/listinfo/tex-music

Reply via email to