Whither lex?
Nov. 27th, 2004 10:47 am![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
Having gone through this exercise, I'm almost done (can't deal with function-call as statement or interesting things on the left-hand side of an assignment) in about six hours of work. This makes me wonder what the motivation for tools like lex and yacc are. For lex, regexps for many things are almost overkill; my scanner is a state machine that builds up words, checks to see whether they're keywords, and emits an appropriate token. This is a little simpler for being a Python generator function (so I can return multiple values via yield), but it feels like a smallish constant factor away from equivalent C code and about as much code as the lex description. And in all that's 300 lines of code; is the code-space savings worth the loss of debuggability you get using a tool?
Pretty much the same thing can be said about yacc. Hand-writing the LL(1) parser was pretty easy. Maybe a table-based LR(k) parser has a smaller code size so it runs better on old machines? For your trouble you get zero debuggability, though possibly better performance than a recursive-descent parser. At MIT I used ANTLR, an LL(k) parser generator, but I don't think I get much beyond some automated munging of the grammar. My impression (not that I'm trying here) is that error recovery sucks in LR parsers and it's a little better in the LL world. yacc makes you munge your grammar less but you still need some work for things like operator precedence.
So if these tools don't generate fast or understandable code, and interpreting their output/error messages involves understanding their theoretical basis, and they make code harder to debug, why do they get so much use?
This corresponds scarily well with my job. Like, I've confronted the horror that is W3C XML Schema: it doesn't disgust me any more, which is probably bad, but mostly because I've converted the SAN loss from reading the spec into knowledge. Which then brings us into the fine world of Lovecraftian W3C specs...
XML Schema. KNOW 6 / 5 SAN. Specification. An oily black cloud that validates XML documents.
WSDL. KNOW 3 / 3 SAN. Specification. A screaming headless specification with a thousand young. Gain 2 KNOW if WSDL and XML Schema are both revealed.
Infoset. KNOW 2 / 4 SAN. Specification. A terrible tree-shaped mound of square brackets that devours all it comes across. +2 to attack any other specification.
The one terrible problem, of course, is the analog of Lightning Bolt, in which every player gains a single momentary glimpse of the horror of the entire web services specification series...I can't decide whether this should be Semantic Web or WS-Unspeakable.
Random computing foo
Oct. 24th, 2004 05:21 pmI coded up ( Ted's stupid solitaire game ) in about 200 lines of Haskell. Could be shorter.
I've had good luck installing OpenWRT on the Linksys WRT54G I bought a while ago. At this point I either need to configure IPSec or get IP-over-IP tunnelling on it, and figure out how to set up Shorewall, and then I can swap it in for donut. Scary.
Productive day off
Oct. 12th, 2004 07:17 am- Laundry.
- Zipcar'd to Furniture Store of DOOM! in Natick. It was impressive, and I'm glad I went, and I found a bed frame I liked (could, actually, be this, though their online catalog seems a little sparse), didn't actually buy anything. (Do these things normally cost $600-1000?) Didn't catch a movie.
- Since I had the car and was in the area, drove around Framingham kind of aimlessly for a bit, then rail-geeked around the commuter rail station. Maps show one line heading north and two south from Framingham, and somewhat surprisingly, they all seem to still be active.
- Installed "new" hard drive I bought in June. Started the long and arduous (well, long, anyways) process of formatting it; exhaustive badblocks check looks like it'll take a couple of days.
- Started poking at wireless router. Only useful if I can get a kernel onto it that supports IP-over-IP tunnelling (or perhaps IPSec, though I don't understand that terribly). If I can get a shell on it, I'll see if the Linksys kernel supports it (unlikely), or if one of the prebuilt kits out there supports it (only vaguely likely), before trying to build my own thing. Handily, I already have a Decaf compiler in Haskell for it if I need that.
Computers hate me
Oct. 2nd, 2004 08:54 amwatertown's syslogs think we lost power last night, with it being on at 1 AM, off at 1:20, and back on for sure at 1:28. The fan in the bedroom woke me up both when it went out and when it came back. Couldn't fall back asleep, finished reading fantasy trilogy I was working on, made it back to bed.
So this morning the network was down. donut was doing the thing recently it's been doing, which is being stuck on
GRUB Loading stage1.5... GRUB Loading.....
(So, it found the boot sector, loaded GRUB's stage1, which loaded stage1.5, which got stuck loading stage2?) I kind of suspect this is the hard drive being picky, but then why would it find the boot block? At this point the system is old enough that I'd either want to consolidate it on to sol-draconi or go with the new-donut project ("build the house router into a Linux-based wireless AP").
watertown's subsequent reboot (to get ntp and zhm) wasn't entirely happy either. It booted fine, but the second monitor came up in 640x480 and off by a bit. So my background on the second screen was a nice picture of the lavender line, at a blue-over-purple signal. (The good news is, when I popped up an xterm, it was still the right physical size, so that bit of infrastructure definitely works.) Yay kicking the X server.
Some software
Sep. 30th, 2004 08:14 pmI was able to build rxvt-unicode on an oldish Red Hat machine pretty painlessly, though without Xft support. Waimea just depends on too much stuff to usefully build from source. Installing it on Athena might be doable, though, and would help fix the pain I'm currently in.
(I wonder what it means that my backgrounds on both machines are from Ashmont station.)
units does everything
Aug. 31st, 2004 08:51 pm2084 units, 71 prefixes, 32 nonlinear units
There's this program called units. It does everything. Well, it won't read your email. But you can do things like find out how big that "120 GB" hard drive really is:
You have: 120 gigabytes
You want: gibibytes
* 111.75871
/ 0.0089478485
What about cooking? Iron Chef Units can figure out how much butter you need:
You have: 2 tbsp butter
You want: stickbutter
* 0.25
/ 4
I hear they say, "a pint's a pound the world 'round." Is it?
You have: 1 pint water
You want: pound force
* 1.0431756
/ 0.95861142
Hmm. We should check to see if it's versed in the classical sciences, like, say, alchemy:
You have: lead
You want: gold
* 1.0519553
/ 0.95061071
Unfortunately, it doesn't seem to know about ISO standard units:
You have: 364.4 smoots
Unknown unit 'smoots'
Right now, my "solution" is to have two separate check-outs, one of which is "the head" and one of which is "my working copy". This scales poorly, though, especially if the fix to "the head" also turns out to be involved. I think the thing I want is a "cheap branch": I type something like vc push -r dzm-temp-branch and my version control system creates a "branch" for things that I've modified (maybe just on the local machine) and gets the head. I make my changes, then run vc pop -r dzm-temp-branch, which attempts to merge my changes in. I could live without version control on the "branch" (especially after I actually commit it to the mainline); I definitely don't want things like automated mail.
...I could do this, almost trivially, with a shell script and CVS, huh. Thought.
Computers suck
May. 31st, 2004 10:31 pmVerizon DSL, if it wasn't obvious, is a bad idea. We seem to have a "business" account, for reasons unknown. It uses PPPoE. Ick. And if the modem loses connectivity at all for any reason, when it comes back up we get renumbered. So now we're on our third external IP address in under a week. This is irritating for me.
Need to figure out wiring. Should look into conduit-type things more; Home Depot had PVC conduit for about $2/foot, which seems like a lot. The new-donut plan may be to replace it with an off-the-shelf "broadband router" or some such that runs Linux, and move the data on to a machine a step or two forward on Moore's Law, but CompUSA in Braintree didn't have the particular model the Slashdot article mentioned. They did have something with a proprietary 802.11 extension to get 35% more speed if you use their branded cards, so you could have only 48 times as much internal bandwidth before you hit the cable modem pipe to get your Web pages. For only twice the price I was expecting. Woot. Should feed model numbers into Froogle, and search terms into normal Google.
Dialing in to Athena
May. 15th, 2004 10:52 pmRSS feeds?
Feb. 19th, 2004 12:07 pmwatertown redux
Feb. 19th, 2004 09:29 amwatertown lives again
Feb. 16th, 2004 12:29 pmNow I just need to remember what else it was that was wrong with this. The ergonomics aren't great but better than my laptop. The two screens are nice, but I should find a window manager that deals (again) or switch to XINERAMA (with one 1600x1200 and one 1280x1024 display, though?). There's the generic "it's slow"ness, which I think is mostly the CPU (a 700 MHz Athlon), and the generic "not enough disk"ness (a 20 GB hard drive partitioned a bit much, but with 8 GB for Windows 98, 10 GB for various chunks of Linux, and 2 GB wasted, where some of that last bit is because of a bad spot on the disk). More memory would be nice, but 256 MB is adequate. So for a couple hundred bucks I could turn this back into a modern machine. But for a couple hundred bucks I could also get a new machine. I'll figure this out the next time I want to spend money.
Model railroad blog
Jan. 6th, 2004 11:51 amEDIT: Thanks to
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
Things I didn't do over break
Jan. 5th, 2004 03:36 pmIn positive news, I at least got to getting train stuff, finally, so now I'm exercising my meager woodworking skills. Yay rolling critical failures.
Accomplishment at work
Dec. 17th, 2003 02:35 pm(In actuality it's a script that reads a QMTest results file, which aggressively requires Python, and generates a file that's read by RT, which uses the embedded Perl to get a list of tickets corresponding to a test failure. So it's useful and not totally looney. Well, okay, so it is totally looney, but still...)
Stupidity in kernel upgrades
Dec. 16th, 2003 09:53 amThe sad state of home computing
Nov. 28th, 2003 08:22 pmConclusion: Moore's Law hits, watertown takes ten damage in the usability department. This feels distressing to me, though I can't really describe why. For a few hundred dollars I could put in a new motherboard with a faster processor and extra storage, but is this worthwhile if I'll just use the laptop for everything?
Why doesn't everybody want this?
Nov. 20th, 2003 12:44 pmSo now I want to do the same thing, but in Python. Except that the environment I'm running under uses threads. Uh-oh. And I can't set a signal handler not-in-the-main-thread, so a direct port fails. Oh, and running our C binary fails, too, mysteriously. (Could be that the top-level process doesn't intelligently handle SIGTERM.) I can actually set a timer as a thread pretty easily in Python, but calling os.kill() from the timeout handler doesn't seem to have an effect, or more appropriately, it kills the top-level process but not any of the children. Grr.
Finished Morrowind
Nov. 18th, 2003 02:24 pm( Minor plot spoilers, game reflections )
...so now I need a new distraction. I could put things I already have (MoO3, MSTS) on my laptop and play those. Or actually come up with a hobby that doesn't involve computers. Shocking, that concept. :-)
The loop has 3772 instructions in it. According to the P3 manual, floating-point instructions pipeline but never run in parallel with each other (except for the FXCH instruction). There's 1007 FXCH instructions, and another 66 instructions that aren't floating-point. Assuming that the scheduling is perfect (doing the first couple of dozen instructions on paper, it isn't) that means that the loop could run in, at an absolute minimum, 2699 cycles per iteration. Which is much more than 1962. Something is wrong here...
But, regardless: the XML-to-print toolchain feels much saner than the SGML-to-print toolchain. Maybe it's because XSL:FO and XSL Transformations are actually, say, documented by someone (the W3C). It helps that XML is trendy right now, so there are multiple online tutorials for the tools. And as a consequence of this, there are *gasp* multiple implementations of the tools (mostly the Java path and the not-Java path, but both seem to work well for XML-to-PDF). And, handily, osx will convert SGML to XML, so you don't have to go through the pain of typing out XML if you happen to have a DTD for your document floating around.