The GOP bumper sticker.
Forward., ?, ¡#%@!
Today’s WSJ called to my attention that Barack Obama’s re-election campaign has adopted the slogan “Forward.”. I read this initally as a command as in “Forward, March!”.
Of course the problem here is that the part of the command that results in execution is missing.
Next I tried reading it as “Forward (full stop)”. While this might seem like something from a ship’s engine telegraph, it is not. And somehow I do not think that this is what the campaign had in mind.
If we read the complete sentence literally and diagram it:
(implied "I",
"you", "we", or "they") | forward | (implied object)
|
Here, the ill-defined actor subject adds to the confusion of who is doing what. That sounds familiar in this President’s administration. But what is clear is that the implied object has been misdirected. Perhaps it has a future, eventually being delivered, that is if the Post Office survives bankruptcy. I suspect the more likely result is that the false promises of the current administration and Congress will be “lost in the mail”. Again.
More likely, a continuation of the “blame someone else” and “kick the can down the road” that have become the hallmark of Barack Obama’s presidency. Three years into an admistration, it is past time to be blaming your predecessor. The president should be leading Congress, but both parties in both the House and the Senate seem to have no strong desire to follow the President off a fiscal cliff.
I am reminded of the slogan of Peabody, the dog who had a time-machine and a pet boy, Sherman, in the “Rocky and Bullwinkle Show” feature. The two would shout “Forward…into the past”. I say, “Oh, no, not again, not 4 more years”.
lex and yacc Continued
Follow the link for an excellent tutorial ref1 on lex and yacc with some sample code. I will refer to this as ref1 in comments below.
Another lex and yacc tutorial with sample code . This post is based substantially on this second tutorial and the examples in the sample code.
A number of examples are provided. For each example, a script, say example1.compile, is present after you gunzip and tar x-tract.
chmod 755 the *.compile files to make them executable.
cat or edit each example, example4.l is the lex file and example4.y is the yacc file.
I have never been a fan of exercise, either in the gym or on paper. Give me a real problem or a real event to contest any day. But exercise is sometimes a necessary preparation for building strength and agility. Recalling Harvey Wagner and the “Mind Expanding Exercises” in his textbook Principles of Operations Research let us call these:
Stretching Exercises
Note: Do all of the examples. Stretching exercises extend but do not replace the tutorial.
0. Download the sample code. Gunzip and expand it. Mark the executable *.compile scripts and execute the example1.compile script. Resolve any knowledge gaps.
1. Build example2 and test it. Now enhance it so that it prints “MIXED” if the input is alpha-numeric, “NUMIXED” if the input is alpha-numeric with leading digit, “NUMBER” if all digits, “TEXT” if all letters and if the input is EXIT, Return 0.
Did you get a message like ex2.l:9: warning, rule cannot be matched on the lex execution? Why might it occur? How can you fix it if it does?
2. Build example4 and test it. What usability problems would you fix? Suggest 3 usability or reliability improvements. Create a version that implements the improvements.
3. Now create a version of the example4.compile script that includes the yacc “-rall” switch. Execute it and examine the y.output file. Do you think that the “-rall” switch aids understanding? Debugging? Checking? Testing? Designing?
4. Review the tutorial at ref1. Repeat exercise 3.
5. Create a word counting program using lex (flex). Nobody expects the Inquistion. Compile and test it.
6. Run example4.compile. Examine y.tab.h.
rm y.output, lex.yy.c, y.tab.h and y.tab.c. Run example1.compile again. Which files are created? Make note of the size(s).
mv or cp lex.yy.c to preserve it.
Run example4.compile again. Which files are different?
diff the preserved version of lex.yy.c and the just created one. Are they more or less different than you expected?
7. Run example4. Use the following inputs (from the tutorial)
heat on
heat off
target temperature 22
What were the responses?
Try “heat foo” – what is the result?
Try “target temp 99” – what is the result?
Rate the generated program on a robustness scale of 0-3.
Rate the generated program on a user friendliness scale of 0-3.
Explain how this experience will influence your future program designs.
Explain how this experience will influence your future program testing.
8. Between earlier examples and example4, can you explain what changed that allowed the removal of -ll (libfl if flex how can that be?) from the link specification?
What did yacc provide that allowed this to happen?
In your intermediate files, can you find the line number?
9. diff example4.l and example5.l
diff examle4.y and example5.y
Demonstrate your understanding of yytext and yylval by explaining the origin of their content and when it is created.
Further explain yytext and yylval as “c” variables in the generated program.
10. diff example4.y and example6.y
Explain your understanding of the origin of variable $2
Explain your understanding of the origin of variable $3
Explain why the specifics of $1 $2 $3 etc. are not that important.
Explain why the shared usage of $1 $2 $3 is important to the shared, generated code.
10. Explain the lexyacc efficency trade-off on the choices made for HEAT ON and HEAT OFF.
11. Run example5.compile and provide inputs from 7 above.
Describe your user experience:
a. Program correct?
b. Program robustness, security, reliability, resistance to failure.
c. Program presentation/beauty/ease-of-use/understandability
d. Program efficiency.
12. As a user, rank the factors a-d above. Check with your associates. Ask visitors to your home to evaluate. Ask strangers to evalute the list.
13. Create a version of example5 that is more user friendly. Consider recovery from errors, ease of use, lack of training, carelessness.
Now that you are warmed up, Wikipedia [Bison] and ref1 present calculator programmes. Build each, test and evaluate, share a blog post that compares and contrasts the available examples.
lex and yacc
If you lift the lid on the engine compartment of your car (bonnet to English-speakers, hood to Americans), you see a complex arrangement of TUBES, wires, boxes, containers, and mysterious objects. Worse, they may be concealed by covers, bundles and conduits. If you have a friend or perhaps classroom instruction, with the help of a readable manual, you can find your way and check your fluids, look for damage, identify the source of a mysterious new noise.
Should you decide that there is a problem that you can fix yourself, you will go to your tool box to choose the right wrench (spanner) or screwdriver to fix the problem.
Linux is not different. And the tool box is vast.
Or perhaps you wish to make something new and different. Linux (and Unix, and all that goes before) provides a huge tool box (the USPTO pretending to not know (“I am not knowing” (has this been outsourced too?)). The great advantage of the Linux distributions is that they are free (as in freedom) and free or inexpensive (in cost). When you receive benefit, give back.
In my home tool box, I have a basin wrench . Cost per use $5. It allows one to reach into the inaccessable space between the wall and the basin to loosen or tighten the nut that holds the faucet to the basin or the supply-line to the faucet.
LEX and YACC are just such tools. Like many tools in the Unix/linux world, the have a specific application. And they are absolutely genius in what they do.
“Proper tool for the proper job”. Each tool does one thing very well. Something else? That is why there is | (pipe)
If you are not trying to create a programme or solve specific problem, you may already know every thing you need to know.
lex – a tool to generate (in conjunction with yacc) C code for a lexical scanner
yacc – a tool to generate (in conjunction with lex) C code for a grammer interpreter.
In naive terms, lex – what do I see, yacc – what do I do with it.
Think about this problem: You are trying to create program that “understands” specific input words and is able to act on them.
lex is the tool that can do this. The “shorthand” description to lex and the C compiler can create a program for Linux that scans the input stream for specific values, and generates specific results.
If the inputs are more complicated, you may need to have the program interpret as an example “what to do” “thing that it is done to”. This is where yacc come in.
To add to the confusion, lex is the classic Unix program, flex is the Linux equivalent. Mostly compatable but subtly different.
Similarly, yacc is a Unix program, bison is the linux equivalent. Fortunately, flex and bison have compatability so previous knowledge and program source is not rendered valueless.
More in a future post.
Credit where credit is due
I could send the payments for my bills and snag my own website renewals but wife takes care of the former and my son takes care the latter. And my life is lighter. Thank you.
Mind Vacation
Back from a short mental break. I was thinking about my younger brother. He referenced Mose Allison. Hopefully, I am not suffering from the overworked mouth. Long ago and far away, I took a beautiful young lady to a movie. I loved the cinematography, light, and music. Probably I missed the interpersonal dynamics. I do remember that emerging into the light after the movie, it was similar to the summer light in Sweden. And how lovely she was. A pursuit. She chose another. Later, she took her own life.
Poop
I listen to Public Radio and I note that it is now apparently OK to refer to “poop” without a “bleep”. Tremendous progress. Most of us animals consider this a normal function, so normal that is not often talked about. But as HEALTH and NATURE become more popular topics, maybe we need to listen to the audience and not to the government censors.
This is a test. This is only a test. If the idiots that choose words for my former employers’ web censor cut this out, maybe it is time to move on.
Those of you who may have been Regular Navy may equate poop=straight skinny=the gouge. That is, the truth.
Exciting Archeology
Remembering an important teacher, I “googled” for his name and this popped up. This could be memories for me except that these pictures are of men 20 years before I met them. Drs. Alexander, Payne, Werthheimer, Mr. Bowen, Mr. Buse, esq. are ones I can say changed my life in various ways.
Error Errors
I got this error message box again. Can anyone tell me what it means?
I actually sort of know what it means, where it originates, and why. But it is a good example of bad programming practice and poor program development management that an end user sees a message like this.
What is wrong with the message? “Bad Opaque”. Yep. This message is worse than opaque, it is a black hole that sucks energy into oblivion. “Bad Juju” (not to be confused with juju) would be just as appropriate and more comprehensible. Where did this message come from? The title on the box provides a clue “Failed to enter room”. I was in a “virtual room” a while ago but the meeting is over and I have closed all of the visible windows. The message box is “on top” and will will not release focus. So, even though it is NOT OK, I click OK because that is the only thing to do.
Some time later, I discover an all-gray window with a title “Failed to connect”. Yep. The programmer clearly failed to connect the “Bad Opaque” message with the application. At least I guess they should be connected as the 3 windows appear to occur around the same time among the 10-12 windows I typically have open on my desktop with no indication on the task bar or system tray.
So my interpretation of this, which may or may not be accurate, is that the meeting I was in has ended, the window-less program that makes the connection tried to re-enter the now closed virtual room. Failing that in an unexpected way pops the “Bad Opaque”.
Somehow the connector or the room-enterer did not get the message that the session was over. A bit more transparency and better error messages would be helpful.
Some Microsoft products have gotten better about making it clear what the error is and what the consequences of “Cancel”, “End”, “OK”, etc are. But not everybody there has gotten the memo yet, or if they have they have not read it and taken it to heart.
I like this one too. It certainly gets your atten- tion. I comp- lained about it to the system administrator for several years. I am sure that it is no longer an issue because that account moved to Google Mail eliminating the application that was uncorrectable. At least this message is clear about what it means and where it comes from. The problem with this one is that while I may not be able to correct the error, the programmer who failed to anticipate the condition but was able to provide an error message could correct the code to make sure that the LookupHandle was allocated or perhaps provide a suggested corrective action to the user. At the very least, the programmer could suggest the external cause, if that were the case, so that external corrective action could be taken, preferably before but in any case after “Abort”-ing the application.
But my all-time favorite is this one.
Typical of Microsoft’s lack of quality control, due to some unexplained condition, you fall into a routine where the debugging software has been left engaged. The good news is that you can use Open Office on Linux to eliminate this message, Microsoft Office, AND best-of-all eliminate Windows.
Copper Bracelets
I made these bracelets a while back. The one in the foreground is in the style of Ashley 2979, a French Sinnet with 4 strands. The one in the background is in the style of Ashley 2976, also with 4 strands. Ashely notes that we are calling these “French Sinnet” while the French call them “Tresse Anglaise”. Ashley also notes that these sinnets are usually made with an odd number of strands, the simplest being 3. I have usually worked with an even number.
This wire is AWG 16 gauge copper electrical wire stripped of insulation. You get 3 pieces from each length of wire. Some types vary in color by strand. You will need approximately 2 times the length to be braided of each strand plus enough to hold on to.
To make 2976, start with 4 strands holding 2 strands in each hand. Take the strand that is furthest away over 2 under 1 and back around, alternating. The strands end on the same side they started.
To make 2979, start with 4 strands in one hand. Work the furthest one under/over/under and back around. Repeat.
Color is from heating with a torch while applying solder to bind the ends. Ends are then cut and filed smooth.