Friday, July 17, 2015

Patting myself on the back with both hands

This week I created the ASCII translator. It came to just over 800 lines of code—with lots of block comments and blank lines, so probably under 500 lines of actual Python. I wrote most of it on Monday and finished the first draft on Tuesday. Wednesday was museum day, but yesterday I sat down to test it. There were perhaps ten minor errors of the sort where I spelled a variable name two different ways, or forgot to initialize some global variable at the right time. There were maybe three places where I had to say, "hmmm, that can't work that way, need to recode". But by supper time all the features had been successfully tested except for table formatting. Mind you, this includes the Knuth-Pratt justification code, ported over from the V1 module but lightly recoded.

This morning I began testing table formatting. That's the process of reading something like this,

/T r6 l50 r8
I | CHAPTER ONE: THE MIRROR CRACKS | 3 |
II | CHAPTER TWO: THE GLAZIER IS CALLED AND COMES TWO HOURS LATE | 24 |
III| CHAPTER THREE: DIM REFLECTIONS ARE CAST | 33 |
T/

and producing output like this,

     I | CHAPTER ONE: THE MIRROR CRACKS                     |       3 |
    II | CHAPTER TWO: THE GLAZIER IS CALLED AND COMES TWO   |      24 |
       | HOURS LATE                                         |         |
   III | CHAPTER THREE: DIM REFLECTIONS ARE CAST            |      33 |

Note that the long table cell was "reflowed" to fit the specified width of the column. Knuth-Pratt reflowed, of course.

Well, it all went together very quickly. It actually mostly worked out of the gate. I spent more time getting it to issue appropriate error messages than I did making it format correctly.

So that's done. (OK, I might go back in and implement "Bottom" alignment for table cells, which could be used in the example above.) But a major piece of code by anyone's standards, I think, written and tested in four days. I told the wife, "You know, I rock." She said, "Sure you do."

What with that and having knocked off all the easily-fixable issues from the github list, it is time to make a new release. We're looking at a busy weekend, so it will probably be Monday when I do that.

There remain two pieces of PPQT2 that I might work on. One is a Ppgen Translator, although I think I would first try to persuade RFrank or one of his minions to do it. The other is to go back and actually implement the drag-out windows using the research with which I started this blog not quite 2 years ago. I don't feel a lot of urgency about either. I really want to move on to some other projects.

Edit: After I wrote the above, I thought about how to actually implement bottom cell alignment. And there really wasn't much to it. I opened up the file and had it working in about 15 minutes.

/T r6 l40 rB8
I | CHAPTER ONE: THE MIRROR CRACKS | 3 |
II | CHAPTER TWO: THE GLAZIER IS CALLED AND COMES TWO HOURS LATE | 24 |
III| CHAPTER THREE: DIM REFLECTIONS ARE CAST | 33 |
T/

Note the "B" in the spec for the third column.

     I|CHAPTER ONE: THE MIRROR CRACKS          |       3|
    II|CHAPTER TWO: THE GLAZIER IS CALLED AND  |        |
      |COMES TWO HOURS LATE                    |      24|
   III|CHAPTER THREE: DIM REFLECTIONS ARE CAST |      33|

I really do rock, you know.

No comments: