[Tutor] parsing chemical formula

Blake Winton bwinton@tor.dhs.org
Mon, 29 Mar 1999 20:41:07 -0500 (EST)

> On Mon, 29 Mar 1999, Steve Spicklemire wrote:
> don't see where you parse the user input here. I'll be more specific:
> How will the program be able to figure out how many atoms of each type
> are in a molecule like (NH4)3PO4? How will it know the difference
> between CO (carbon monoxide) and Co (a cobalt atom)? It seems to be
> that figuring out the difference between Co and CO and interpreting
> the parentheses correctly is fairly tricky (at least for me). Any
> other suggestions would be appreciated.

I've been playing around with John Aycock's "Little Language Framework"
(at http://www.csc.uvic.ca/~aycock/), and it looks pretty much perfect
for what you're trying to do, so I whipped a quick little something up.

WARNING!!!  :  It's not really suitable for the tutor list, since it
               relies on a non-standard Python module, and compiler
               technology isn't really beginner material.  But it works,
               so far.  I can try to explain what I did, if anyone
               thinks it'll be useful, but I think the explanation would
               be better kept to email.