<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-19301055.post114551488308079673..comments</id><updated>2009-11-11T01:13:12.616+02:00</updated><title type='text'>Comments on EnErGy[CSDX] Blog: Рисуем диаграмы реляционной базы</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://energyblog.blogspot.com/feeds/114551488308079673/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19301055/114551488308079673/comments/default'/><link rel='alternate' type='text/html' href='http://energyblog.blogspot.com/2006/04/blog-post_20.html'/><author><name>EnErGy[CSDX]</name><uri>http://www.blogger.com/profile/01217432111321323317</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-19301055.post-114767576198528749</id><published>2006-05-15T09:49:00.000+03:00</published><updated>2006-05-15T09:49:00.000+03:00</updated><title type='text'>i wouldn`t mind if you iclude this into pyparsing....</title><content type='html'>i wouldn`t mind if you iclude this into pyparsing.&lt;BR/&gt;i accept your suggestions</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19301055/114551488308079673/comments/default/114767576198528749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19301055/114551488308079673/comments/default/114767576198528749'/><link rel='alternate' type='text/html' href='http://energyblog.blogspot.com/2006/04/blog-post_20.html?showComment=1147675740000#c114767576198528749' title=''/><author><name>EnErGy [CSDX]</name><uri>http://www.blogger.com/profile/09096585177254790874</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://energyblog.blogspot.com/2006/04/blog-post_20.html' ref='tag:blogger.com,1999:blog-19301055.post-114551488308079673' source='http://www.blogger.com/feeds/19301055/posts/default/114551488308079673' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-19301055.post-114737436719601446</id><published>2006-05-11T22:06:00.000+03:00</published><updated>2006-05-11T22:06:00.000+03:00</updated><title type='text'>Dear EnergyBlog:From time to time I use Google to ...</title><content type='html'>Dear EnergyBlog:&lt;BR/&gt;&lt;BR/&gt;From time to time I use Google to look for any intrepid pyparsing users out there, and I found your program on energyblog.  You have done a very nice job with this.  I have some *minor* comments on your grammar, use them or not as you wish (free advice is worth what you pay for it):&lt;BR/&gt;&lt;BR/&gt;1. I had to stare at this a bit to see what you were doing:&lt;BR/&gt;&lt;BR/&gt;    reduce(lambda a,b:a+" "+b,tok)&lt;BR/&gt;    &lt;BR/&gt;I think a more common form of this is:&lt;BR/&gt;    &lt;BR/&gt;    " ".join(tok)&lt;BR/&gt;    &lt;BR/&gt;For that matter, you could change:&lt;BR/&gt;&lt;BR/&gt;    field_def = OneOrMore(Word(alphanums+"_\"':-") | skobki)&lt;BR/&gt;&lt;BR/&gt;to use the Combine class:&lt;BR/&gt;&lt;BR/&gt;    field_def = Combine( OneOrMore(Word(alphanums+"_\"':-"), joinString=" ", adjacent=False ) \&lt;BR/&gt;                | skobki)&lt;BR/&gt;&lt;BR/&gt;and do away with the parse action completely.&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;2. I very much like these constructions:&lt;BR/&gt;&lt;BR/&gt;    create_table_def = Literal("CREATE") + "TABLE" + ...&lt;BR/&gt;    add_fkey_def=Literal("ALTER")+"TABLE"+"ONLY" + ...&lt;BR/&gt;    &lt;BR/&gt;and so on.  Many people make the mistake of defining such expressions as:&lt;BR/&gt;&lt;BR/&gt;    create_table_def = Literal("CREATE TABLE") + ...&lt;BR/&gt;    add_fkey_def=Literal("ALTER TABLE ONLY") + ...&lt;BR/&gt;    &lt;BR/&gt;but this defeats the flexible whitespace handling between keywords.  Well done!&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;3. Your definition of field_list_def as:&lt;BR/&gt;&lt;BR/&gt;    field_list_def =  field_def + ZeroOrMore("," + field_def) &lt;BR/&gt;&lt;BR/&gt;forces you to add a parse action to skip over the delimiting commas.  Try switching to delimitedList:&lt;BR/&gt;&lt;BR/&gt;    field_list_def =  delimitedList( field_def )&lt;BR/&gt;&lt;BR/&gt;delimitedList generates almost the exact same expression, but also suppresses the delimiters, so you don't need to define the parse action.  Or you can just modify your existing definition to suppress the commas, using&lt;BR/&gt;&lt;BR/&gt;    field_list_def =  field_def + ZeroOrMore(Suppress(",") + field_def) &lt;BR/&gt;&lt;BR/&gt;This is almost exactly what delimitedList generates.&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;4. You might want to look into defining some results names.  Results names are there to help you avoid creating expressions like:&lt;BR/&gt;&lt;BR/&gt;    return """ "%s":%s -&gt; "%s":%s """ %(tok[3],tok[10],tok[13],tok[15])&lt;BR/&gt;    &lt;BR/&gt;Explicit reference to token elements by index number can make your grammar fragile, especially if you update it later to insert new fields, thereby forcing you to update all of the index references after the inserted field.  It's even worse if you insert an optional field, because then you have to first check to see if the optional field was used, and then recalculate indexes dynamically.&lt;BR/&gt;&lt;BR/&gt;If you instead define you grammar expressions like this:&lt;BR/&gt;&lt;BR/&gt;    add_fkey_def=Literal("ALTER")+"TABLE"+"ONLY" + Word(alphanums+"_").setResultsName("tableName") + "ADD" \&lt;BR/&gt;        + "CONSTRAINT" + Word(alphanums+"_") + \&lt;BR/&gt;        "FOREIGN"+"KEY"+"("+Word(alphanums+"_").setResultsName("foreignKeyName")+")" \&lt;BR/&gt;        +"REFERENCES"+Word(alphanums+"_").setResultsName("fkTableName")+\&lt;BR/&gt;        "("+Word(alphanums+"_").setResultsName("fkColName")+")"+";" &lt;BR/&gt;&lt;BR/&gt;You can then reference the tokens by field name:&lt;BR/&gt;&lt;BR/&gt;    return """ "%s":%s -&gt; "%s":%s """ %(tok.tableName,tok.foreignKeyName,tok.fkTableName,tok.fkColName)&lt;BR/&gt;    &lt;BR/&gt;or even:&lt;BR/&gt;&lt;BR/&gt;    return """ "%(tableName)s":%(foreignKeyName)s -&gt; "%(fkTableName)s":%(fkColName)s """ % tok&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;&lt;BR/&gt;Overall, though, a nice SQL graphing utility.  Would you mind if I included it with the pyparsing examples? Either yes or no, I'm glad pyparsing is working for you.&lt;BR/&gt;&lt;BR/&gt;Dasvedanya,&lt;BR/&gt;-- Paul</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19301055/114551488308079673/comments/default/114737436719601446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19301055/114551488308079673/comments/default/114737436719601446'/><link rel='alternate' type='text/html' href='http://energyblog.blogspot.com/2006/04/blog-post_20.html?showComment=1147374360000#c114737436719601446' title=''/><author><name>Paul McGuire</name><uri>http://www.blogger.com/profile/07398966790089965794</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://energyblog.blogspot.com/2006/04/blog-post_20.html' ref='tag:blogger.com,1999:blog-19301055.post-114551488308079673' source='http://www.blogger.com/feeds/19301055/posts/default/114551488308079673' type='text/html'/></entry></feed>