c***@gmail.com
2015-02-23 22:34:01 UTC
Hello:
I previously created a Google Code page to attempt a simplified end-of-line processing of text files in ISO m2.
See "m2-text-filters - ISO Modula-2 Text Filters - Google Project Hosting"
<https://code.google.com/p/m2-text-filters/>
I attempted to emulate the approach of N. Wirth's "Programming in Modula-2". This simple approach is seen in Logitech's Modula-2 system and the Lilith, and probably other m2 systems who used the InOut library definitions from PIM2.
There, a single EOL character constant is returned on reading the end-of-line in a text file, so end-of-line does not appear to require special treatment. After you read the end-of-line, you are ready to read the first character of the next line.
But in ISO m2, SkipLine is generally needed when an end-of-line is encountered.
On the Google Code site, I hid the call to SkipLine and returned a single character constant, EOL. I wanted to emulate PIM2's simplicity.
But where I failed was in treating end-of-line (eol) more generally as a CR LF pair or a single LF or a single CR. The programs on the Google Code site are only tested on text lines terminated with the single eol character of the p1 Modula-2 system, the LF character.
I created a blog, Modula2Squad DOT com, to present a possible solution to this problem.
<http://www.modula2squad.com/>
My second blog entry presents an example program, CountLinesChars, which uses RawIO and StreamFile libraries and is supposed to handle any end-of-line (eol), which is defined by the EBNF rule, eol = cr [ lf ] | lf.
It has been tested only on p1 Modula-2.
I welcome testing the 2 example programs on other ISO m2 systems such as ADW m2 and gm2.
Modifications will probably be needed to get the programs to run correctly on these other ISO m2 systems. The end-of-line handling by RawIO.ReadChar itself might need modification.
Another possible modification is in the calls to ProgramArgs.NextArg().
ProgramArgs.NextArg() is first called in these examples to skip the programname, so the next argument read is a named input text file. Other m2 systems already skip the programname, so there you would need to remove the extra call to ProgramArgs.NextArg().
Carl
I previously created a Google Code page to attempt a simplified end-of-line processing of text files in ISO m2.
See "m2-text-filters - ISO Modula-2 Text Filters - Google Project Hosting"
<https://code.google.com/p/m2-text-filters/>
I attempted to emulate the approach of N. Wirth's "Programming in Modula-2". This simple approach is seen in Logitech's Modula-2 system and the Lilith, and probably other m2 systems who used the InOut library definitions from PIM2.
There, a single EOL character constant is returned on reading the end-of-line in a text file, so end-of-line does not appear to require special treatment. After you read the end-of-line, you are ready to read the first character of the next line.
But in ISO m2, SkipLine is generally needed when an end-of-line is encountered.
On the Google Code site, I hid the call to SkipLine and returned a single character constant, EOL. I wanted to emulate PIM2's simplicity.
But where I failed was in treating end-of-line (eol) more generally as a CR LF pair or a single LF or a single CR. The programs on the Google Code site are only tested on text lines terminated with the single eol character of the p1 Modula-2 system, the LF character.
I created a blog, Modula2Squad DOT com, to present a possible solution to this problem.
<http://www.modula2squad.com/>
My second blog entry presents an example program, CountLinesChars, which uses RawIO and StreamFile libraries and is supposed to handle any end-of-line (eol), which is defined by the EBNF rule, eol = cr [ lf ] | lf.
It has been tested only on p1 Modula-2.
I welcome testing the 2 example programs on other ISO m2 systems such as ADW m2 and gm2.
Modifications will probably be needed to get the programs to run correctly on these other ISO m2 systems. The end-of-line handling by RawIO.ReadChar itself might need modification.
Another possible modification is in the calls to ProgramArgs.NextArg().
ProgramArgs.NextArg() is first called in these examples to skip the programname, so the next argument read is a named input text file. Other m2 systems already skip the programname, so there you would need to remove the extra call to ProgramArgs.NextArg().
Carl