{"id":640,"date":"2010-11-03T21:48:48","date_gmt":"2010-11-04T02:48:48","guid":{"rendered":"http:\/\/yuguangzhang.com\/blog\/?p=640"},"modified":"2010-11-03T21:48:48","modified_gmt":"2010-11-04T02:48:48","slug":"coding-horror-and-the-illumination","status":"publish","type":"post","link":"http:\/\/yuguangzhang.com\/blog\/coding-horror-and-the-illumination\/","title":{"rendered":"Coding Horror and the Illumination"},"content":{"rendered":"<p>Can you imagine anything useful coming out of this line of code?<br \/>\n[cc lang=&#8221;python&#8221;]<br \/>\nprereqPattern=&#8221;'([A-Z]{2,5} \\d{3}\/[A-Z]{2,5} \\d{3}\\s*and\\s*[A-Z]{2,5} \\d{3}\/[A-Z]{2,5} \\d{3})|([A-Z]{2,5} \\d{3}\\s*and\\s*\\(*[A-Z]{2,5} \\d{3}\\)*)|(\\)\\s*and\\s*\\()|(One of [A-Z]{2,5} \\d{3}\\s*[, or\\d{3}]*;|[A-Z]{2,5} \\d{3}[, \\d{3}]*;|.*,\\s*[A-Z]{2,5} \\d{3}.*;|[A-Z]{2,5} \\d{3} or [A-Z]{2,5} \\d{3}|[A-Z]{2,5} \\d{3} or \\d{3}|[A-Z]{2,5} \\d{3})&#8221;&#8217;<br \/>\n[\/cc]<br \/>\nI can, because I&#8217;ve seen it. Here&#8217;s a small slice:<\/p>\n<pre>MATH 137 or 147\n ACTSC 231, STAT 230 or 240\nMATH 136 or 146\nACTSC 232\nACTSC 371\nAFM 272;ACTSC 291\nSTAT 330, 333\nSTAT 330, 333\n ACTSC 331, STAT 330\nAFM 372;ACTSC 391;ACTSC 231;ACTSC 231 and BUS 393;STAT 330;STAT 334\nAFM 372;ACTSC 391;ACTSC 231;ACTSC 231 and BUS 393;STAT 333 or 334\nACTSC 331\nAFM 101 or BUS 227\nAFM 101<\/pre>\n<p>A master piece at its time, and quite decent to maintain with the documentation:<br \/>\n[cc lang=&#8221;python&#8221;]<br \/>\n&#8216;CS 134 or 145 or a mark of 60% or higher in 136 or 138; Honours Mathematics or Software Engineering students only.&#8217;<br \/>\n&#8216;([A-Z]{2,5} \\d{3}) or (\\d{3})*&#8217;<br \/>\n(&#8216;CS 134&#8217;, &#8216;145&#8217;)<\/p>\n<p>&#8216;One of CS 134, 136, 138, 145; Computer Science students only.&#8217;<br \/>\n&#8216;([A-Z]{2,5} \\d{3})([, \\d{3}]*;)&#8217;<br \/>\n(&#8216;CS 134&#8217;, &#8216;, 136, 138, 145;&#8217;)<\/p>\n<p>&#8216;Computer Science students only.&#8217;<br \/>\n&#8216;(\\D* students only)&#8217;<br \/>\n&#8216;Computer Science students only&#8217;<\/p>\n<p>&#8216;CS 350 or ECE 354&#8217;<br \/>\n&#8216;([A-Z]{2,5} \\d{3}) or ([A-Z]{2,5} \\d{3})*&#8217;<br \/>\n(&#8216;CS 350&#8217;, &#8216;ECE 354&#8217;)<\/p>\n<p>&#8216;CM 339\/CS 341 or CS 350&#8217;<br \/>\n&#8216;([A-Z]{2,5} \\d{3})\/([A-Z]{2,5} \\d{3})( or [A-Z]{2,5} \\d{3})*&#8217;<br \/>\n(&#8216;CM 339&#8217;, &#8216;CS 341&#8217;, &#8216; or CS 350&#8217;)<\/p>\n<p>&#8216;DAC 201\/ENGL 203 and DAC 202\/ENGL 204&#8217;<br \/>\n &#8216;([A-Z]{2,5} \\d{3})\/([A-Z]{2,5} \\d{3}).*([A-Z]{2,5} \\d{3})\/([A-Z]{2,5} \\d{3})*&#8217;<br \/>\n(&#8216;DAC 201&#8217;, &#8216;ENGL 203&#8217;, &#8216;AC 202&#8217;, &#8216;ENGL 204&#8217;)<br \/>\n[\/cc]<br \/>\nAnd a light comes through. There is a better way, better than I ever imagined. In fact, <a href=\"http:\/\/yuguangzhang.com\/blog\/parsing-with-ply-the-good-bad-and-ugly\/\">the ugly phase of evolution<\/a> comes before the flowering. A metaphor for this would be the pollution during industrialization and a bloom of clean industries following it due to the emphasis on knowledge rather than machine labor.<br \/>\nSimply pass on the parenthesis in the lexer and rewrite the grammar so that it can see more of the input before having to make a decision for shift\/reduce conflicts. This is similar to using a parser with more lookahead, an oracle that sees infinitely many steps ahead.<\/p>\n<p style=\"text-align: center;\"><em>Yet, no matter how sweet the code, <\/em><\/p>\n<p style=\"text-align: center;\"><em>it is time to part ways. <\/em><\/p>\n<p style=\"text-align: center;\"><em>What comes next, <\/em><\/p>\n<p style=\"text-align: center;\"><em>no one knows. <\/em><\/p>\n<p style=\"text-align: center;\"><em>This age is past, <\/em><\/p>\n<p style=\"text-align: center;\"><em>and the ground is laid for the next one. <\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can you imagine anything useful coming out of this line of code? [cc lang=&#8221;python&#8221;] prereqPattern=&#8221;'([A-Z]{2,5} \\d{3}\/[A-Z]{2,5} \\d{3}\\s*and\\s*[A-Z]{2,5} \\d{3}\/[A-Z]{2,5} \\d{3})|([A-Z]{2,5} \\d{3}\\s*and\\s*\\(*[A-Z]{2,5} \\d{3}\\)*)|(\\)\\s*and\\s*\\()|(One of [A-Z]{2,5} \\d{3}\\s*[, or\\d{3}]*;|[A-Z]{2,5} \\d{3}[, \\d{3}]*;|.*,\\s*[A-Z]{2,5} \\d{3}.*;|[A-Z]{2,5} \\d{3} or [A-Z]{2,5} \\d{3}|[A-Z]{2,5} \\d{3} or \\d{3}|[A-Z]{2,5} \\d{3})&#8221;&#8217; [\/cc] I can, because I&#8217;ve seen it. Here&#8217;s a small slice: MATH 137 or 147 ACTSC 231, STAT 230 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[29],"tags":[65,64,69,67,66,63,68],"class_list":["post-640","post","type-post","status-publish","format-standard","hentry","category-coursetree","tag-coding-horror","tag-documentation","tag-look-ahead","tag-oracle","tag-parser","tag-regular-expressions","tag-tokens"],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/posts\/640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/comments?post=640"}],"version-history":[{"count":0,"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/posts\/640\/revisions"}],"wp:attachment":[{"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/media?parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/categories?post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yuguangzhang.com\/blog\/wp-json\/wp\/v2\/tags?post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}