<div dir="ltr"><div class="gmail_default" style="font-family:arial,sans-serif">A rare case where I disagree with you, Doug. If the language is reasonably regular (I do not mean in the strict Kleene sense), a recursive descent parser is not much harder to write than a yacc grammar, and much smoother at providing good error messages. Having done many yaccs and many RD parsers, I no longer go to yacc.</div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif">To put it another way, there are few programming tasks I enjoy more than writing a recursive descent parser for a sane language.</div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif">Now if the language is not so regular, my position might shift. I do recall Bjarne dynamically editing the generated tables mid-parse to get yacc to handle at least one stage of C++'s development.</div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif">Another way to think of it is that if you are designing the language and it is undergoing frequent changes in grammar, yacc could certainly be move you along faster. But even then once things had settled I'd still redo it as RD, for the quality of the result.</div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif">You can credit Stephen R. "Software" Steve for this change in my thinking.</div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif">-rob</div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Mar 10, 2025 at 1:12 PM Douglas McIlroy <<a href="mailto:douglas.mcilroy@dartmouth.edu">douglas.mcilroy@dartmouth.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">> everyone should write for their first compiler in Pascal for a<br>> simple language and no cheating using YACC.  You need to write the whole<br>> thing if you want to understand how parsing really works.</div><div dir="ltr"><br></div><div>Yacc certainly makes it easier to write parsers for big grammars, but it's far from cheating. You need to know a lot more about parsing to use Yacc than you need to roll your own. </div><div><br></div><div>Hand parsing of a tiny grammar is almost a  necessary step on the way to understanding Yacc. But I think hand-building the whole parser for a compiler is unnecessary torture--like doing trigonometry with log tables.</div><div><br></div><div>Doug</div></div></div></div></div></div>
</blockquote></div>