CINXE.COM
language agnostic - Learning to write a compiler - Stack Overflow
<!DOCTYPE html> <html itemscope itemtype="https://schema.org/QAPage" class="html__responsive " lang="en"> <head> <title>language agnostic - Learning to write a compiler - Stack Overflow</title> <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196"> <link rel="apple-touch-icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> <link rel="image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml"> <link rel="canonical" href="https://stackoverflow.com/questions/1669/learning-to-write-a-compiler" /> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0"> <meta property="og:type" content= "website" /> <meta property="og:url" content="https://stackoverflow.com/questions/1669/learning-to-write-a-compiler"/> <meta property="og:site_name" content="Stack Overflow" /> <meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon@2.png?v=73d79a89bded" /> <meta name="twitter:card" content="summary"/> <meta name="twitter:domain" content="stackoverflow.com"/> <meta name="twitter:title" property="og:title" itemprop="name" content="Learning to write a compiler" /> <meta name="twitter:description" property="og:description" itemprop="description" content="Preferred languages: C/C++, Java, and Ruby.

I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, an..." /> <script id="webpack-public-path" type="text/uri-list">https://cdn.sstatic.net/</script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script defer src="https://cdn.sstatic.net/Js/third-party/npm/@stackoverflow/stacks/dist/js/stacks.min.js?v=90a447add688"></script> <script src="https://cdn.sstatic.net/Js/stub.en.js?v=30464efc364f"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4"> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=cc49ce762956"> <script> StackExchange.ready(function () { StackExchange.using("snippets", function () { StackExchange.snippets.initSnippetRenderer(); }); StackExchange.using("postValidation", function () { StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer'); }); StackExchange.question.init({showAnswerHelp:true,showTrendingSortLaunchPopover:false,showTrendingSortPostLaunchPopover:false,totalCommentCount:4,shownCommentCount:4,enableTables:true,questionId:1669}); styleCode(); StackExchange.realtime.subscribeToQuestion('1', '1669'); StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.js-post-body'); }); }); </script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7"> <script type="application/json" data-role="module-args" data-module-name="Shared/options.mod">{"options":{"locale":"en","serverTime":1740274359,"routeName":"Questions/Show","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","site":{"name":"Stack Overflow","description":"Q\u0026A for professional and enthusiast programmers","isNoticesTabEnabled":true,"enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"cookieDomain":".stackoverflow.com","childUrl":"https://meta.stackoverflow.com","negativeVoteScoreFloor":null,"enableSocialMediaInSharePopup":true,"protocol":"https"},"user":{"fkey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","tid":"aaaaa91c-365c-448b-9a3c-ce80354b4996","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}}}}</script> <script type="application/json" data-role="module-args" data-module-name="Shared/settings.mod">{"settings":{"search":{},"image":{"maxImageUploadSizeInBytes":10485760,"maxImageUploadSizeInBytesAnimatedGif":2097152},"paths":{"jQueryUIJSPath":"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js","jQueryUICSSPath":"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/themes/smoothness/jquery-ui.css"},"legal":{"useCustomConsent":false,"oneTrustTCFConfigId":"c3d9f1e3-55f3-4eba-b268-46cee4c6789c"},"snippets":{"renderDomain":"stacksnippets.net","snippetsEnabled":true},"questionLinkTitleReplacement":{"maxNumberOfSitesProcessed":10,"maxReplacementsPerSite":20},"auth":{"oauthInPopup":true},"tags":{},"userMessaging":{"showNewFeatureNotice":true},"markdown":{"enableTables":true},"subscriptions":{"defaultFreemiumMaxTrueUpSeats":50,"defaultMaxTrueUpSeats":1000,"defaultBasicMaxTrueUpSeats":250},"questions":{"enableSavesFeature":true,"maxTitleSize":150,"questionTitleLengthStartLiveWarningChars":50,"enableQuestionTitleLengthLiveWarning":true},"mentions":{"maxNumUsersInDropdown":50},"flags":{"allowRetractingFlags":true,"allowRetractingCommentFlags":true},"elections":{"opaVoteResultsBaseUrl":"https://www.opavote.com/results/"},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true},"comments":{},"site":{"enableImageHttps":true,"forceHttpsImages":true,"enableUserHovercards":true,"stacksEditorPreviewEnabled":true,"styleCode":true,"allowImageUploads":true},"intercom":{"appId":"inf0secd"}}}</script> <script>StackExchange.init();</script> <script> StackExchange.using.setCacheBreakers({"Js/adops.en.js":"6da43f5e0a84","Js/ask.en.js":"","Js/begin-edit-event.en.js":"20edbaccceae","Js/copy-transpiled.en.js":"f48f8f039185","Js/events.en.js":"","Js/explore-qlist.en.js":"ee2a4f8c3992","Js/full-anon.en.js":"427705904ec4","Js/full.en.js":"296fbe64881a","Js/highlightjs-loader.en.js":"a3e36fe85053","Js/inline-tag-editing.en.js":"8517756a2cb6","Js/keyboard-shortcuts.en.js":"c255a5a5979b","Js/markdown-it-loader.en.js":"781aa77e9602","Js/mentions-transpiled.en.js":"bcadb48d3570","Js/moderator.en.js":"a9347e812307","Js/postCollections-transpiled.en.js":"9f7a87e8cf0d","Js/post-validation.en.js":"44d59ccfc490","Js/question-editor.en.js":"","Js/review-v2-transpiled.en.js":"c9e05881f8ab","Js/revisions.en.js":"9dd135bb585f","Js/stacks-editor.en.js":"cf77c9d2187c","Js/tageditor.en.js":"5b8f289d02ef","Js/tageditornew.en.js":"ca426894aed0","Js/tagsuggestions.en.js":"762b96a1ae1f","Js/unlimited-transpiled.en.js":"8713a979101d","Js/wmd.en.js":"eef1c2cfa021","Js/snippet-javascript-codemirror.en.js":"0f42dbb990fa"}); StackExchange.using("gps", function() { StackExchange.gps.init(false); }); </script> <noscript id="noscript-css"><style>body,.s-topbar{margin-top:1.9em}</style></noscript> </head> <body class="question-page unified-theme"> <div id="signup-modal-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/signup-modal/index.mod">{"ContainerElementId":"signup-modal-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","TriggerEvent":"signupModalShow","OauthInPopup":true,"ReturnUrl":"https://stackoverflow.com/questions/1669/learning-to-write-a-compiler/1672","ReturnUrlForPopup":"https://stackoverflow.com/users/after-signup/oauth-only","SiteName":"Stack Overflow","SiteLogoPath":"https://cdn.sstatic.net/Sites/stackoverflow/Img/icon-48.png?v=b7e36f88ff92","AuthProviders":["Google","GitHub"],"ParentSiteUrl":"","IsInitiallyVisible":false}</script> <script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=f1f216c36f5e"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/8901.en.js?v=9ff34567d3a5"></script><script defer src="https://cdn.sstatic.net/Js/islands/signup-modal.en.js?v=47ec828efb46"></script> <script defer> dispatchEvent(new CustomEvent("openSignupModal")); </script> <div id="one-tap-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/one-tap/index.mod">{"ContainerElementId":"one-tap-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","GoogleClientId":"717762328687-iludtf96g1hinl76e4lc1b9a82g457nn.apps.googleusercontent.com","Autoselect":false,"ReturnUrl":"https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler%2f1672"}</script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=f1f216c36f5e"></script><script defer src="https://cdn.sstatic.net/Js/islands/one-tap.en.js?v=bc67e8c0f01e"></script> <div id="notify-container"></div> <div id="custom-header"></div> <header class="s-topbar ps-fixed t0 l0 js-top-bar"> <a href="#content" class="s-topbar--skip-link">Skip to main content</a> <div class="s-topbar--container"> <a href="#" class="s-topbar--menu-btn js-left-sidebar-toggle" role="menuitem" aria-haspopup="true" aria-controls="left-sidebar" aria-expanded="false"><span></span></a> <div class="topbar-dialog leftnav-dialog js-leftnav-dialog dno"> <div class="left-sidebar js-unpinned-left-sidebar" data-can-be="left-sidebar" data-is-here-when="sm"></div> </div> <a href="https://stackoverflow.com" class="s-topbar--logo js-gps-track" data-gps-track="top_nav.click({is_current:false, location:2, destination:8}); homelogo_nav.click({location:2})"> <span class="-img _glyph">Stack Overflow</span> </a> <ol class="s-navigation fw-nowrap" role="presentation"> <li class="md:d-none"> <a href="https://stackoverflow.co/" class="s-navigation--item js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:7})" data-ga="["top navigation","about menu click",null,null,null]">About</a> </li> <li> <button class="s-navigation--item js-gps-track" type="button" aria-controls="products-popover" aria-expanded="false" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-toggle-class="is-selected" data-gps-track="top_nav.products.click({location:2, destination:1})" data-ga="["top navigation","products menu click",null,null,null]"> Products </button> </li> <li class="md:d-none"> <a href="https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai" class="s-navigation--item js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:10})" data-ga="["top navigation","learn more - overflowai",null,null,null]">OverflowAI</a> </li> </ol> <div class="s-popover ws2 mtn2 p0" id="products-popover" role="menu" aria-hidden="true"> <div class="s-popover--arrow"></div> <ol class="list-reset s-anchors s-anchors__inherit"> <li class="m6"> <a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:3})" data-ga="["top navigation","teams submenu click",null,null,null]"> <span class="fs-body1 d-block">Stack Overflow for Teams</span> <span class="fs-caption d-block fc-black-400">Where developers & technologists share private knowledge with coworkers</span> </a> </li> <li class="m6"> <a href="https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:6})" data-ga="["top navigation","advertising submenu click",null,null,null]"> <span class="fs-body1 d-block">Advertising & Talent</span> <span class="fs-caption d-block fc-black-400">Reach devs & technologists worldwide about your product, service or employer brand</span> </a> </li> <li class="bt bc-black-200 pt6 px6 bbr-md"> <a href="https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:10})" data-ga="["top navigation","overflowai submenu click",null,null,null]"> <span class="fs-body1 d-block">OverflowAI</span> <span class="fs-caption d-block fc-black-400">GenAI features for Teams</span> </a> </li> <li class="pb6 px6 bbr-md"> <a href="https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:11})" data-ga="["top navigation","overflowapi submenu click",null,null,null]"> <span class="fs-body1 d-block">OverflowAPI</span> <span class="fs-caption d-block fc-black-400">Train & fine-tune LLMs</span> </a> </li> <li class="bt bc-black-200 py6 px6 bbr-md"> <a href="https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:12})" data-ga="["top navigation","labs submenu click",null,null,null]"> <span class="fs-body1 d-block">Labs</span> <span class="fs-caption d-block fc-black-400">The future of collective knowledge sharing</span> </a> </li> <li class="bg-black-100 bt bc-black-200 py6 px6 bbr-md"> <a href="https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company" class="fc-black-400 d-block py6 px6 h:fc-black-600" data-ga="["top navigation","about submenu click",null,null,null]">About the company</a> <a href="https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog" class="fc-black-400 d-block py6 px6 h:fc-black-600" data-ga="["top navigation","blog submenu click",null,null,null]">Visit the blog</a> </li> </ol> </div> <form id="search" role="search" action=/search class="s-topbar--searchbar js-searchbar " autocomplete="off"> <div class="s-topbar--searchbar--input-group"> <input name="q" type="text" role="combobox" placeholder="Search…" value="" autocomplete="off" maxlength="240" class="s-input s-input__search js-search-field wmn1 " aria-label="Search" aria-controls="top-search" data-controller="s-popover" data-action="focus->s-popover#show" data-s-popover-placement="bottom-start" /> <svg aria-hidden="true" class="s-input-icon s-input-icon__search svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18zM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0"/></svg> <div class="s-popover p0 wmx100 wmn4 sm:wmn-initial js-top-search-popover" id="top-search" role="menu"> <div class="s-popover--arrow"></div> <div class="s-popover--content"> <div class="js-spinner p24 d-flex ai-center jc-center d-none"> <div class="s-spinner s-spinner__sm fc-orange-400"> <div class="v-visible-sr">Loading…</div> </div> </div> <span class="v-visible-sr js-screen-reader-info"></span> <div class="js-ac-results overflow-y-auto hmx3 d-none"></div> <div class="js-search-hints" aria-describedby="Tips for searching"></div> </div> </div> </div> </form> <nav class="h100 ml-auto overflow-x-auto pr12" aria-label="Topbar"> <ol class="s-topbar--content" role="menubar"> <li class="js-topbar-dialog-corral" role="presentation"> <div class="topbar-dialog siteSwitcher-dialog dno" role="menu"> <div class="header fw-wrap"> <h3 class="flex--item"> <a href="https://stackoverflow.com">current community</a> </h3> <div class="flex--item fl1"> <div class="ai-center d-flex jc-end"> <button class="js-close-button s-btn s-btn__muted p0 ml8 d-none sm:d-block" type="button" aria-label="Close" > <svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9z"/></svg> </button> </div> </div> </div> <div class="modal-content bg-blue-200 current-site-container"> <ul class="current-site"> <li class="d-flex"> <div class="fl1"> <a href="https://stackoverflow.com" class="current-site-link d-flex gx8 site-link js-gps-track" data-id="1" data-gps-track="site_switcher.click({ item_type:3 })"> <div class="favicon favicon-stackoverflow site-icon flex--item" title="Stack Overflow"></div> <span class="flex--item fl1"> Stack Overflow </span> </a> </div> <div class="related-links"> <a href="https://stackoverflow.com/help" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:14 })">help</a> <a href="https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a> </div> </li> <li class="related-site d-flex"> <div class="L-shaped-icon-container"> <span class="L-shaped-icon"></span> </div> <a href="https://meta.stackoverflow.com" class="s-block-link px16 d-flex gx8 site-link js-gps-track" data-id="552" data-gps-track="site.switch({ target_site:552, item_type:3 }),site_switcher.click({ item_type:4 })"> <div class="favicon favicon-stackoverflowmeta site-icon flex--item" title="Meta Stack Overflow"></div> <span class="flex--item fl1"> Meta Stack Overflow </span> </a> </li> </ul> </div> <div class="header" id="your-communities-header"> <h3> your communities </h3> </div> <div class="modal-content" id="your-communities-section"> <div class="call-to-login"> <a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler%2f1672" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler%2f1672" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a> to customize your list. </div> </div> <div class="header"> <h3><a href="https://stackexchange.com/sites">more stack exchange communities</a> </h3> <a href="https://stackoverflow.blog" class="float-right">company blog</a> </div> <div class="modal-content"> <div class="child-content"></div> </div> </div> </li> <li role="none"><button class="s-topbar--item s-btn s-btn__icon s-btn__muted d-none sm:d-inline-flex js-searchbar-trigger" role="menuitem" aria-label="Search" aria-haspopup="true" aria-controls="search" title="Click to show search"><svg aria-hidden="true" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18zM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0"/></svg></button></li> <li role="none"> <a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler%2f1672" class="s-topbar--item s-topbar--item__unset s-btn s-btn__outlined ws-nowrap js-gps-track" role="menuitem" rel="nofollow" data-gps-track="login.click" data-ga="["top navigation","login button click",null,null,null]">Log in</a> </li> <li role="none"><a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler%2f1672" class="s-topbar--item s-topbar--item__unset ml4 s-btn s-btn__filled ws-nowrap js-signup-button js-gps-track" role="menuitem" rel="nofollow" data-gps-track="signup.topbar.click" data-ga="["sign up","Sign Up Navigation","Header",null,null]">Sign up</a></li> </ol> </nav> </div> </header> <script> StackExchange.ready(function () { StackExchange.topbar.init(); }); StackExchange.scrollPadding.setPaddingTop(50, 10); </script> <div class="container"> <div id="homepage-wizard-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/homepage-wizard/index.mod">{"ContainerElementId":"homepage-wizard-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","Tags":["javascript","python","java","c#","php","android","html","jquery","c++","css","ios","sql","mysql","r","reactjs","node.js","arrays","c","asp.net","json","python-3.x",".net","ruby-on-rails","sql-server","swift","django","angular","objective-c","excel","pandas","angularjs","regex","typescript","ruby","linux","ajax","iphone","vba","xml","laravel","spring","asp.net-mvc","database","wordpress","string","flutter","postgresql","mongodb","wpf","windows","amazon-web-services","xcode","bash","git","oracle-database","spring-boot","dataframe","azure","firebase","list","multithreading","docker","vb.net","react-native","eclipse","algorithm","powershell","macos","visual-studio","numpy","image","forms","scala","function","vue.js","performance","twitter-bootstrap","selenium","winforms","kotlin","loops","express","dart","hibernate","sqlite","matlab","python-2.7","shell","rest","apache","entity-framework","android-studio","csv","api","maven","linq","qt","dictionary","unit-testing","facebook","asp.net-core","tensorflow","apache-spark","file","swing","class","unity-game-engine","sorting","date","authentication","go","symfony","opencv","t-sql","matplotlib",".htaccess","google-chrome","for-loop","datetime","codeigniter","http","perl","validation","sockets","google-maps","object","uitableview","xaml","oop","if-statement","visual-studio-code","cordova","ubuntu","web-services","email","android-layout","github","elasticsearch","spring-mvc","kubernetes","selenium-webdriver","ms-access","user-interface","parsing","ggplot2","pointers","machine-learning","c++11","google-sheets","security","flask","google-apps-script","ruby-on-rails-3","nginx","templates","variables","exception","sql-server-2008","gradle","debugging","tkinter","listview","delphi","jpa","asynchronous","pdf","web-scraping","haskell","jsp","ssl","amazon-s3","google-cloud-platform","jenkins","testing","xamarin","wcf","npm","batch-file","generics","ionic-framework","network-programming","unix","recursion","google-app-engine","mongoose","visual-studio-2010",".net-core","android-fragments","assembly","animation","math","next.js","session","svg","hadoop","intellij-idea","curl","django-models","join","laravel-5","winapi","rust","url","heroku","http-redirect","tomcat","google-cloud-firestore","inheritance","webpack","keras","image-processing","asp.net-mvc-4","gcc","web","logging","dom","swiftui","matrix","pyspark","actionscript-3","button","post","optimization","firebase-realtime-database","jquery-ui","cocoa","iis","xpath","d3.js","firefox","javafx","internet-explorer","xslt","caching","select","asp.net-mvc-3","opengl","events","asp.net-web-api","plot","dplyr","magento","encryption","search","stored-procedures","amazon-ec2","ruby-on-rails-4","memory","audio","canvas","multidimensional-array","jsf","random","cookies","vector","redux","facebook-graph-api","input","flash","xamarin.forms","indexing","arraylist","ipad","cocoa-touch","data-structures","video","apache-kafka","model-view-controller","serialization","jdbc","woocommerce","routes","razor","awk","azure-devops","servlets","mod-rewrite","beautifulsoup","docker-compose","iframe","filter","excel-formula","aws-lambda","design-patterns","text","django-rest-framework","visual-c++","cakephp","mobile","android-intent","react-hooks","struct","methods","groovy","mvvm","ssh","lambda","checkbox","google-chrome-extension","ecmascript-6","time","grails","installation","sharepoint","cmake","shiny","spring-security","jakarta-ee","android-recyclerview","plsql","core-data","types","meteor","android-activity","sed","bootstrap-4","websocket","activerecord","graph","replace","scikit-learn","file-upload","group-by","vim","junit","deep-learning","boost","import","sass","memory-management","error-handling","async-await","eloquent","dynamic","soap","silverlight","dependency-injection","charts","layout","apache-spark-sql","deployment","browser","gridview","svn","while-loop","google-bigquery","vuejs2","ffmpeg","dll","highcharts","view","foreach","plugins","c#-4.0","makefile","redis","reporting-services","jupyter-notebook","server","merge","https","unicode","reflection","google-maps-api-3","twitter","oauth-2.0","extjs","axios","pytorch","terminal","pip","split","mysqli","cmd","django-views","encoding","automation","netbeans","database-design","collections","hash","data-binding","ember.js","build","tcp","sqlalchemy","pdo","apache-flex","concurrency","command-line","entity-framework-core","spring-data-jpa","printing","java-8","react-redux","jestjs","service","html-table","neo4j","ansible","lua","parameters","module","material-ui","visual-studio-2012","enums","promise","flexbox","outlook","webview","firebase-authentication","web-applications","uwp","jquery-mobile","utf-8","datatable","python-requests","parallel-processing","drop-down-menu","colors","scroll","hive","tfs","scipy","count","syntax","ms-word","twitter-bootstrap-3","ssis","google-analytics","three.js","fonts","constructor","graphql","powerbi","rxjs","file-io","paypal","discord","cassandra","socket.io","graphics","compiler-errors","gwt","react-router","nlp","solr","backbone.js","url-rewriting","datatables","memory-leaks","oauth","datagridview","terraform","drupal","oracle11g","zend-framework","neural-network","knockout.js","triggers","django-forms","interface","google-api","angular-material","casting","jmeter","linked-list","path","proxy","timer","django-templates","arduino","orm","directory","parse-platform","visual-studio-2015","windows-phone-7","cron","push-notification","conditional-statements","primefaces","functional-programming","pagination","model","jar","xamarin.android","hyperlink","uiview","visual-studio-2013","gitlab","vbscript","google-cloud-functions","azure-active-directory","jwt","download","swift3","sql-server-2005","process","configuration","rspec","properties","pygame","combobox","callback","windows-phone-8","safari","linux-kernel","permissions","scrapy","raspberry-pi","scripting","emacs","clojure","scope","io","x86","compilation","mongodb-query","responsive-design","nhibernate","angularjs-directive","request","expo","bluetooth","3d","dns","azure-functions","binding","reference","discord.js","architecture","playframework","pyqt","version-control","doctrine-orm","package","pycharm","get","sql-server-2012","rubygems","f#","autocomplete","datepicker","openssl","kendo-ui","tree","controller","jackson","yii","nested","grep","xamarin.ios","static","statistics","dockerfile","transactions","null","datagrid","active-directory","uiviewcontroller","phpmyadmin","webforms","discord.py","notifications","computer-vision","sas","duplicates","mocking","youtube","nullpointerexception","yaml","menu","sum","bitmap","electron","asp.net-mvc-5","visual-studio-2008","time-series","yii2","jsf-2","android-listview","css-selectors","stl","blazor","floating-point","cryptography","ant","stream","hashmap","character-encoding","msbuild","sdk","asp.net-core-mvc","google-drive-api","selenium-chromedriver","jboss","joomla","navigation","cors","devise","anaconda","frontend","background","camera","pyqt5","multiprocessing","binary","cuda","linq-to-sql","iterator","mariadb","onclick","ios7","plotly","rabbitmq","android-asynctask","android-jetpack-compose","microsoft-graph-api","tabs","laravel-4","insert","amazon-dynamodb","uicollectionview","environment-variables","linker","console","xsd","coldfusion","upload","continuous-integration","ftp","textview","opengl-es","operating-system","mockito","localization","vuejs3","xml-parsing","macros","formatting","json.net","kivy","type-conversion","data.table","timestamp","calendar","integer","segmentation-fault","android-ndk","drag-and-drop","prolog","char","crash","jasmine","automated-tests","dependencies","geometry","android-gradle-plugin","itext","firebase-cloud-messaging","header","sprite-kit","mfc","fortran","attributes","nosql","nuxt.js","format","nestjs","azure-pipelines","odoo","jquery-plugins","db2","leaflet","jenkins-pipeline","event-handling","postman","flutter-layout","annotations","julia","keyboard","textbox","arm","visual-studio-2017","gulp","libgdx","stripe-payments","xampp","synchronization","crystal-reports","azure-web-app-service","timezone","dom-events","android-emulator","swagger","uikit","sequelize.js","wso2","aggregation-framework","namespaces","uiscrollview","jvm","chart.js","google-sheets-formula","com","subprocess","geolocation","centos","webdriver","html5-canvas","widget","dialog","garbage-collection","numbers","concatenation","snowflake-cloud-data-platform","sql-update","qml","windows-10","set","mapreduce","smtp","tuples","ionic2","java-stream","rotation","modal-dialog","android-edittext","spring-data","http-headers","nuget","doctrine","radio-button","grid","sonarqube","lucene","xmlhttprequest","internationalization","listbox","components","initialization","switch-statement","google-play","boolean","apache-camel","serial-port","ldap","ios5","youtube-api","return","gdb","pivot","latex","eclipse-plugin","frameworks","tags","containers","dataset","github-actions","asp-classic","foreign-keys","subquery","label","copy","uinavigationcontroller","google-cloud-storage","delegates","c++17","struts2","migration","base64","protractor","sql-server-2008-r2","queue","find","uibutton","embedded","arguments","composer-php","append","jaxb","zip","stack","cucumber","autolayout","ide","entity-framework-6","popup","iteration","windows-7","airflow","r-markdown","ssl-certificate","vb6","gmail","hover","jqgrid","g++","udp","tailwind-css"],"TriggerEvent":"homepageWizardShow","OauthInPopup":true,"ReturnUrl":"https://stackoverflow.com","ReturnUrlForPopup":"https://stackoverflow.com/users/after-signup/oauth-only","ThemePreferenceFlags":0}</script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=f1f216c36f5e"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/2784.en.js?v=414ac3934ec2"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/8901.en.js?v=9ff34567d3a5"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/6719.en.js?v=5cd743a95ced"></script><script defer src="https://cdn.sstatic.net/Js/islands/homepage-wizard.en.js?v=7eef21a5b01c"></script> <div id="left-sidebar" data-is-here-when="md lg" class="left-sidebar js-pinned-left-sidebar ps-relative"> <div class="left-sidebar--sticky-container js-sticky-leftnav"> <nav aria-label="Primary"> <ol class="nav-links"> <li> <ol class="nav-links"> <li class="ps-relative" aria-current="false"> <a href="/" class="s-block-link pl8 js-homepage-wizard-link js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:8, has_activity_notification:False});home_nav.click({location:2})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconHome" width="18" height="18" viewBox="0 0 18 18"><path d="M15 10v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5H0l9-9 9 9zm-8 1v6h4v-6z"/></svg> <span class="-link--channel-name pl6">Home</span> </div> </a> </li> <li class="ps-relative youarehere" aria-current="true"> <a id="nav-questions" href="/questions" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: true, location:2, destination:1, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconQuestion" width="18" height="18" viewBox="0 0 18 18"><path d="m4 15-3 3V4c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v9c0 1.09-.91 2-2 2zm7.75-3.97c.72-.83.98-1.86.98-2.94 0-1.65-.7-3.22-2.3-3.83a4.4 4.4 0 0 0-3.02 0 3.8 3.8 0 0 0-2.32 3.83q0 1.93 1.03 3a3.8 3.8 0 0 0 2.85 1.07q.94 0 1.71-.34.97.66 1.06.7.34.2.7.3l.59-1.13a5 5 0 0 1-1.28-.66m-1.27-.9a5 5 0 0 0-1.5-.8l-.45.9q.5.18.98.5-.3.1-.65.11-.92 0-1.52-.68c-.86-1-.86-3.12 0-4.11.8-.9 2.35-.9 3.15 0 .9 1.01.86 3.03-.01 4.08"/></svg> <span class="-link--channel-name pl6">Questions</span> </div> </a> </li> <li class="ps-relative" aria-current="false"> <a href="/tags" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:2, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconTags" width="18" height="18" viewBox="0 0 18 18"><path d="M9.24 1a3 3 0 0 0-2.12.88l-5.7 5.7a2 2 0 0 0-.38 2.31 3 3 0 0 1 .67-1.01l6-6A3 3 0 0 1 9.83 2H14a3 3 0 0 1 .79.1A2 2 0 0 0 13 1z" opacity=".4"/><path d="M9.83 3a2 2 0 0 0-1.42.59l-6 6a2 2 0 0 0 0 2.82L6.6 16.6a2 2 0 0 0 2.82 0l6-6A2 2 0 0 0 16 9.17V5a2 2 0 0 0-2-2zM12 9a2 2 0 1 1 0-4 2 2 0 0 1 0 4"/></svg> <span class="-link--channel-name pl6">Tags</span> </div> </a> </li> <li class="pb24"></li> <li class="ps-relative" aria-current="false"> <a id="nav-users" href="/users" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:3, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconPeople" width="18" height="18" viewBox="0 0 18 18"><path d="M17 14c0 .44-.45 1-1 1H9a1 1 0 0 1-1-1H2c-.54 0-1-.56-1-1 0-2.63 3-4 3-4s.23-.4 0-1c-.84-.62-1.06-.59-1-3s1.37-3 2.5-3 2.44.58 2.5 3-.16 2.38-1 3c-.23.59 0 1 0 1s1.55.71 2.42 2.09c.78-.72 1.58-1.1 1.58-1.1s.23-.4 0-1c-.84-.61-1.06-.58-1-3s1.37-3 2.5-3 2.44.59 2.5 3c.05 2.42-.16 2.39-1 3-.23.6 0 1 0 1s3 1.38 3 4"/></svg> <span class="-link--channel-name pl6">Users</span> </div> </a> </li> <li class="ps-relative" aria-current="false"> <a id="nav-companies" href="https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:12, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconIndustry" width="18" height="18" viewBox="0 0 18 18"><path d="M10 16v-4H8v4H2V4c0-1.1.9-2 2-2h6c1.09 0 2 .91 2 2v2h2c1.09 0 2 .91 2 2v8zM4 4v2h2V4zm0 4v2h2V8zm4-4v2h2V4zm0 4v2h2V8zm-4 4v2h2v-2zm8 0v2h2v-2zm0-4v2h2V8z"/></svg> <span class="-link--channel-name pl6">Companies</span> </div> </a> </li> <li class="ml8 mt32 mb8"> <a href="javascript:void(0)" class="s-link s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine" role="button" aria-controls="popover-labs-left-nav" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="top" data-s-popover-toggle-class="is-selected" > <div class="flex--item fl-grow1 tt-uppercase fc-black-600 fw-bold">Labs</div> <div class="flex--item px12"> <svg aria-hidden="true" class="svg-icon iconInfoSm" width="14" height="14" viewBox="0 0 14 14"><path d="M7 1a6 6 0 1 1 0 12A6 6 0 0 1 7 1m1 10V6H6v5zm0-6V3H6v2z"/></svg> </div> </a> </li> <li class="ps-relative" aria-current="false"> <a id="nav-labs-discussions" href="/beta/discussions" class="s-block-link pl8 ai-center js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:24, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="w16 svg-icon iconMessage" width="18" height="18" viewBox="0 0 18 18"><path d="M5 7a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1m1 2a1 1 0 1 0 0 2h4a1 1 0 1 0 0-2zm-5 9V4c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v9c0 1.09-.91 2-2 2H4.5zm2.76-5h11.23v-.01H15V4H3v9.65z"/></svg> <span class="-link--channel-name pl6">Discussions</span> </div> </a> </li> <li class="ml8 mt32 mb4"> <div class="d-flex jc-space-between ai-center"> <a class="s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine" href="javascript:void(0)" role="button" aria-controls="popover-discover-collectives" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="top" data-s-popover-toggle-class="is-selected" data-gps-track="top_nav.click({is_current:false, location:2, destination:17})" > <div class="flex--item fl-grow1 tt-uppercase fc-black-600 fw-bold">Collectives</div> <div class="flex--item px12 js-collectives-navcta-toggle"> <svg aria-hidden="true" class="svg-icon iconPlusSm" width="14" height="14" viewBox="0 0 14 14"><path d="M8 2H6v4H2v2h4v4h2V8h4V6H8z"/></svg> </div> </a> </div> </li> <li class="ps-relative js-collectives-navcta-toggle"> <p class="fs-fine pr8 pl8 pt4 fc-black-400"> Communities for your favorite technologies. <a href="/collectives-all" class="s-link s-link__grayscale s-link__underlined fw-bold">Explore all Collectives</a> </p> </li> </ol> </li> <li class="js-freemium-cta ps-relative mt32 mb8"> <div class="fs-fine tt-uppercase fc-black-600 fw-bold ml8 mt16 mb8">Teams</div> <div class="px12 pt12 pb4 mb12 fc-medium overflow-hidden"> <img class="wmx100 mx-auto mb12 h-auto d-block" width="151" height="24" src="https://cdn.sstatic.net/Img/teams/teams-promo.svg?v=e507948b81bf" alt=""> <p class="fs-fine"> Ask questions, find answers and collaborate at work with Stack Overflow for Teams. </p> <a href="https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams" class="w100 s-btn s-btn__filled s-btn__xs bg-orange-400 h:bg-orange-500 js-gps-track pt8 pr7 pb6 pl7" data-gps-track="teams.create.left-sidenav.click({ Action: 6 })" data-ga="["teams left navigation - anonymous","left nav free cta","stackoverflow.com/teams/create/free",null,null]">Try Teams for free</a> <a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams" class="w100 s-btn s-btn__muted s-btn__xs mt1 js-gps-track" data-gps-track="teams.create.left-sidenav.click({ Action: 5 })" data-ga="["teams left navigation - anonymous","left nav free cta","stackoverflow.com/teams",null,null]">Explore Teams</a> </div> </li> <li class="d-flex ai-center jc-space-between ml8 mt32 mb8 js-create-team-cta d-none"> <a href="javascript:void(0)" class="s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine js-gps-track" role="button" aria-controls="popover-teams-create-cta" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="bottom-start" data-s-popover-toggle-class="is-selected" data-gps-track="teams.create.left-sidenav.click({ Action: ShowInfo })" data-ga="["teams left navigation - anonymous","left nav show teams info",null,null,null]" > <div class="flex--item fl-grow1 fc-black-600 fw-bold tt-uppercase">Teams</div> <div class="flex--item px12"> <svg aria-hidden="true" class="svg-icon iconPlusSm" width="14" height="14" viewBox="0 0 14 14"><path d="M8 2H6v4H2v2h4v4h2V8h4V6H8z"/></svg> </div> </a> </li> <li class="ps-relative js-create-team-cta d-none"> <p class="fs-fine pr8 pl8 pb4 fc-black-400"> Ask questions, find answers and collaborate at work with Stack Overflow for Teams. <a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact" class="s-link s-link__grayscale s-link__underlined fw-bold">Explore Teams</a> </p> </li> </ol> </nav> </div> <div class="s-popover ws2" id="popover-discover-collectives" role="menu"> <div class="s-popover--arrow"></div> <div> <svg aria-hidden="true" class="fc-orange-400 float-right ml24 svg-spot spotCollective" width="48" height="48" viewBox="0 0 48 48"><path d="M25.5 7a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5M14 18.25c0-.69.56-1.25 1.25-1.25h22.5c.69 0 1.25.56 1.25 1.25V37.5a1 1 0 0 1-1.6.8l-4.07-3.05a1.3 1.3 0 0 0-.75-.25H15.25c-.69 0-1.25-.56-1.25-1.25zM7 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M25.5 48a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5M48 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0" opacity=".2"/><path d="M21 3.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0M24.5 2a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M0 23.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0M3.5 22a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M21 44.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0m3.5-1.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m20-23a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7M43 23.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0m-23.23-3.14a1 1 0 0 1-.13 1.4l-2.08 1.74 2.08 1.73a1 1 0 1 1-1.28 1.54l-2.42-2.02a1.63 1.63 0 0 1 0-2.5l2.42-2.02a1 1 0 0 1 1.4.13m7.6 1.41a1 1 0 1 1 1.28-1.54l2.42 2.02c.78.65.78 1.85 0 2.5l-2.42 2.02a1 1 0 1 1-1.28-1.54l2.08-1.73zM24.12 18a1 1 0 0 1 .87 1.12l-1 8a1 1 0 1 1-1.98-.24l1-8a1 1 0 0 1 1.11-.87M12.25 13C11.01 13 10 14 10 15.25v15.5c0 1.24 1 2.25 2.25 2.25h17.33q.09 0 .15.05l4.07 3.05a2 2 0 0 0 3.2-1.6V15.25c0-1.24-1-2.25-2.25-2.25zM12 15.25q.02-.23.25-.25h22.5q.23.02.25.25V34.5l-4.07-3.05q-.6-.45-1.35-.45H12.25a.25.25 0 0 1-.25-.25zm7.24-10.68a1 1 0 1 0-.48-1.94A22 22 0 0 0 2.91 17.7a1 1 0 1 0 1.92.58 20 20 0 0 1 14.4-13.72m11.06-1.65a1 1 0 0 0-.58 1.92c6.45 1.92 11.54 7 13.46 13.46a1 1 0 1 0 1.92-.58 22 22 0 0 0-14.8-14.8M4.57 28.76a1 1 0 0 0-1.94.48 22 22 0 0 0 16.13 16.13 1 1 0 1 0 .48-1.94A20 20 0 0 1 4.57 28.76m40.8.48a1 1 0 1 0-1.94-.48 20 20 0 0 1-13.72 14.41 1 1 0 0 0 .58 1.92 22 22 0 0 0 15.08-15.85"/></svg> <h5 class="pt4 fw-bold">Collectives™ on Stack Overflow</h5> <p class="my16 fs-caption fc-black-500">Find centralized, trusted content and collaborate around the technologies you use most.</p> <a href="/collectives" class="js-gps-track s-btn s-btn__filled s-btn__xs" data-gps-track="top_nav.click({is_current:false, location:2, destination:18})"> Learn more about Collectives </a> </div> </div> <div class="s-popover ws2" id="popover-teams-create-cta" role="menu" aria-hidden="true"> <div class="s-popover--arrow"></div> <div class="ps-relative overflow-hidden"> <p class="mb2"><strong>Teams</strong></p> <p class="mb12 fs-caption fc-black-400">Q&A for work</p> <p class="mb12 fs-caption fc-black-500">Connect and share knowledge within a single location that is structured and easy to search.</p> <a href="https://stackoverflow.co/teams/" class="js-gps-track s-btn s-btn__filled s-btn__xs" data-gps-track="teams.create.left-sidenav.click({ Action: CtaClick })" data-ga="["teams left navigation - anonymous","left nav cta","stackoverflow.com/teams",null,null]"> Learn more about Teams </a> </div> <div class="ps-absolute t8 r8"> <svg aria-hidden="true" class="fc-orange-400 svg-spot spotPeople" width="48" height="48" viewBox="0 0 48 48"><path d="M13.5 28a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9M7 30a1 1 0 0 1 1-1h11a1 1 0 0 1 1 1v5h11v-5a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v10a2 2 0 0 1-2 2H33v5a1 1 0 0 1-1 1H20a1 1 0 0 1-1-1v-5H8a1 1 0 0 1-1-1zm25-6.5a4.5 4.5 0 1 0 9 0 4.5 4.5 0 0 0-9 0M24.5 34a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9" opacity=".2"/><path d="M16.4 26.08A6 6 0 1 0 7.53 26C5.64 26.06 4 27.52 4 29.45V40a1 1 0 0 0 1 1h9a1 1 0 1 0 0-2h-4v-7a1 1 0 1 0-2 0v7H6v-9.55c0-.73.67-1.45 1.64-1.45H16a1 1 0 0 0 .4-1.92M12 18a4 4 0 1 1 0 8 4 4 0 0 1 0-8m16.47 14a6 6 0 1 0-8.94 0A3.6 3.6 0 0 0 16 35.5V46a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V35.5c0-1.94-1.64-3.42-3.53-3.5M20 28a4 4 0 1 1 8 0 4 4 0 0 1-8 0m-.3 6h8.6c1 0 1.7.75 1.7 1.5V45h-2v-7a1 1 0 1 0-2 0v7h-4v-7a1 1 0 1 0-2 0v7h-2v-9.5c0-.75.7-1.5 1.7-1.5M42 22c0 1.54-.58 2.94-1.53 4A3.5 3.5 0 0 1 44 29.45V40a1 1 0 0 1-1 1h-9a1 1 0 1 1 0-2h4v-7a1 1 0 1 1 2 0v7h2v-9.55A1.5 1.5 0 0 0 40.48 28H32a1 1 0 0 1-.4-1.92A6 6 0 1 1 42 22m-2 0a4 4 0 1 0-8 0 4 4 0 0 0 8 0"/><g opacity=".35"><path d="M17 10a1 1 0 011-1h12a1 1 0 110 2H18a1 1 0 01-1-1m1-5a1 1 0 100 2h12a1 1 0 100-2zM14 1a1 1 0 00-1 1v12a1 1 0 001 1h5.09l4.2 4.2a1 1 0 001.46-.04l3.7-4.16H34a1 1 0 001-1V2a1 1 0 00-1-1zm1 12V3h18v10h-5a1 1 0 00-.75.34l-3.3 3.7-3.74-3.75a1 1 0 00-.71-.29z"/></g></svg> </div> </div> <div class="s-popover ws2" id="popover-labs-left-nav" role="menu" aria-hidden="true"> <div class="s-popover--arrow"></div> <svg aria-hidden="true" class="fc-black-600 mb8 svg-icon iconLabsAltSm" width="42" height="18" viewBox="0 0 42 18"><path fill="var(--black-600)" d="M11.5 13.62c0 .21-.17.38-.37.38H5.36a.37.37 0 0 1-.37-.38V4.38c0-.21.17-.38.37-.38h1.26c.2 0 .37.17.37.38v7.6h4.14c.2 0 .37.18.37.38zm9.43.22a.4.4 0 0 1-.3.16h-1.5q-.25-.01-.36-.25l-.55-1.7h-3.1l-.56 1.7a.4.4 0 0 1-.35.25h-1.5a.38.38 0 0 1-.35-.5l3.39-9.25c.05-.15.2-.25.35-.25h1.13q.26.01.36.25l3.39 9.24q.06.19-.05.35m-4.16-7.39-1.21 3.53h2.26zm13.34 5.71a.37.37 0 0 0 0 .53A4.5 4.5 0 0 0 33.59 14c1.02 0 1.92-.27 2.58-.79a2.8 2.8 0 0 0 1.07-2.25c0-.86-.27-1.62-.87-2.15-.46-.4-1-.63-1.89-.76l-1.04-.16a2 2 0 0 1-.83-.33q-.22-.19-.22-.57 0-.46.3-.73c.2-.18.53-.32 1-.32.7 0 1.25.15 1.72.6.14.14.37.14.52 0l.88-.87a.37.37 0 0 0-.01-.53A4.2 4.2 0 0 0 33.72 4c-1.01 0-1.87.3-2.48.84a3 3 0 0 0-.93 2.2q-.02 1.24.78 2.01.72.66 1.93.83l1.07.15c.5.07.65.15.8.29q.23.2.24.67-.01.5-.35.73-.34.29-1.16.3c-.87 0-1.49-.19-2.07-.76a.37.37 0 0 0-.52 0zM22.37 14a.37.37 0 0 1-.37-.38V4.38c0-.21.17-.38.37-.38h3.54q1.4 0 2.26.78c.56.52.86 1.26.86 2.13 0 .84-.37 1.52-.87 1.95A2.6 2.6 0 0 1 29.17 11q0 1.42-.9 2.23c-.56.51-1.34.76-2.22.76zm3.54-1.98c.96 0 .96-1 .96-1s0-1.02-.96-1.02H24v2.02zm-.11-4.06c1.07 0 1.07-1.02 1.07-1.02s0-1.01-1.07-1.01H24v2.03zM0 4v10a4 4 0 0 0 4 4h34a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4H4a4 4 0 0 0-4 4m4-2h34a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4c0-1.1.9-2 2-2"/></svg> <p class="fs-caption">Get early access and see previews of new features.</p> <a class="s-btn s-btn__filled s-btn__xs s-btn__icon fs-fine" href="https://stackoverflow.co/labs/"><svg aria-hidden="true" class="svg-icon iconShareSm" width="14" height="14" viewBox="0 0 14 14"><path d="M5 1H3a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V9h-2v2H3V3h2zm2 0h6v6h-2V4.5L6.5 9 5 7.5 9.5 3H7z"/></svg> Learn more about Labs</a> </div> </div> <div id="content" class="snippet-hidden"> <div id="redirect-action-modal-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/redirect-action-modal/index.mod">{"ContainerElementId":"redirect-action-modal-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","HeaderImageUrl":"https://cdn.sstatic.net/Img/modal/img-upvote.png?v=fce73bd9724d"}</script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=f1f216c36f5e"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/islands/redirect-action-modal.en.js?v=4fb6b33d576c"></script><div itemprop="mainEntity" itemscope itemtype="https://schema.org/Question"> <link itemprop="image" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> <div class="inner-content clearfix"> <div id="question-header" class="d-flex sm:fd-column"> <h1 itemprop="name" class="fs-headline1 ow-break-word mb8 flex--item fl1"><a href="/questions/1669/learning-to-write-a-compiler" class="question-hyperlink">Learning to write a compiler [closed]</a></h1> <div class="ml12 aside-cta flex--item sm:ml0 sm:mb12 sm:order-first d-flex jc-end"> <div class="ml12 aside-cta flex--item print:d-none"> <a href="/questions/ask" class="ws-nowrap s-btn s-btn__filled"> Ask Question </a> </div> </div> </div> <div class="d-flex fw-wrap pb8 mb16 bb bc-black-200"> <div class="flex--item ws-nowrap mr16 mb8" title="2008-08-04 22:46:36Z"> <span class="fc-black-400 mr2">Asked</span> <time itemprop="dateCreated" datetime="2008-08-04T22:46:36">16 years, 6 months ago</time> </div> <div class="flex--item ws-nowrap mr16 mb8"> <span class="fc-black-400 mr2">Modified</span> <a href="?lastactivity" class="s-link s-link__inherit" title="2024-07-11 16:58:04Z">7 months ago</a> </div> <div class="flex--item ws-nowrap mb8" title="Viewed 366,094 times"> <span class="fc-black-400 mr2">Viewed</span> 366k times </div> </div> <div id="mainbar" role="main" aria-label="question and answers"> <div class="question js-question" data-questionid="1669" data-position-on-page="0" data-score="697" id="question"> <style> </style> <div class="js-zone-container zone-container-main"> <div id="dfp-tlb" class="everyonelovesstackoverflow everyoneloves__top-leaderboard everyoneloves__leaderboard"></div> <div class="js-report-ad-button-container " style="width: 728px"></div> </div> <div class="post-layout "> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1669" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1669" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This question shows research effort; it is useful and clear" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:17c7ac105e1aca8d,10:1740274359,16:e69af18fd52d32f2,4:1669,37101038adbdc3381747805c89191ab300bbee59e11277de28b28043b9ac2c96" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="697"> 697 </div> <button class="js-vote-down-btn js-vote-down-question flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This question does not show any research effort; it is unclear or not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:8759ff9f93aef181,10:1740274359,16:efa0d6bb722aef30,4:1669,9b302c2f1c0368da6d6f1e37d7d92144ebf532969388fc22a98ceaa8221998ce" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1669" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this question." data-is-saved="false" aria-label="Save" data-post-id="1669" data-post-type-id="1" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1669/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <div> <aside class="s-notice s-notice__info post-notice js-post-notice mb16" role="status"> <div class="d-flex fd-column fw-nowrap"> <div class="d-flex fw-nowrap"> <div class="flex--item wmn0 fl1 lh-lg"> <div class="flex--item fl1 lh-lg"> <div> <b>Closed.</b> This question does not meet <a href="/help/closed-questions">Stack Overflow guidelines</a>. It is not currently accepting answers. </div> </div> </div> </div> </div> <hr class="my12 outline-none baw0 bb bc-blue-400" /> <div class="fw-nowrap fc-black-500"> <div class="d-flex fd-column lh-md"> <div class="mb0 d-flex"> <div class="flex--item mr8"> <svg aria-hidden="true" class="svg-icon iconLightbulb" width="18" height="18" viewBox="0 0 18 18"><path d="M15 6.38A6.5 6.5 0 0 0 7.78.04h-.02A6.5 6.5 0 0 0 2.05 5.6a6.3 6.3 0 0 0 2.39 5.75c.49.39.76.93.76 1.5v.24c0 1.07.89 1.9 1.92 1.9h2.75c1.04 0 1.92-.83 1.92-1.9v-.2c0-.6.26-1.15.7-1.48A6.3 6.3 0 0 0 15 6.37M4.03 5.85A4.5 4.5 0 0 1 8 2.02a4.5 4.5 0 0 1 5 4.36 4.3 4.3 0 0 1-1.72 3.44c-.98.74-1.5 1.9-1.5 3.08v.1H7.2v-.14c0-1.23-.6-2.34-1.53-3.07a4.3 4.3 0 0 1-1.64-3.94M10 18a1 1 0 0 0 0-2H7a1 1 0 1 0 0 2z"/></svg> </div> <p> Questions asking us to <b>recommend or find a tool, library or favorite off-site resource</b> are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, <a href="http://meta.stackoverflow.com/q/254394/">describe the problem</a> and what has been done so far to solve it.</p> </div> <div class="mb0 mt6 d-flex"> <p class="ml24 pl2">Closed <span title='2014-06-26 12:41:32Z' class='relativetime'>10 years ago</span>.</p> </div> <div class="ml24 pl2"> </div> </div> </div> </aside> <aside class="s-notice s-notice__info post-notice js-post-notice mb16" role="status"> <div class="d-flex fd-column fw-nowrap"> <div class="d-flex fw-nowrap"> <div class="flex--item mr8"> <svg aria-hidden="true" class="svg-icon iconLock" width="18" height="18" viewBox="0 0 18 18"><path d="M16 9a2 2 0 0 0-2-2V6A5 5 0 0 0 4 6v1a2 2 0 0 0-2 2v6c0 1.1.9 2 2 2h10a2 2 0 0 0 2-2zm-7 5a2 2 0 1 1 0-4 2 2 0 0 1 0 4m3.1-7H5.9V6a3.1 3.1 0 0 1 6.2 0z"/></svg> </div> <div class="flex--item wmn0 fl1 lh-lg"> <div class="flex--item fl1 lh-lg"> <div> <b>This question's answers are a <a href="/help/privileges/edit-community-wiki">community effort</a></b>. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. </div> </div> </div> </div> </div> </aside> </div> <p><em>Preferred languages</em>: C/C++, Java, and Ruby.</p> <p>I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and Ruby, so I prefer resources that involve one of those three, but any good resource is acceptable.</p> </div> <div class="mt24 mb12"> <div class="post-taglist d-flex gs4 gsy fd-column"> <div class="d-flex ps-relative fw-wrap"> <ul class='ml0 list-ls-none js-post-tag-list-wrapper d-inline'><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/compiler-construction" class="s-tag post-tag" title="show questions tagged 'compiler-construction'" aria-label="show questions tagged 'compiler-construction'" rel="tag" aria-labelledby="tag-compiler-construction-tooltip-container" data-tag-menu-origin="Unknown">compiler-construction</a></li><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/language-agnostic" class="s-tag post-tag" title="show questions tagged 'language-agnostic'" aria-label="show questions tagged 'language-agnostic'" rel="tag" aria-labelledby="tag-language-agnostic-tooltip-container" data-tag-menu-origin="Unknown">language-agnostic</a></li></ul> </div> </div> </div> <div class="mb0 "> <div class="mt16 d-flex gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="flex--item mr16 fl1 w96"> <div class="js-post-menu pt2" data-post-id="1669" data-post-type-id="1"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/q/1669" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this question" data-gps-track="post.click({ item: 2, priv: 0, post_type: 1 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this question" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="question" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="1" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1669" class="s-btn s-btn__link js-follow-post js-follow-question js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 1 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this question to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:a42d82e23f389e83,10:1740274359,16:5b86b4174669690b,4:1669,c9682a469a792ad68466b13dd81c5c0b08f012409bec6e06cc10744523ba741b" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1669/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 1 })">edited <span title='2014-02-28 23:45:33Z' class='relativetime'>Feb 28, 2014 at 23:45</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1669" href="/posts/1669/revisions" title="show revision history for this post"> 20 revs, 10 users 47%<br><a href="/users/340">Anton</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">4</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1669" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1669" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="false" data-comments-unavailable="true" data-addlink-disabled="true"> <li id="comment-4900726" class="comment js-comment " data-comment-id="4900726" data-comment-owner-id="293821" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">ANTLR all the way. All the resources proposed below looks like an overkill to me. ANTLR is always a compiler designer best friend. A</span> <div class="d-inline-flex ai-center"> – <a href="/users/293821/a-var" title="1,036 reputation" class="comment-user">A_Var</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2010-12-19 04:25:15Z, License: CC BY-SA 2.5' class='relativetime-clean'>Dec 19, 2010 at 4:25</span> </span> <span title="this comment was edited 1 time"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> <li id="comment-6660552" class="comment js-comment " data-comment-id="6660552" data-comment-owner-id="452102" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">If your main focus is to learn how compiling ideas work in general - you can check and SICP short for Structured Interpretation of Computer program based in Scheme ( List) but teaches the general principles . <a href="http://mitpress.mit.edu/sicp/" rel="nofollow noreferrer">mitpress.mit.edu/sicp</a> . I was recommended this book by a veteran who works for a company and does these works compilation and interpretation for a living !</span> <div class="d-inline-flex ai-center"> – <a href="/users/452102/nishant" title="21,914 reputation" class="comment-user">Nishant</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2011-04-27 15:32:25Z, License: CC BY-SA 3.0' class='relativetime-clean'>Apr 27, 2011 at 15:32</span> </span> <span title="this comment was edited 2 times"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> <li id="comment-33537635" class="comment js-comment " data-comment-id="33537635" data-comment-owner-id="223424" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">A shameless plug: <a href="http://programmers.stackexchange.com/a/165558/11732">my answer on a similar question</a>.</span> <div class="d-inline-flex ai-center"> – <a href="/users/223424/9000" title="40,894 reputation" class="comment-user">9000</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2014-03-01 00:21:05Z, License: CC BY-SA 3.0' class='relativetime-clean'>Mar 1, 2014 at 0:21</span> </span> </div> </div> </li> <li id="comment-33826682" class="comment js-comment " data-comment-id="33826682" data-comment-owner-id="242278" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I wrote an article on creating a compiler on my blog: <a href="http://orangejuiceliberationfront.com/how-to-write-a-compiler/" rel="nofollow noreferrer">orangejuiceliberationfront.com/how-to-write-a-compiler</a> It focuses on the very basics and getting started, really. There's a bunch more compiler/codegen/parser/language design-related articles on there.</span> <div class="d-inline-flex ai-center"> – <a href="/users/242278/uliwitness" title="8,843 reputation" class="comment-user">uliwitness</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2014-03-08 12:33:30Z, License: CC BY-SA 3.0' class='relativetime-clean'>Mar 8, 2014 at 12:33</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1669" data-rep=50 data-anon=true> <span class="disabled-link">Comments disabled on deleted / locked posts / reviews</span> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> <script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=f1f216c36f5e"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/2784.en.js?v=414ac3934ec2"></script><script defer src="https://cdn.sstatic.net/Js/islands/comment-popover.en.js?v=3f9e19615dd5"></script> </div> </div> <div class="js-zone-container zone-container-responsive"> <div id="dfp-isb" class="everyonelovesstackoverflow everyoneloves__inline-sidebar mx-auto"></div> <div class="js-report-ad-button-container mx-auto" style="width: 300px"></div> </div> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="answers-subheader d-flex ai-center mb8"> <div class="flex--item fl1"> <h2 class="mb0" data-answercount="38"> 38 Answers <span style="display:none;" itemprop="answerCount">38</span> </h2> </div> <div class="flex--item"> <div class="d-flex g4 gsx ai-center sm:fd-column sm:ai-start"> <div class="d-flex fd-column ai-end sm:ai-start"> <label class="flex--item fs-caption" for="answer-sort-dropdown-select-menu"> Sorted by: </label> <a class="js-sort-preference-change s-link flex--item fs-fine d-none" data-value="ScoreDesc" href="/questions/1669/learning-to-write-a-compiler?answertab=scoredesc#tab-top" > Reset to default </a> </div> <div class="flex--item s-select"> <select id="answer-sort-dropdown-select-menu"> <option value=scoredesc selected=selected > Highest score (default) </option> <option value=trending > Trending (recent votes count more) </option> <option value=modifieddesc > Date modified (newest first) </option> <option value=createdasc > Date created (oldest first) </option> </select> </div> </div> </div> </div> </div> <div class="s-pagination site1 themed pager-answers"> <div class="s-pagination--item is-selected" aria-current="page">1</div> <a class="s-pagination--item js-pagination-item" href="/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top" rel="" title="Go to page 2">2</a> <a class="s-pagination--item js-pagination-item" href="/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top" rel="next" title="Go to page 2"> Next</a></div> <a name="1672"></a> <div id="answer-1672" class="answer js-answer accepted-answer js-accepted-answer" data-answerid="1672" data-parentid="1669" data-score="1202" data-position-on-page="1" data-highest-scored="1" data-question-has-accepted-highest-score="1" itemprop="acceptedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1672" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1672" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:27b66d945e26d55d,10:1740274359,16:05013d8c42ff58a0,4:1672,360df35643c1de37883a4603653eb4ea3dc7c177c0fff4ef0b5c746cb2168d65" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="1202"> 1202 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:79cfa2b898ba73b7,10:1740274359,16:264ac1eccc139654,4:1672,5f57e9e95c696c1e5988d7510afc02a3d542581670fb1065ca71545356c384e0" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1672" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1672" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1672/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <h2>Big List of Resources:</h2> <ul> <li><a href="http://www.cs.indiana.edu/%7Edyb/pubs/nano-jfp.pdf" rel="noreferrer">A Nanopass Framework for Compiler Education</a> ¶</li> <li><a href="http://www.amazon.com/gp/offer-listing/1558603204?tag=thecompilerconne&camp=14573&creative=327641&linkCode=am1&creativeASIN=1558603204&adid=1ZQWN5FGBA1JM6MNQ2ZV&" rel="noreferrer">Advanced Compiler Design and Implementation</a> $</li> <li><a href="http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf" rel="noreferrer">An Incremental Approach to Compiler Construction</a> ¶</li> <li><a href="http://javadude.com/articles/antlr3xtut" rel="noreferrer">ANTLR 3.x Video Tutorial</a></li> <li><a href="http://www.diku.dk/%7Etorbenm/Basics/" rel="noreferrer">Basics of Compiler Design</a></li> <li><a href="http://web.archive.org/web/20160731061607/http://www.onlamp.com/pub/a/onlamp/2004/04/15/parrot_compiler_construction.html" rel="noreferrer">Building a Parrot Compiler</a></li> <li><a href="http://www.cs.man.ac.uk/%7Epjj/farrell/compmain.html" rel="noreferrer">Compiler Basics</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0201403536" rel="noreferrer" rel="nofollow noreferrer">Compiler Construction</a> $</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0442275366" rel="noreferrer" rel="nofollow noreferrer">Compiler Design and Construction</a> $</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0805321667" rel="noreferrer" rel="nofollow noreferrer">Crafting a Compiler with C</a> $</li> <li><a href="http://craftinginterpreters.com/" rel="noreferrer">Crafting Interpreters</a></li> <li>[Compiler Design in C] <a href="http://www.holub.com/software/compiler.design.in.c.html" rel="noreferrer">12</a> ¶</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0321486811" rel="noreferrer" rel="nofollow noreferrer">Compilers: Principles, Techniques, and Tools</a> $ — aka <a href="http://en.wikipedia.org/wiki/Compilers:_Principles%2C_Techniques%2C_and_Tools" rel="noreferrer">"The Dragon Book"</a>; widely considered "the book" for compiler writing.</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/012088478X" rel="noreferrer" rel="nofollow noreferrer">Engineering a Compiler</a> $</li> <li><a href="http://www.cs.indiana.edu/eopl/" rel="noreferrer">Essentials of Programming Languages</a></li> <li><a href="http://flipcode.com/archives/articles.shtml" rel="noreferrer">Flipcode Article Archive</a> (look for "Implementing A Scripting Engine by Jan Niestadt")</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/1931841578" rel="noreferrer" rel="nofollow noreferrer">Game Scripting Mastery</a> $</li> <li><a href="http://www.codeproject.com/KB/recipes/B32Machine1/VMCS.pdf" rel="noreferrer">How to build a virtual machine from scratch in C#</a> ¶</li> <li><a href="http://research.microsoft.com/%7Esimonpj/papers/pj-lester-book/" rel="noreferrer">Implementing Functional Languages</a></li> <li><a href="http://www1.digitalgrammars.com/ipl-book/" rel="noreferrer">Implementing Programming Languages (with BNFC)</a></li> <li><a href="http://www.codeproject.com/KB/recipes/programminglanguagetoools.aspx" rel="noreferrer">Implementing Programming Languages using C# 4.0</a></li> <li><a href="http://en.wikipedia.org/wiki/Interpreter_pattern" rel="noreferrer">Interpreter pattern</a> (described in <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="noreferrer" rel="nofollow noreferrer">Design Patterns</a> $) specifies a way to evaluate sentences in a language</li> <li><a href="http://pragprog.com/titles/tpdsl/language-implementation-patterns" rel="noreferrer">Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages</a> $</li> <li><a href="http://compilers.iecc.com/crenshaw/" rel="noreferrer">Let's Build a Compiler</a> by Jack Crenshaw — The <a href="http://www.stack.nl/%7Emarcov/compiler.pdf" rel="noreferrer">PDF</a> ¶ version (examples are in Pascal, but the information is generally applicable)</li> <li><a href="http://books.google.com/books?id=Id9cYsIdjIwC&lpg=PP1&ots=IxFkFWJ-8V&dq=%22linkers%20and%20loaders%22&pg=PA215#v=onepage&q=%22linkers%20and%20loaders%22&f=false" rel="noreferrer">Linkers and Loaders</a> $ (Google Books)</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0521562473" rel="noreferrer" rel="nofollow noreferrer">Lisp in Small Pieces (LiSP)</a> $</li> <li><a href="http://llvm.org/docs/tutorial/" rel="noreferrer">LLVM Tutorial</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0521607647" rel="noreferrer" rel="nofollow noreferrer">Modern Compiler Implementation in ML</a> $ — There is a <a href="https://rads.stackoverflow.com/amzn/click/com/052182060X" rel="noreferrer" rel="nofollow noreferrer">Java</a> $ and <a href="https://rads.stackoverflow.com/amzn/click/com/0521607655" rel="noreferrer" rel="nofollow noreferrer">C</a> $ version as well - widely considered a very good book</li> <li><a href="http://www.amazon.com/gp/offer-listing/013630740X?tag=thecompilerconne&camp=14573&creative=327641&linkCode=am1&creativeASIN=013630740X&adid=0JPMVBRNCAN6PDKGYSXX&" rel="noreferrer">Object-Oriented Compiler Construction</a> $</li> <li><a href="http://www.dickgrune.com/Books/PTAPG_1st_Edition/" rel="noreferrer">Parsing Techniques - A Practical Guide</a></li> <li><a href="http://www-old.oberon.ethz.ch/WirthPubl/ProjectOberon.pdf" rel="noreferrer">Project Oberon</a> ¶ - Look at chapter 13</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0137302673" rel="noreferrer" rel="nofollow noreferrer">Programming a Personal Computer</a> $</li> <li><a href="http://www.cs.brown.edu/%7Esk/Publications/Books/ProgLangs/" rel="noreferrer">Programing Languages: Application and Interpretation</a></li> <li><a href="http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AITR-474.pdf" rel="noreferrer">Rabbit: A Compiler for Scheme</a>¶</li> <li><a href="http://web.archive.org/web/20141221110345/http://cm.bell-labs.com/who/ken/trust.html" rel="noreferrer">Reflections on Trusting Trust</a> — A quick guide</li> <li><a href="http://msdn.microsoft.com/en-us/magazine/cc136756.aspx" rel="noreferrer">Roll Your Own Compiler for the .NET framework</a> — A quick tutorial from MSDN</li> <li><a href="http://mitpress.mit.edu/sicp/" rel="noreferrer">Structure and Interpretation of Computer Programs</a></li> <li><a href="http://www.cis.upenn.edu/%7Ebcpierce/tapl/" rel="noreferrer">Types and Programming Languages</a></li> <li><a href="http://prog21.dadgum.com/30.html" rel="noreferrer">Want to Write a Compiler?</a> - a quick guide</li> <li><a href="http://www.hokstad.com/writing-a-compiler-in-ruby-bottom-up-step-1.html" rel="noreferrer">Writing a Compiler in Ruby Bottom Up</a></li> <li><a href="https://bernsteinbear.com/blog/compiling-a-lisp-0/" rel="noreferrer">Compiling a Lisp</a> — compile directly to x86-64</li> </ul> <p>Legend:</p> <ul> <li>¶ Link to a PDF file</li> <li>$ Link to a printed book</li> </ul> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-04T22:52:00"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1672" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1672" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1672/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1672" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:7fcf62e446c7a5c3,10:1740274359,16:168ead74c0b4c7b1,4:1672,53a6371e4398e0ae052426fcf61bf5e996178a6c7f136776abf43a4d916a0ad5" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1672/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2021-07-30 22:04:27Z' class='relativetime'>Jul 30, 2021 at 22:04</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1672" href="/posts/1672/revisions" title="show revision history for this post"> 40 revs, 29 users 26%<br><a href="/users/340">Anton</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">4</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1672" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1672" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-2996907" class="comment js-comment " data-comment-id="2996907" data-comment-owner-id="13198" data-comment-score="28"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="hot">28</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I've read <code>Let's Build a Compiler</code> [<a href="http://compilers.iecc.com/crenshaw/]" rel="nofollow noreferrer">compilers.iecc.com/crenshaw/]</a> series, it is really nice writeup and is a good starting point.</span> <div class="d-inline-flex ai-center"> – <a href="/users/13198/thevillageidiot" title="40,517 reputation" class="comment-user">TheVillageIdiot</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2010-05-31 04:35:19Z, License: CC BY-SA 2.5' class='relativetime-clean'>May 31, 2010 at 4:35</span> </span> </div> </div> </li> <li id="comment-58896582" class="comment js-comment " data-comment-id="58896582" data-comment-owner-id="505292" data-comment-score="6"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="warm">6</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I think one worth mentioning is Coursera's compilers course. It has nice videos and walks through creating a java like language / simple compiler. <a href="https://www.coursera.org/course/compilers" rel="nofollow noreferrer">Coursera Compilers Link</a></span> <div class="d-inline-flex ai-center"> – <a href="/users/505292/quantumkarl" title="499 reputation" class="comment-user">QuantumKarl</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2016-02-24 15:25:49Z, License: CC BY-SA 3.0' class='relativetime-clean'>Feb 24, 2016 at 15:25</span> </span> </div> </div> </li> <li id="comment-69285004" class="comment js-comment " data-comment-id="69285004" data-comment-owner-id="1757805" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I wanted to keep this answer posted to being as original as possible so I decided to post this reference here: <a href="https://www.tutorialspoint.com/compiler_design/index.htm" rel="nofollow noreferrer">tutorialspoint.com/compiler_design/index.htm</a> What I liked about this site is that it doesn't get involved with actually writing any code to create a compiler, but it does break down the compiler into its parts: phases and stages. It does describe the logic and algorithmic design approach without any specific language paradigm as it expresses the notations of an arbitrary language and alphabet. It is a quick read, but gives you the concepts of what is needed for each part.</span> <div class="d-inline-flex ai-center"> – <a href="/users/1757805/francis-cugler" title="7,915 reputation" class="comment-user">Francis Cugler</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2016-12-08 11:55:52Z, License: CC BY-SA 3.0' class='relativetime-clean'>Dec 8, 2016 at 11:55</span> </span> <span title="this comment was edited 1 time"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> <li id="comment-117200366" class="comment js-comment " data-comment-id="117200366" data-comment-owner-id="13580938" data-comment-score="3"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">3</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">The link by @TheVillageIdiot is broken (due to a formatting error in the comment), this works: <a href="https://compilers.iecc.com/crenshaw/" rel="nofollow noreferrer">compilers.iecc.com/crenshaw</a></span> <div class="d-inline-flex ai-center"> – <a href="/users/13580938/dimitar-bogdanov" title="394 reputation" class="comment-user">dimitar.bogdanov</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2021-02-20 14:33:38Z, License: CC BY-SA 4.0' class='relativetime-clean'>Feb 20, 2021 at 14:33</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1672" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <div class="js-zone-container zone-container-main"> <div id="dfp-mlb" class="everyonelovesstackoverflow everyoneloves__mid-leaderboard everyoneloves__leaderboard"></div> <div class="js-report-ad-button-container " style="width: 728px"></div> </div> <a name="1156434"></a> <div id="answer-1156434" class="answer js-answer" data-answerid="1156434" data-parentid="1669" data-score="75" data-position-on-page="2" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1156434" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1156434" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:83ca91cc54426c13,10:1740274359,16:2742c5893ca30366,7:1156434,0b9dc3c21c3717889e13834c8317a8c50635f22b86d37732dc27cb4a427ac2eb" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="75"> 75 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:6d1a7ee25bed5cc4,10:1740274359,16:0acf08f041804393,7:1156434,d8f595ea70350c49918976d4fe898b1fbfd1bb3b3cf83e2067d559e89fde98bd" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1156434" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1156434" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1156434/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>This is a pretty vague question, I think; just because of the depth of the topic involved. A compiler can be decomposed into two separate parts, however; a top-half and a bottom-one. The top-half generally takes the source language and converts it into an intermediate representation, and the bottom half takes care of the platform specific code generation.</p> <p>Nonetheless, one idea for an easy way to approach this topic (the one we used in my compilers class, at least) is to build the compiler in the two pieces described above. Specifically, you'll get a good idea of the entire process by just building the top-half.</p> <p>Just doing the top half lets you get the experience of writing the lexical analyzer and the parser and go to generating some "code" (that intermediate representation I mentioned). So it will take your source program and convert it to another representation and do some optimization (if you want), which is the heart of a compiler. The bottom half will then take that intermediate representation and generate the bytes needed to run the program on a specific architecture. For example, the the bottom half will take your intermediate representation and generate a PE executable. </p> <p>Some books on this topic that I found particularly helpful was <a href="https://rads.stackoverflow.com/amzn/click/com/0321486811" rel="noreferrer" rel="nofollow noreferrer">Compilers Principles and Techniques</a> (or the Dragon Book, due to the cute dragon on the cover). It's got some great theory and definitely covers Context-Free Grammars in a really accessible manner. Also, for building the lexical analyzer and parser, you'll probably use the *nix tools lex and yacc. And uninterestingly enough, the book called "<a href="https://rads.stackoverflow.com/amzn/click/com/1565920007" rel="noreferrer" rel="nofollow noreferrer">lex and yacc</a>" picked up where the Dragon Book left off for this part.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-07-20T23:01:20"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1156434" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1156434" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1156434/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1156434" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:b87caeec65b557af,10:1740274359,16:d2a6ff8e8a492c92,7:1156434,8d640655c8c7419afe0f42c772a870908c933d93980e78b481576c4671e967ef" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/1156434/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2009-07-20 23:01:20Z' class='relativetime'>Jul 20, 2009 at 23:01</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Sep 2, 2010 at 17:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1156434" href="/posts/1156434/revisions" title="show revision history for this post"> mrduclaw </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1156434" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="1156434" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-1156434" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="7085"></a> <div id="answer-7085" class="answer js-answer" data-answerid="7085" data-parentid="1669" data-score="63" data-position-on-page="3" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="7085" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-7085" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:e27b12872469af0a,10:1740274359,16:1721863e722c6b22,4:7085,c55f6338d25f3f554babbd0040eb26bac5f58564f593d17dbbe59675237c88d3" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="63"> 63 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:caa7261cc4b8649b,10:1740274359,16:e8c541ecd8179fc5,4:7085,44b89632b850cc1c5e6f930d5aaeb009182028c1c708702bc1c00e26c892237a" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-7085" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="7085" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/7085/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I think <a href="https://rads.stackoverflow.com/amzn/click/com/0521607647" rel="noreferrer" rel="nofollow noreferrer" title="Modern Compiler Implementation in ML">Modern Compiler Implementation in ML</a> is the best introductory compiler writing text. There's a <a href="https://rads.stackoverflow.com/amzn/click/com/052182060X" rel="noreferrer" rel="nofollow noreferrer" title="Modern Compiler Implementation in Java">Java version</a> and a <a href="https://rads.stackoverflow.com/amzn/click/com/0521607655" rel="noreferrer" rel="nofollow noreferrer" title="Modern Compiler Implementation in C">C version</a> too, either of which might be more accessible given your languages background. The book packs a lot of useful basic material (scanning and parsing, semantic analysis, activation records, instruction selection, RISC and x86 native code generation) and various "advanced" topics (compiling OO and functional languages, polymorphism, garbage collection, optimization and single static assignment form) into relatively little space (~500 pages).</p> <p>I prefer Modern Compiler Implementation to the Dragon book because Modern Compiler implementation surveys less of the field--instead it has really solid coverage of all the topics you would need to write a serious, decent compiler. After you work through this book you'll be ready to tackle research papers directly for more depth if you need it.</p> <p>I must confess I have a serious soft spot for Niklaus Wirth's <a href="https://rads.stackoverflow.com/amzn/click/com/0201403536" rel="noreferrer" rel="nofollow noreferrer" title="Compiler Construction">Compiler Construction.</a> It is <a href="http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf" rel="noreferrer" title="Compiler Construction (PDF)">available online</a> as a PDF. I find Wirth's programming aesthetic simply beautiful, however some people find his style too minimal (for example Wirth favors recursive descent parsers, but most CS courses focus on parser generator tools; Wirth's language designs are fairly conservative.) Compiler Construction is a very succinct distillation of Wirth's basic ideas, so whether you like his style or not or not, I highly recommend reading this book.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-10T07:54:32"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="7085" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/7085" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/7085/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-7085" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:1589ac694e76eb10,10:1740274359,16:ed683bb6071b09fe,4:7085,68226e1b3a15db1eda61dbe890695924f98d1edacb2dc42fa782b10bfcd0979c" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/7085/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2019-12-04 14:42:49Z' class='relativetime'>Dec 4, 2019 at 14:42</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-7085" href="/posts/7085/revisions" title="show revision history for this post"> 2 revs, 2 users 96%<br><a href="/users/878">Dominic Cooney</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">2</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-7085" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="7085" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-54341155" class="comment js-comment " data-comment-id="54341155" data-comment-owner-id="2310961" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Compiler Construction PDF <a href="http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf" rel="nofollow noreferrer">ethoberon.ethz.ch/WirthPubl/CBEAll.pdf</a></span> <div class="d-inline-flex ai-center"> – <a href="/users/2310961/matepal297" title="1,101 reputation" class="comment-user">matepal297</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2015-10-21 22:00:39Z, License: CC BY-SA 3.0' class='relativetime-clean'>Oct 21, 2015 at 22:00</span> </span> <span title="this comment was edited 3 times"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> <li id="comment-64581369" class="comment js-comment " data-comment-id="64581369" data-comment-owner-id="1353549" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I strongly recommend <i>against</i> the C version of "Modern Compiler Implementation", it's crippled by low-level details due to C. It completely clutters the book. Java 1st is not too good as its OO design is poor, Java 2nd ed is no longer about the Tiger language. So I strongly recommend the ML one: it is not necessary to be fluent in ML to understand it. ML is definitely well suited for the job.</span> <div class="d-inline-flex ai-center"> – <a href="/users/1353549/akim" title="8,769 reputation" class="comment-user">akim</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2016-07-26 17:52:07Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 26, 2016 at 17:52</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-7085" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <div class="js-zone-container zone-container-main"> <div id="dfp-smlb" class="everyonelovesstackoverflow everyoneloves__mid-second-leaderboard everyoneloves__leaderboard"></div> <div class="js-report-ad-button-container " style="width: 728px"></div> </div> <a name="1686"></a> <div id="answer-1686" class="answer js-answer" data-answerid="1686" data-parentid="1669" data-score="47" data-position-on-page="4" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1686" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1686" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:d3ad0c728039b745,10:1740274359,16:986cc38f3681e9b2,4:1686,1d1555c4965610946300cfb227c18e502caebc4121f8f68a827cebbba8dc8a8b" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="47"> 47 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:ce0f1c8b6da145e3,10:1740274359,16:b6c5504f0cc38968,4:1686,b3b519f79ada32513e07ccfd80604aae6f230180108680009e70a26913f97e69" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1686" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1686" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1686/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I concur with the Dragon Book reference; IMO, it is the definitive guide to compiler construction. Get ready for some hardcore theory, though.</p> <p>If you want a book that is lighter on theory, <a href="https://rads.stackoverflow.com/amzn/click/com/1931841578" rel="noreferrer" rel="nofollow noreferrer">Game Scripting Mastery</a> might be a better book for you. If you are a total newbie at compiler theory, it provides a gentler introduction. It doesn't cover more practical parsing methods (opting for non-predictive recursive descent without discussing LL or LR parsing), and as I recall, it doesn't even discuss any sort of optimization theory. Plus, instead of compiling to machine code, it compiles to a bytecode that is supposed to run on a VM that you also write.</p> <p>It's still a decent read, particularly if you can pick it up for cheap on Amazon. If you only want an easy introduction into compilers, Game Scripting Mastery is not a bad way to go. If you want to go hardcore up front, then you should settle for nothing less than the Dragon Book.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-04T23:08:18"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1686" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1686" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1686/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1686" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:11545e87a4cd7e0d,10:1740274359,16:86764370b1a7c1df,4:1686,ab7aa6634f7f1a8b87b009525d497510196a2636a22967b7f18d525d8c1868fd" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/1686/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-08-04 23:08:18Z' class='relativetime'>Aug 4, 2008 at 23:08</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1686" href="/posts/1686/revisions" title="show revision history for this post"> user316 </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">2</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1686" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1686" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-185768" class="comment js-comment " data-comment-id="185768" data-comment-owner-id="22437" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Game Scripting Mastery is a great learning resource because when you're done you will have a playable, scriptable 2D adventure game. This makes every exercise focused on a specific purpose, and keeps the reader motivated.</span> <div class="d-inline-flex ai-center"> – <a href="/users/22437/dour-high-arch" title="21,722 reputation" class="comment-user">Dour High Arch</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2008-12-09 17:58:02Z, License: CC BY-SA 2.5' class='relativetime-clean'>Dec 9, 2008 at 17:58</span> </span> </div> </div> </li> <li id="comment-862912" class="comment js-comment " data-comment-id="862912" data-comment-owner-id="99354" data-comment-score="1"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">1</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Dragon is a bit overly focussed on grammar based parsing. If you are not trying to parse something sheer impossible like C++ or so using parser generators, but can use e.g. a handcrafted LL grammar you might want to look out for something that treats a higher percentage compiler fields other than grammar transformation and proving</span> <div class="d-inline-flex ai-center"> – <a href="/users/99354/marco-van-de-voort" title="26,376 reputation" class="comment-user">Marco van de Voort</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-06-26 21:36:25Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jun 26, 2009 at 21:36</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1686" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1678"></a> <div id="answer-1678" class="answer js-answer" data-answerid="1678" data-parentid="1669" data-score="32" data-position-on-page="5" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1678" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1678" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:103e94c02f4edeb3,10:1740274359,16:1d482794b4e8df3b,4:1678,5c5a49081c7dac84d6dc13fc016c1fcea3afe388ec40982aea4fed16a643c088" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="32"> 32 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:2e1fe668832676c5,10:1740274359,16:e5eaf823f1c3fc8c,4:1678,37c7f38c5b2d1443923a4d4a1cf3afa85036b300d672d8852177a89cb631d94d" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1678" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1678" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1678/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p><a href="http://compilers.iecc.com/crenshaw/" rel="noreferrer">"Let's Build a Compiler"</a> is awesome, but it's a bit outdated. (I'm not saying it makes it even a little bit less valid.)</p> <p>Or check out <a href="https://www.quora.com/As-a-self-taught-programmer-how-can-I-learn-about-compilers/answer/Akhil-Kooliyatt?srid=TAGM" rel="noreferrer">SLANG</a>. This is similar to "Let's Build a Compiler" but is a much better resource especially for beginners. This comes with a pdf tutorial which takes a 7 step approach at teaching you a compiler. Adding the quora link as it have the links to all the various ports of SLANG, in C++, Java and JS, also interpreters in python and java, originally written using C# and the .NET platform.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-04T22:56:30"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1678" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1678" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1678/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1678" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:34b15639f138d230,10:1740274359,16:6e293516794b163c,4:1678,5ea200fede0365fcf51864b80d6e8a0ed3d858e145ec626df57dbbcf8ddaf829" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1678/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2016-08-16 05:55:29Z' class='relativetime'>Aug 16, 2016 at 5:55</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1678" href="/posts/1678/revisions" title="show revision history for this post"> 4 revs, 4 users 40%<br><a href="/users/3988992">RBz</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1678" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1678" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-3932046" class="comment js-comment " data-comment-id="3932046" data-comment-owner-id="106762" data-comment-score="5"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="warm">5</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I agree that this series is a bit outdated, although it is still useful. However, my biggest gripe with it is the fact that it tries to output straight to assembly language rather than building any type of parse tree, which means (contrary to what is stated in the first article) that it isn't very useful for writing an interpreter.</span> <div class="d-inline-flex ai-center"> – <a href="/users/106762/a-m0d" title="12,205 reputation" class="comment-user">a_m0d</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2010-09-16 06:58:36Z, License: CC BY-SA 2.5' class='relativetime-clean'>Sep 16, 2010 at 6:58</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1678" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1693"></a> <div id="answer-1693" class="answer js-answer" data-answerid="1693" data-parentid="1669" data-score="26" data-position-on-page="6" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1693" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1693" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:ebb6178cb113b599,10:1740274359,16:c705a208ab3fa013,4:1693,2d45821810522bc1f1d528ac3fc38d646cfa6ca8fb380baa3a244ea13a4a553a" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="26"> 26 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:1726f8edba829d08,10:1740274359,16:b7b767a2f9bed102,4:1693,4da6890a360b352323849b8deaaf3291d8e3834bf59becb6ae6108222c1f50b4" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1693" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1693" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1693/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>If you're looking to use powerful, higher level tools rather than building <em>everything</em> yourself, going through the projects and readings for <a href="http://www.antlr.org/wiki/display/CS652/CS652+Home" rel="noreferrer">this course</a> is a pretty good option. It's a languages course by the author of the Java parser engine ANTLR. You can get the book for the course as a PDF from <a href="http://www.pragprog.com/titles/tpantlr/the-definitive-antlr-reference" rel="noreferrer">the Pragmatic Programmers</a>.</p> <p>The course goes over the standard compiler compiler stuff that you'd see elsewhere: parsing, types and type checking, polymorphism, symbol tables, and code generation. Pretty much the only thing that isn't covered is optimizations. The final project is a program that <a href="http://www.antlr.org/wiki/display/CS652/C+subset+compiler" rel="noreferrer">compiles a subset of C</a>. Because you use tools like ANTLR and LLVM, it's feasible to write the entire compiler in a single day (I have an existence proof of this, though I do mean ~24 hours). It's heavy on practical engineering using modern tools, a bit lighter on theory.</p> <p>LLVM, by the way, is simply fantastic. Many situations where you might normally compile down to assembly, you'd be much better off compiling to <a href="http://llvm.org/docs/LangRef.html" rel="noreferrer">LLVM's Intermediate Representation</a> instead. It's higher level, cross platform, and LLVM is quite good at generating optimized assembly from it.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-04T23:13:49"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1693" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1693" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1693/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1693" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:ded1cc580871fa91,10:1740274359,16:23133e875545e8d7,4:1693,52be36cc1a62bd64a0a06b7a89ef6e9d1bda7d08a3b8cc5156dbdd955dd2a76d" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1693/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2008-08-04 23:25:02Z' class='relativetime'>Aug 4, 2008 at 23:25</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1693" href="/posts/1693/revisions" title="show revision history for this post"> 2 revs<br><a href="/users/101">Peter Burns</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1693" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1693" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-73091134" class="comment js-comment " data-comment-id="73091134" data-comment-owner-id="257418" data-comment-score="8"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="warm">8</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">The first link is dead.</span> <div class="d-inline-flex ai-center"> – <a href="/users/257418/lynn" title="10,794 reputation" class="comment-user">lynn</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2017-03-24 13:31:46Z, License: CC BY-SA 3.0' class='relativetime-clean'>Mar 24, 2017 at 13:31</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1693" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="3592870"></a> <div id="answer-3592870" class="answer js-answer" data-answerid="3592870" data-parentid="1669" data-score="23" data-position-on-page="7" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="3592870" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-3592870" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:fff3e537a5efda50,10:1740274359,16:d065f3da6e6ba19e,7:3592870,cc1c182c12c845745928292266695723add7293f41908bbedb94fb01ad46d0ad" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="23"> 23 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:d3383e2ef1a56391,10:1740274359,16:5bc589a9f39eb7f8,7:3592870,05298dc23a26d8c2e323fbd223a998abba0ebcdbf1521c226b46a70f3b39220b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-3592870" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="3592870" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/3592870/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>If you have little time, I recommend <a href="http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf" rel="noreferrer">Niklaus Wirth's "Compiler Construction" (Addison-Wesley. 1996)</a>, a tiny little booklet that you can read in a day, but it explains the basics (including how to implement lexers, recursive descent parsers, and your own stack-based virtual machines). After that, if you want a deep dive, there's no way around the Dragon book as other commenters suggest.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2010-08-28T23:14:41"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="3592870" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/3592870" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/3592870/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-3592870" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:ab5ab837c66de9c0,10:1740274359,16:4ac0c05060e84a9c,7:3592870,5e51deb98979eb76c00738af5d06c79b3ecee008cd0aa96bf4d904cb091ab50d" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/3592870/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2011-10-18 13:55:17Z' class='relativetime'>Oct 18, 2011 at 13:55</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Aug 28, 2010 at 23:14. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-3592870" href="/posts/3592870/revisions" title="show revision history for this post"> 2 revs, 2 users 67%<br><a href="/users/444469">Matthieu</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-3592870" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="3592870" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-10925969" class="comment js-comment " data-comment-id="10925969" data-comment-owner-id="86604" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">If you have not much time, don' write a compiler.</span> <div class="d-inline-flex ai-center"> – <a href="/users/86604/ingo" title="36,349 reputation" class="comment-user">Ingo</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-01-06 23:56:02Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jan 6, 2012 at 23:56</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-3592870" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1156391"></a> <div id="answer-1156391" class="answer js-answer" data-answerid="1156391" data-parentid="1669" data-score="19" data-position-on-page="8" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1156391" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1156391" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:d50d77e5d4161fa3,10:1740274359,16:4e4400338688ecd3,7:1156391,baeff812c9b578f76768359dc86e2f3e6a570a27d6a0e979b0f2716dcaecaa4e" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="19"> 19 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:058407f391e430ce,10:1740274359,16:c24bb7f9949641af,7:1156391,553112466e0477ba349c71194f7b4b9d26ec6798e3195cf4214d8572e67ca183" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1156391" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1156391" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1156391/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>You might want to look into Lex/Yacc (or Flex/Bison, whatever you want to call them). Flex is a lexical analyzer, which will parse and identify the semantic components ("tokens") of your language, and Bison will be used to define what happens when each token is parsed. This could be, but is definitely not limited to, printing out C code, for a compiler that would compile to C, or dynamically running the instructions.</p> <p><a href="http://tldp.org/HOWTO/Lex-YACC-HOWTO-5.html" rel="noreferrer">This FAQ</a> should help you, and <a href="http://www.mactech.com/articles/mactech/Vol.16/16.07/UsingFlexandBison/" rel="noreferrer">this tutorial</a> looks quite useful.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-07-20T22:47:04"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1156391" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1156391" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1156391/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1156391" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:a5d27ab480364bd2,10:1740274359,16:eccc5065690c5691,7:1156391,da3868539b449082011c283fccde109f3ce4f4eaa367ed1e9824ab9b17be456b" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/1156391/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2009-07-20 22:47:04Z' class='relativetime'>Jul 20, 2009 at 22:47</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Sep 2, 2010 at 17:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1156391" href="/posts/1156391/revisions" title="show revision history for this post"> Zachary Murray </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1156391" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="1156391" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-1156391" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1158408"></a> <div id="answer-1158408" class="answer js-answer" data-answerid="1158408" data-parentid="1669" data-score="17" data-position-on-page="9" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1158408" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1158408" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:b7b0dc7ccfaafaaf,10:1740274359,16:827550d729e74361,7:1158408,a0f7dbefb3c145bf094b72e41f0b4f8f598ba1f97c2f3a70c21233b14d626d5d" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="17"> 17 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:45d496956f38c303,10:1740274359,16:58c29ee53588f265,7:1158408,dd884130643b57a8767e045ad9778f3324abba3cd6ec289b5da5cfa08c07c53b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1158408" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1158408" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1158408/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Generally speaking, there's no five minutes tutorial for compilers, because it's a complicated topic and writing a compiler can take months. You will have to do your own search.</p> <p>Python and Ruby are usually interpreted. Perhaps you want to start with an interpreter as well. It's generally easier.</p> <p>The first step is to write a formal language description, the grammar of your programming language. Then you have to transform the source code that you want to compile or interpret according to the grammar into an abstract syntax tree, an internal form of the source code that the computer understands and can operate on. This step is usually called parsing and the software that parses the source code is called a parser. Often the parser is generated by a parser generator which transform a formal grammar into source oder machine code. For a good, non-mathematical explanation of parsing I recommend Parsing Techniques - A Practical Guide. Wikipedia has a comparison of parser generators from which you can choose that one that is suitable for you. Depending on the parser generator you chose, you will find tutorials on the Internet and for really popular parser generators (like GNU bison) there are also books.</p> <p>Writing a parser for your language can be really hard, but this depends on your grammar. So I suggest to keep your grammar simple (unlike C++); a good example for this is LISP.</p> <p>In the second step the abstract syntax tree is transformed from a tree structure into a linear intermediate representation. As a good example for this Lua's bytecode is often cited. But the intermediate representation really depends on your language.</p> <p>If you are building an interpreter, you will simply have to interpret the intermediate representation. You could also just-in-time-compile it. I recommend LLVM and libjit for just-in-time-compilation. To make the language usable you will also have to include some input and output functions and perhaps a small standard library.</p> <p>If you are going to compile the language, it will be more complicated. You will have to write backends for different computer architectures and generate machine code from the intermediate representation in those backends. I recommend LLVM for this task.</p> <p>There are a few books on this topic, but I can recommend none of them for general use. Most of them are too academic or too practical. There's no "Teach yourself compiler writing in 21 days" and thus, you will have to buy several books to get a good understanding of this entire topic. If you search the Internet, you will come across some some online books and lecture notes. Maybe there's a university library nearby you where you can borrow books on compilers.</p> <p>I also recommend a good background knowledge in theoretical computer science and graph theory, if you are going to make your project serious. A degree in computer science will also be helpful.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-07-21T10:37:00"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1158408" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1158408" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1158408/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1158408" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:d00453453f5863f2,10:1740274359,16:d01eaf26512d5838,7:1158408,c9f0be4cae7839f1061715ad98727b1b96d55cf7ab83c7588d20939228acafcb" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/1158408/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2009-07-21 10:37:00Z' class='relativetime'>Jul 21, 2009 at 10:37</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Sep 2, 2010 at 17:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1158408" href="/posts/1158408/revisions" title="show revision history for this post"> user141335 </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1158408" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1158408" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-979091" class="comment js-comment " data-comment-id="979091" data-comment-owner-id="23771" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">++ You're right that it's good to know all those things, and it can be a big job, but I also learned from some experts how <i>not</i> to make things a big deal. It's good to know things, and it's even better to know when not to use them, which is most of the time.</span> <div class="d-inline-flex ai-center"> – <a href="/users/23771/mike-dunlavey" title="40,679 reputation" class="comment-user">Mike Dunlavey</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-07-21 16:00:37Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jul 21, 2009 at 16:00</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1158408" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="2853691"></a> <div id="answer-2853691" class="answer js-answer" data-answerid="2853691" data-parentid="1669" data-score="14" data-position-on-page="10" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="2853691" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-2853691" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:7b569fa5b17e542e,10:1740274359,16:ba1106dc3bdfd4d4,7:2853691,6aaeb0de0f2e9e834b317692632fe8a292fadec4f1a6bacd09760ec0fd4c0f6d" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="14"> 14 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:ac90b4dc7ff49bac,10:1740274359,16:db83cc2410a1ee71,7:2853691,c88f84fa13a85962794e9c3ba6983e451d060b636a14c051ccb45ffa02c1649d" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-2853691" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="2853691" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/2853691/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Take a look at the book below. The author is the creator of <a href="http://www.antlr.org/" rel="noreferrer">ANTLR</a>.</p> <p><a href="http://pragprog.com/titles/tpdsl/language-implementation-patterns" rel="noreferrer">Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages</a>.</p> <p><img src="https://i.sstatic.net/ukOkz.jpg" alt="alt text"></p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2010-05-17T23:38:29"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="2853691" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/2853691" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/2853691/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-2853691" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:5c1e413fcb901183,10:1740274359,16:499450cb59b35d85,7:2853691,52bfb5bad4c33944564c76d3c29326010af98e67c4e7aa4c7dc5cc50ba872715" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/2853691/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2014-12-27 12:39:08Z' class='relativetime'>Dec 27, 2014 at 12:39</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of May 17, 2010 at 23:38. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-2853691" href="/posts/2853691/revisions" title="show revision history for this post"> 2 revs, 2 users 95%<br><a href="/users/105744">Taylor Leese</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-2853691" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="2853691" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-2853691" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="15178"></a> <div id="answer-15178" class="answer js-answer" data-answerid="15178" data-parentid="1669" data-score="12" data-position-on-page="11" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="15178" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-15178" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:d4c58606b2fe682c,10:1740274359,16:b086d79893fbf42b,5:15178,7020f6233bea1ca4b1a6ac3f6d87cc4e4fca5423da14a98cdfe660640c23ebf3" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="12"> 12 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:64b6e231075a3cc6,10:1740274359,16:2abe115d6bb55036,5:15178,44d0af5258c4c67c341d2873be7e43525c0f37dca0fc4420cebed9d6061dde9b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-15178" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="15178" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/15178/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>One book not yet suggested but very important is <a href="http://books.google.com/books?id=h34d_jr2iikC&dq=%22linkers+and+loaders%22&pg=PP1&ots=IxFkFWJ-8V&sig=GSlclmkezTRL6YYguGJmZsnkM3c&hl=en&sa=X&oi=book_result&resnum=1&ct=result" rel="noreferrer">"Linkers and Loaders"</a> by John Levine. If you're not using an external assembler, you'll need a way to output a object file that can be linked into your final program. Even if you're using an external assembler, you'll probably need to understand relocations and how the whole program loading process works to make a working tool. This book collects a lot of the random lore around this process for various systems, including Win32 and Linux.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-18T20:18:32"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="15178" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/15178" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/15178/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-15178" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:28c09b48be630f34,10:1740274359,16:f523dfdefe86feaa,5:15178,15aed1da33a5f5cdae66bac69eff65fb4d6914f5d5a21b4c2ef94b3c47d05d1b" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/15178/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-08-18 20:18:32Z' class='relativetime'>Aug 18, 2008 at 20:18</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-15178" href="/posts/15178/revisions" title="show revision history for this post"> Ben Combee </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-15178" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="15178" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-15178" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="17694"></a> <div id="answer-17694" class="answer js-answer" data-answerid="17694" data-parentid="1669" data-score="12" data-position-on-page="12" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="17694" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-17694" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:be96c249aedadb87,10:1740274359,16:779391d6ff0c8426,5:17694,354e38a1db1eb8e72b89165828cdb855d79936934341e09a3807ddb7c411213f" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="12"> 12 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:4b75d204759f262f,10:1740274359,16:c960b64bffe3fd51,5:17694,77943c11eb85f55dbc970d62d9b8a31e04c3c19357bc64adff32966eb122ab90" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-17694" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="17694" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/17694/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>If you're willing to use LLVM, check this out: <a href="http://llvm.org/docs/tutorial/" rel="noreferrer">http://llvm.org/docs/tutorial/</a>. It teaches you how to write a compiler from scratch using LLVM's framework, and doesn't assume you have any knowledge about the subject.</p> <p>The tutorial suggest you write your own parser and lexer etc, but I advise you to look into bison and flex once you get the idea. They make life so much easier.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-20T10:01:17"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="17694" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/17694" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/17694/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-17694" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:cfe60450b60f3b9a,10:1740274359,16:d62b94215cb3f9d3,5:17694,21d39fea041b87858db2d2eaa520644c138678e782b22e6a2907314405739b22" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/17694/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-08-20 10:01:17Z' class='relativetime'>Aug 20, 2008 at 10:01</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-17694" href="/posts/17694/revisions" title="show revision history for this post"> wvdschel </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-17694" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="17694" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-41006196" class="comment js-comment " data-comment-id="41006196" data-comment-owner-id="-1" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">But the documentation for setting it up of Visual Studio is badly written, plus no examples</span> <div class="d-inline-flex ai-center"> – <span class="comment-user">user868935</span> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2014-10-02 09:17:44Z, License: CC BY-SA 3.0' class='relativetime-clean'>Oct 2, 2014 at 9:17</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-17694" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="2523"></a> <div id="answer-2523" class="answer js-answer" data-answerid="2523" data-parentid="1669" data-score="11" data-position-on-page="13" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="2523" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-2523" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:ad36e50ab37062bf,10:1740274359,16:7120536d38a61df3,4:2523,b169b2f67b011b0e6114b656a8b6d3660b4ca07552910a6151b4705ccef24432" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="11"> 11 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:e54324280cb8589e,10:1740274359,16:7ed76b4b1ccd879e,4:2523,71164ec2619fc13787c2d71e0f436c79b30dd940199235a79f0b19e27f9ae65b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-2523" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="2523" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/2523/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p><a href="https://rads.stackoverflow.com/amzn/click/com/0321486811" rel="noreferrer" rel="nofollow noreferrer">The Dragon Book</a> is definitely the "building compilers" book, but if your language isn't quite as complicated as the current generation of languages, you may want to look at the Interpreter pattern from <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="noreferrer" rel="nofollow noreferrer">Design Patterns</a>.</p> <p>The example in the book designs a regular expression-like language and is well thought through, but as they say in the book, it's good for thinking through the process but is effective really only on small languages. However, it is much faster to write an Interpreter for a small language with this pattern than having to learn about all the different types of parsers, yacc and lex, et cetera...</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-05T16:16:01"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="2523" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/2523" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/2523/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-2523" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:36cb76356d3421fb,10:1740274359,16:cb581dfb6f05c9bc,4:2523,17c4890c30da4556206a3ecef2155722470cffa899268524dbe21092f48d0099" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/2523/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-08-05 16:16:01Z' class='relativetime'>Aug 5, 2008 at 16:16</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-2523" href="/posts/2523/revisions" title="show revision history for this post"> Chris Bunch </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-2523" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="2523" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-2523" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="3443032"></a> <div id="answer-3443032" class="answer js-answer" data-answerid="3443032" data-parentid="1669" data-score="11" data-position-on-page="14" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="3443032" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-3443032" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:7d9a04234b8f266e,10:1740274359,16:1df44be559553037,7:3443032,c96e7816afdec497e75cf292a7faddc82f3ac11e636d36756708dd8ceb00b3c5" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="11"> 11 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:983d186f8f1f0f3d,10:1740274359,16:ed0ed86eb86f1607,7:3443032,b2d9264d75430cf7af0f1e29a861e58c9d6d8da9f29d31952faefbd630417ad2" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-3443032" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="3443032" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/3443032/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I found the Dragon book much too hard to read with too much focus on language theory that is not really required to write a compiler in practice. </p> <p>I would add the <a href="http://en.wikipedia.org/wiki/Oberon_%28programming_language%29" rel="noreferrer">Oberon</a> book which contains the full source of an amazingly fast and simple Oberon compiler <a href="http://www.amazon.de/Project-Oberon-Design-Operating-Compiler/dp/0201544288/ref=sr_1_3?ie=UTF8&s=books-intl-de&qid=1281378762&sr=8-3" rel="noreferrer">Project Oberon</a>.</p> <p><img src="https://i.sstatic.net/N3GFA.jpg" alt="Alt text"></p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2010-08-09T18:33:42"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="3443032" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/3443032" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/3443032/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-3443032" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:24e8615b46f0fc2f,10:1740274359,16:5b31b5824c40e411,7:3443032,2aa64e958559c7349906afcf684b3a17b9968f106e574c71c49c0e92fbf8ae23" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/3443032/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2014-12-27 12:39:09Z' class='relativetime'>Dec 27, 2014 at 12:39</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Aug 9, 2010 at 18:33. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-3443032" href="/posts/3443032/revisions" title="show revision history for this post"> 3 revs, 3 users 73%<br><a href="/users/155082">Lothar</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-3443032" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="3443032" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-3443032" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="74176"></a> <div id="answer-74176" class="answer js-answer" data-answerid="74176" data-parentid="1669" data-score="11" data-position-on-page="15" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="74176" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-74176" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:81ff56c8f323cfc4,10:1740274359,16:2e04340eda106196,5:74176,e2e12b8d093a5ad4764189612b4b0ec1e6c6aca788c84bdbbe0579e81257a1c5" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="11"> 11 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:471131533068af58,10:1740274359,16:457903605398f109,5:74176,e0046b120ffe2cfd8737ebcafd155705ac47e8299c8d564865851d978db58702" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-74176" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="74176" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/74176/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>The LCC compiler (<a href="http://en.wikipedia.org/wiki/Local_C_compiler" rel="nofollow noreferrer">wikipedia</a>) (<a href="http://www.cs.princeton.edu/software/lcc/" rel="nofollow noreferrer">project homepage</a>) (<a href="https://github.com/drh/lcc" rel="nofollow noreferrer">github.com/drh/lcc</a>) of Fraser and Hanson is described in their book "A Retargetable C Compiler: Design and Implementation". It is quite readable and explains the whole compiler, down to code generation. </p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-09-16T16:21:23"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="74176" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/74176" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/74176/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-74176" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:00ffdca4adc42ef5,10:1740274359,16:21450621020e1ed5,5:74176,935dd6b825b43b72e7060202e568a19403712abc0ee53c26442d6d4dc2545df1" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/74176/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2019-12-04 14:40:14Z' class='relativetime'>Dec 4, 2019 at 14:40</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-74176" href="/posts/74176/revisions" title="show revision history for this post"> 2 revs, 2 users 75%<br><a href="/users/8015">mfx</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-74176" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="74176" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-65159826" class="comment js-comment " data-comment-id="65159826" data-comment-owner-id="368070" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">This seems like an <b>extremely good resource</b> thanks.</span> <div class="d-inline-flex ai-center"> – <a href="/users/368070/gideon" title="19,465 reputation" class="comment-user">gideon</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2016-08-11 15:26:31Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 11, 2016 at 15:26</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-74176" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="401786"></a> <div id="answer-401786" class="answer js-answer" data-answerid="401786" data-parentid="1669" data-score="10" data-position-on-page="16" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="401786" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-401786" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="68:3:31e,16:f068fa26536b6294,10:1740274359,16:2159a7395072fa8f,6:401786,ebb83eca0e1f0e9176adb0a876d1efb51ba240101cb2902f0c992e24b70ddaaa" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="10"> 10 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="68:3:31e,16:238e3df25dfe9432,10:1740274359,16:b4dbeffb31e75f1b,6:401786,075eda777f036d063e6217201a8bc6c88afc0538d27840a63c3e9f7f0e4a4519" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-401786" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="401786" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/401786/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I am looking into the same concept, and found this promising article by Joel Pobar,</p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc136756.aspx" rel="nofollow noreferrer">Create a Language Compiler for the .NET Framework - not sure where this has gone</a></p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc136756.aspx" rel="nofollow noreferrer">Create a Language Compiler for the .NET Framework - pdf copy of the original doc</a></p> <p>he discusses a high level concept of a compiler and proceeds to invent his own langauge for the .Net framework. Although its aimed at the .Net Framework, many of the concepts should be able to be reproduced. The Article covers:</p> <ol> <li>Langauge definition </li> <li>Scanner </li> <li>Parser (the bit im mainly interested in)</li> <li>Targeting the .Net Framework The</li> <li>Code Generator</li> </ol> <p>there are other topics, but you get the just.</p> <p>Its aimed to people starting out, written in C# (not quite Java)</p> <p>HTH</p> <p>bones</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-12-30T23:01:20"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="401786" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/401786" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/401786/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-401786" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="68:3:31e,16:f56ca4bf4d8c2e79,10:1740274359,16:4e7b316e2ee61d64,6:401786,47a553168a771be21eb3fb943bc8c9d02c4e6df2cf5ccee8ab52654b80c0ed5a" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/401786/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2018-12-15 01:04:58Z' class='relativetime'>Dec 15, 2018 at 1:04</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Dec 30, 2008 at 23:01. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-401786" href="/posts/401786/revisions" title="show revision history for this post"> 2 revs<br><a href="/users/47642">dbones</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">2</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-401786" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="401786" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-600166" class="comment js-comment " data-comment-id="600166" data-comment-owner-id="84291" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">What does "not quite Java" mean?</span> <div class="d-inline-flex ai-center"> – <a href="/users/84291/hejazzman" title="2,152 reputation" class="comment-user">Hejazzman</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-04-25 21:53:58Z, License: CC BY-SA 2.5' class='relativetime-clean'>Apr 25, 2009 at 21:53</span> </span> </div> </div> </li> <li id="comment-607453" class="comment js-comment " data-comment-id="607453" data-comment-owner-id="47642" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">haha, sorry, i meant its written for .Net, which in principal is similar to java. Both are JIT in style. :)</span> <div class="d-inline-flex ai-center"> – <a href="/users/47642/dbones" title="4,504 reputation" class="comment-user">dbones</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-04-28 10:48:51Z, License: CC BY-SA 2.5' class='relativetime-clean'>Apr 28, 2009 at 10:48</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-401786" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1241910"></a> <div id="answer-1241910" class="answer js-answer" data-answerid="1241910" data-parentid="1669" data-score="10" data-position-on-page="17" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1241910" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1241910" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:264ef888a9593ac1,10:1740274359,16:2ec58a08aebde43f,7:1241910,3e338d82415858ced7b6d4cd4a0a66abefa4a835e778c4606152ad4ba4bc8d35" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="10"> 10 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:415beaa03b4c1d27,10:1740274359,16:b034363d7a29e04b,7:1241910,e44f5c64ceb6636a32de75fa2fa33d287ed4d6219f731a98edb768688169a9a9" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1241910" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1241910" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1241910/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I remember asking this question about seven years ago when I was rather new to programming.</p> <p>I was very careful when I asked and surprisingly I didn't get as much criticism as you are getting here. They did however point me in the direction of the "<a href="http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools" rel="nofollow noreferrer">Dragon Book</a>" which is in my opinion, a really great book that explains everything you need to know to write a compiler (you will of course have to master a language or two. The more languages you know, the merrier.).</p> <p>And yes, many people say reading that book is crazy and you won't learn anything from it, but I disagree completely with that.</p> <p>Many people also say that writing compilers is stupid and pointless. Well, there are a number of reasons why compiler development are useful:</p> <ul> <li>Because it's fun.</li> <li>It's educational, when learning how to write compilers you will learn a lot about computer science and other techniques that are useful when writing other applications.</li> <li>If nobody wrote compilers the existing languages wouldn't get any better.</li> </ul> <p>I didn't write my own compiler right away, but after asking I knew where to start. And now, after learning many different languages and reading the Dragon Book, writing isn't that much of a problem. (I'm also studying computer engineering atm, but most of what I know about programming is self taught.)</p> <p>In conclusion, The Dragon Book is a great "tutorial". But spend some time mastering a language or two before attempting to write a compiler. Don't expect to be a compiler guru within the next decade or so though.</p> <p>The book is also good if you want to learn how to write parsers/interpreters.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-08-06T22:37:05"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1241910" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1241910" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1241910/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1241910" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:b9f9dd705798571c,10:1740274359,16:b65d3b7cad92a0ef,7:1241910,0d73dffb302db1f4d4f2e045f0e6312a075bd7b7259aef9b9f40df6e29e3c983" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1241910/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2019-05-26 23:00:07Z' class='relativetime'>May 26, 2019 at 23:00</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Sep 2, 2010 at 17:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1241910" href="/posts/1241910/revisions" title="show revision history for this post"> 6 revs, 5 users 68%<br><a href="/users/150636">Pandafox</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1241910" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1241910" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-122221700" class="comment js-comment " data-comment-id="122221700" data-comment-owner-id="1993474" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">We were taught Compilers subject in college with Dragon Book, and i can vouch for it, it was one of the best books I've came through</span> <div class="d-inline-flex ai-center"> – <a href="/users/1993474/cosmoloc" title="3,004 reputation" class="comment-user">cosmoloc</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2021-09-12 14:41:04Z, License: CC BY-SA 4.0' class='relativetime-clean'>Sep 12, 2021 at 14:41</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1241910" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="17768"></a> <div id="answer-17768" class="answer js-answer" data-answerid="17768" data-parentid="1669" data-score="9" data-position-on-page="18" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="17768" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-17768" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:b503f23840e720ee,10:1740274359,16:4e8a599bdd85134b,5:17768,f9c3aa8c1a4501e53e44fb149f1f116064a9c419e338fe006443e98c41ef922a" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="9"> 9 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:45847c1b1783780b,10:1740274359,16:3eeb32e86326bbba,5:17768,16e5bebe890ab1e57d506ae2000b0fbd019ae51262a848124aebb7f03902f0d2" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-17768" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="17768" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/17768/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <blockquote> <p>"... Let's Build a Compiler ..."</p> </blockquote> <p>I'd second <a href="http://compilers.iecc.com/crenshaw/" rel="nofollow noreferrer">http://compilers.iecc.com/crenshaw/</a> by <a href="https://stackoverflow.com/questions/1669/learning-to-write-a-compiler#1678">@sasb</a>. Forget buying more books for the moment.</p> <p>Why? Tools & language. </p> <p>The language required is Pascal and if I remember correctly is based on Turbo-Pascal. It just so happens if you go to <a href="http://www.freepascal.org/" rel="nofollow noreferrer">http://www.freepascal.org/</a> and download the Pascal compiler all the examples work straight from the page ~ <a href="http://www.freepascal.org/download.var" rel="nofollow noreferrer">http://www.freepascal.org/download.var</a> The beaut thing about Free Pascal is you can use it almost whatever processor or OS you can care for. </p> <p>Once you have mastered the lessons then try the more advanced <em>"<a href="http://en.wikipedia.org/wiki/Dragon_book" rel="nofollow noreferrer">Dragon Book</a>"</em> ~ <a href="http://en.wikipedia.org/wiki/Dragon_book" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Dragon_book</a></p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-20T11:28:58"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="17768" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/17768" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/17768/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-17768" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:a5b5731ca905e45d,10:1740274359,16:45526ce49ecb8c12,5:17768,a5b8309c949cfb6f32fa7157728e8c26c000d26e4746a9a4d7302727dd55d8f2" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/17768/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2017-05-23 11:54:41Z' class='relativetime'>May 23, 2017 at 11:54</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-17768" href="/posts/17768/revisions" title="show revision history for this post"> 3 revs<br><a href="/users/2092">bootload</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-17768" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="17768" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-17768" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="17690"></a> <div id="answer-17690" class="answer js-answer" data-answerid="17690" data-parentid="1669" data-score="8" data-position-on-page="19" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="17690" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-17690" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:2508d84690a98832,10:1740274359,16:324b2910e7cc3bdb,5:17690,61ac4844c016f343c3a9d68b1347448f074801e9604f7c26c8f0ec72dd163f0d" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="8"> 8 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:32d74deeba7b4456,10:1740274359,16:079277978cdb90b0,5:17690,6a31f3d11205dd7e5a59c44fa052927416bbadd6ddb0cbe38d78ab854244226b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-17690" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="17690" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/17690/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>An easy way to create a compiler is to use bison and flex (or similar), build a tree (AST) and generate code in C. With generating C code being the most important step. By generating C code, your language will automatically work on all platforms that have a C compiler.</p> <p>Generating C code is as easy as generating HTML (just use print, or equivalent), which in turn is much easier than writing a C parser or HTML parser.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-20T09:56:34"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="17690" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/17690" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/17690/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-17690" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:c395a20a556048c5,10:1740274359,16:96a8bcbd7ad148df,5:17690,073cab50bf9ba439c884b32476542d1c8743073bb732bc0c92aa8e2917dbeb74" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/17690/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-08-20 09:56:34Z' class='relativetime'>Aug 20, 2008 at 9:56</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-17690" href="/posts/17690/revisions" title="show revision history for this post"> Peter Stuifzand </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-17690" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="17690" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-17690" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="3125367"></a> <div id="answer-3125367" class="answer js-answer" data-answerid="3125367" data-parentid="1669" data-score="8" data-position-on-page="20" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="3125367" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-3125367" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:ef0c408be0b215ba,10:1740274359,16:80556773b189bb26,7:3125367,508955c95e3d9fe5bd3442203156bbf7013a2d030bee8ccc8e2b2fe5d253742b" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="8"> 8 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:cc6efc105e004727,10:1740274359,16:c919ea697296e649,7:3125367,55f0b9c83b4f536158f81b31df5f2888be5064c28e0f418168e849ef5c84916f" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-3125367" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="3125367" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/3125367/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>From the <a href="http://www.faqs.org/faqs/compilers/faq/" rel="noreferrer">comp.compilers FAQ</a>:</p> <p>"Programming a Personal Computer" by Per Brinch Hansen Prentice-Hall 1982 ISBN 0-13-730283-5</p> <p>This unfortunately-titled book explains the design and creation of a single-user programming environment for micros, using a Pascal-like language called Edison. The author presents all source code and explanations for the step-by-step implementation of an Edison compiler and simple supporting operating system, all written in Edison itself (except for a small supporting kernel written in a symbolic assembler for PDP 11/23; the complete source can also be ordered for the IBM PC).</p> <p>The most interesting things about this book are: 1) its ability to demonstrate how to create a complete, self-contained, self-maintaining, useful compiler and operating system, and 2) the interesting discussion of language design and specification problems and trade-offs in Chapter 2.</p> <p>"Brinch Hansen on Pascal Compilers" by Per Brinch Hansen Prentice-Hall 1985 ISBN 0-13-083098-4</p> <p>Another light-on-theory heavy-on-pragmatics here's-how-to-code-it book. The author presents the design, implementation, and complete source code for a compiler and p-code interpreter for Pascal- (Pascal "minus"), a Pascal subset with boolean and integer types (but no characters, reals, subranged or enumerated types), constant and variable definitions and array and record types (but no packed, variant, set, pointer, nameless, renamed, or file types), expressions, assignment statements, nested procedure definitions with value and variable parameters, if statements, while statements, and begin-end blocks (but no function definitions, procedural parameters, goto statements and labels, case statements, repeat statements, for statements, and with statements).</p> <p>The compiler and interpreter are written in Pascal* (Pascal "star"), a Pascal subset extended with some Edison-style features for creating software development systems. A Pascal* compiler for the IBM PC is sold by the author, but it's easy to port the book's Pascal- compiler to any convenient Pascal platform.</p> <p>This book makes the design and implementation of a compiler look easy. I particularly like the way the author is concerned with quality, reliability, and testing. The compiler and interpreter can easily be used as the basis for a more involved language or compiler project, especially if you're pressed to quickly get something up and running. </p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2010-06-26T20:17:04"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="3125367" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/3125367" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/3125367/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-3125367" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:6a33a8ca989a2584,10:1740274359,16:922a8a7fbbeb1cb0,7:3125367,5311a1e08a2bc35a3d826274d85150d060f1e4a8e496c226793b942a9edb8060" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/3125367/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2010-06-27 19:00:38Z' class='relativetime'>Jun 27, 2010 at 19:00</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Jun 26, 2010 at 20:17. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-3125367" href="/posts/3125367/revisions" title="show revision history for this post"> 2 revs<br><a href="/users/357174">joe snyder</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-3125367" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="3125367" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-3125367" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="172181"></a> <div id="answer-172181" class="answer js-answer" data-answerid="172181" data-parentid="1669" data-score="8" data-position-on-page="21" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="172181" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-172181" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="68:3:31e,16:73552bc6bb4311ad,10:1740274359,16:b2761bede02021ec,6:172181,6da19afc11c0f6e0aeeafe634b8f0ac75544b615581ae296db50fc42d1127afa" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="8"> 8 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="68:3:31e,16:2458885eb3704e29,10:1740274359,16:a11c9762b83f338d,6:172181,7d06fcdc11dae642800bf1307ed68ac6595f4b17f3b246fc1acf8b4da85f5eb8" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-172181" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="172181" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/172181/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>You should check out Darius Bacon's "<a href="https://github.com/darius/ichbins" rel="nofollow noreferrer" title="I can hardly believe it's not Scheme">ichbins</a>", which is a compiler for a small Lisp dialect, targeting C, in just over 6 pages of code. The advantage it has over most toy compilers is that the language is complete enough that the compiler is written in it. (The tarball also includes an interpreter to bootstrap the thing.)</p> <p>There's more stuff about what I found useful in learning to write a compiler on my <a href="http://www.canonical.org/~kragen/sw/urscheme/" rel="nofollow noreferrer" title="a small self-hosted Scheme to x86 asm compiler">Ur-Scheme</a> web page.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-10-05T16:00:52"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="172181" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/172181" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/172181/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-172181" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="68:3:31e,16:8db0b15232e82da1,10:1740274359,16:531249888a4e6fb5,6:172181,147e744f53861efcd2d43a5107d04ce06f72917e86c9242eb2d8066960f029ad" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/172181/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2010-12-01 12:50:57Z' class='relativetime'>Dec 1, 2010 at 12:50</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 5, 2008 at 16:00. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-172181" href="/posts/172181/revisions" title="show revision history for this post"> 2 revs, 2 users 89%<br>Kragen Javier Sitaker </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-172181" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="172181" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-172181" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="8690"></a> <div id="answer-8690" class="answer js-answer" data-answerid="8690" data-parentid="1669" data-score="7" data-position-on-page="22" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="8690" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-8690" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="66:3:31e,16:a34fd33fbfd99da2,10:1740274359,16:79dcd24d78660501,4:8690,0979cdd7ac38f09f2325b17340f273712c5c0b7198ae684beb0ea7b0b918293b" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="7"> 7 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="66:3:31e,16:9cdacd21c157d67b,10:1740274359,16:195e1c298a2c33b4,4:8690,2edd35fa8a6b93ecf757b9ec2e5b938cc9643e1c473ca12361c9b7ee928ddd5b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-8690" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="8690" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/8690/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Python comes bundled with a python compiler written in Python. You can see the source code, and it includes all phases, from parsing, abstract syntax tree, emitting code, etc. Hack it.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-12T11:25:34"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="8690" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/8690" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/8690/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-8690" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="66:3:31e,16:33527b463b2fb7f1,10:1740274359,16:62abfd104fe4319b,4:8690,3cb8b6e81c015038064496f75af4efe0d0394495451f0cf3c7263aaa18415390" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/8690/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-08-12 11:25:34Z' class='relativetime'>Aug 12, 2008 at 11:25</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-8690" href="/posts/8690/revisions" title="show revision history for this post"> yeruham </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-8690" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="8690" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-8690" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="789357"></a> <div id="answer-789357" class="answer js-answer" data-answerid="789357" data-parentid="1669" data-score="7" data-position-on-page="23" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="789357" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-789357" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="68:3:31e,16:4dba8e1ad8c31e2a,10:1740274359,16:6718be86001b578f,6:789357,6d136ab94670100b23810ebd917ad3d986959c378bbcb8243577faa86d952df3" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="7"> 7 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="68:3:31e,16:638c0f564927bc22,10:1740274359,16:ad0f33535d32f701,6:789357,4952ca7a0970de3d3da587f11d3395e56419715e5082aea5f8fe5ea212e102c7" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-789357" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="789357" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/789357/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Sorry, it is in Spanish, but this is the bibliography of a course called "Compiladores e Intérpretes" (Compilers and Interpreters) in Argentina. </p> <p>The course was from formal language theory to compiler construction, and these are the topics you need to build, at least, a simple compiler:</p> <blockquote> <ul> <li><p>Compilers Design in C. <br /> Allen I. Holub <br /><br> Prentice-Hall. 1990.</p></li> <li><p>Compiladores. Teoría y Construcción. <br /> Sanchís Llorca, F.J. , Galán Pascual, C. Editorial Paraninfo. 1988.</p></li> <li><p>Compiler Construction. <br /> Niklaus Wirth <br /><br> Addison-Wesley. 1996.</p></li> <li><p>Lenguajes, Gramáticas y Autómatas. Un enfoque práctico. <br /> Pedro Isasi Viñuela, Paloma Martínez Fernández, Daniel Borrajo Millán. Addison-Wesley Iberoamericana (España). 1997.</p></li> <li><p>The art of compiler design. Theory and practice. <br /> Thomas Pittman, James Peters. <br /><br> Prentice-Hall. 1992.</p></li> <li><p>Object-Oriented Compiler Construction. <br /> Jim Holmes. <br /> Prentice Hall, Englewood Cliffs, N.J. 1995</p></li> <li><p>Compiladores. Conceptos Fundamentales. <br /> B. Teufel, S. Schmidt, T. Teufel. <br /><br> Addison-Wesley Iberoamericana. 1995.</p></li> <li><p>Introduction to Automata Theory, Languages, and Computation. <br /><br> John E. Hopcroft. Jeffref D. Ullman. <br /> Addison-Wesley. 1979.</p></li> <li><p>Introduction to formal languages. <br /> György E. Révész. <br /><br> Mc Graw Hill. 1983.</p></li> <li><p>Parsing Techniques. A Practical Guide. <br /> Dick Grune, Ceriel Jacobs. <br /> Impreso por los autores. 1995<br> <a href="http://www.cs.vu.nl/~dick/PTAPG.html" rel="nofollow noreferrer">http://www.cs.vu.nl/~dick/PTAPG.html</a></p></li> <li><p>Yacc: Yet Another Compiler-Compiler. <br /> Stephen C. Johnson <br /> Computing Science Technical Report Nº 32, 1975. Bell Laboratories. Murray Hill, New<br> Jersey.</p></li> <li><p>Lex: A Lexical Analyzer Generator. <br /> M. E. Lesk, E. Schmidt. Computing Science Technical Report Nº 39, 1975. Bell Laboratories. Murray Hill, New Jersey.</p></li> <li><p>lex & yacc. <br /> John R. Levine, Tony Mason, Doug Brown. <br /> O’Reilly & Associates. 1995.</p></li> <li><p>Elements of the theory of computation. <br /> Harry R. Lewis, Christos H. Papadimitriou. Segunda Edición. Prentice Hall. 1998. </p></li> <li><p>Un Algoritmo Eficiente para la Construcción del Grafo de Dependencia de Control.<br/> Salvador V. Cavadini.<br> Trabajo Final de Grado para obtener el Título de Ingeniero en Computación.<br> Facultad de Matemática Aplicada. U.C.S.E. 2001.</p></li> </ul> </blockquote> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-04-25T17:23:55"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="789357" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/789357" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/789357/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-789357" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="68:3:31e,16:a346f41d03ac2d71,10:1740274359,16:b0a1f704a9e68837,6:789357,dfec527026815d0c4b9fe21bb89619a17d8e10b0b07d27277170b28a16e8e9fa" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/789357/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2014-02-28 23:52:55Z' class='relativetime'>Feb 28, 2014 at 23:52</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Apr 25, 2009 at 17:23. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-789357" href="/posts/789357/revisions" title="show revision history for this post"> 2 revs, 2 users 98%<br><a href="/users/32173">eKek0</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-789357" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="789357" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-789357" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1156383"></a> <div id="answer-1156383" class="answer js-answer" data-answerid="1156383" data-parentid="1669" data-score="7" data-position-on-page="24" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1156383" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1156383" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:cb238827f0b17bd0,10:1740274359,16:3cf335d74c75d947,7:1156383,675e2ebcdc6f2254c4264de51bc5557dbae13cc1996d0cb489dc5dda2bee28ef" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="7"> 7 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:7f332db47e994476,10:1740274359,16:8b71935044d7c417,7:1156383,6264165d89b29c052e375f4e7c6d497f99a258b51d21eda975486022b9b075fb" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1156383" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1156383" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1156383/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <ol> <li>This is a vast subject. Do not underestimate this point. And do not underestimate my point to not underestimate it.</li> <li>I hear the <a href="http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools" rel="nofollow noreferrer">Dragon Book</a> is a (the?) place to start, along with searching. :) Get better at searching, eventually it will be your life.</li> <li>Building your own programming language is absolutely a good exercise! But know that it will never be used for any practical purpose in the end. Exceptions to this are few and <em>very</em> far between.</li> </ol> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-07-20T22:44:40"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1156383" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1156383" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1156383/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1156383" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:6db0a1364f47f30e,10:1740274359,16:5e5374f1c45afbbf,7:1156383,000473495ce69d917c2971f2e94ddfe1688f568aa7a18f18cd3566dcb2ac1a20" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1156383/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2014-02-28 23:54:22Z' class='relativetime'>Feb 28, 2014 at 23:54</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Sep 2, 2010 at 17:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1156383" href="/posts/1156383/revisions" title="show revision history for this post"> 2 revs, 2 users 73%<br><a href="/users/138304">280Z28</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">9</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1156383" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1156383" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="4" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-975348" class="comment js-comment " data-comment-id="975348" data-comment-owner-id="-1" data-comment-score="5"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="warm">5</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">If you haven't read the Dragon book. Please don't recommend it. In fact, have you ever implemented a compiler?</span> <div class="d-inline-flex ai-center"> – <span class="comment-user">anon</span> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-07-20 22:46:24Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jul 20, 2009 at 22:46</span> </span> </div> </div> </li> <li id="comment-975356" class="comment js-comment " data-comment-id="975356" data-comment-owner-id="134547" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Yeah, as the name implies, the Dragon Book is a monster. Very in-depth, but a very good resource nonetheless. I wouldn't recommend it for beginners, though...</span> <div class="d-inline-flex ai-center"> – <a href="/users/134547/zachary-murray" title="1,220 reputation" class="comment-user">Zachary Murray</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-07-20 22:47:51Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jul 20, 2009 at 22:47</span> </span> </div> </div> </li> <li id="comment-975363" class="comment js-comment " data-comment-id="975363" data-comment-owner-id="138304" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">@Neil: You haven't google'd me, have you? lol. <a href="http://blog.280z28.org/" rel="nofollow noreferrer">blog.280z28.org</a> But no, I haven't read that book.</span> <div class="d-inline-flex ai-center"> – <a href="/users/138304/sam-harwell" title="99,949 reputation" class="comment-user">Sam Harwell</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-07-20 22:49:48Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jul 20, 2009 at 22:49</span> </span> </div> </div> </li> <li id="comment-975389" class="comment js-comment " data-comment-id="975389" data-comment-owner-id="43992" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">I'm reading it (the dragon book) presently, and also Lex/Yacc at the same time, I'm finding the book quite good. Personally.</span> <div class="d-inline-flex ai-center"> – <a href="/users/43992/simeon-pilgrim" title="26,043 reputation" class="comment-user">Simeon Pilgrim</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-07-20 22:58:10Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jul 20, 2009 at 22:58</span> </span> </div> </div> </li> <li id="comment-975423" class="comment js-comment " data-comment-id="975423" data-comment-owner-id="138304" data-comment-score="1"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">1</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">To be fair, I prefaced it with "I hear...". :) #1 and #3 are the points I feel are extremely important to know going in but aren't mentioned as often.</span> <div class="d-inline-flex ai-center"> – <a href="/users/138304/sam-harwell" title="99,949 reputation" class="comment-user">Sam Harwell</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2009-07-20 23:07:39Z, License: CC BY-SA 2.5' class='relativetime-clean'>Jul 20, 2009 at 23:07</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1156383" data-rep=50 data-anon=true> <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button"></a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link " title="Expand to show all comments on this post" href=# onclick="" role="button">Show <b>4</b> more comments</a> </div> </div> </div> </div> <a name="1344367"></a> <div id="answer-1344367" class="answer js-answer" data-answerid="1344367" data-parentid="1669" data-score="6" data-position-on-page="25" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1344367" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1344367" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:22af7cdc43ad3d85,10:1740274359,16:cc803fa884faec67,7:1344367,1d11f8ddf348e3cc83c645e9c9e18be9677c0caed857396193a16cf7af31a38a" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="6"> 6 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:8d45aa1ad339eca4,10:1740274359,16:8017cdc3f5448cdc,7:1344367,e0b35caaef3b084340f76b2c9a1e268b801ba55f1203f0d8ea474885bed277e3" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1344367" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1344367" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1344367/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Not a book, but a technical paper and an enormously fun learning experience if you want to know more about compilers (and metacompilers)... This website walks you through building a completely self-contained compiler system that can compile itself and other languages:</p> <p><em><a href="http://www.bayfronttechnologies.com/mc_tutorial.html" rel="nofollow noreferrer">Tutorial: Metacompilers Part 1</a></em></p> <p>This is all based on an amazing little 10-page technical paper:</p> <p><i>Val Schorre</i> <b>META II: A Syntax-Oriented Compiler Writing Language</b></p> <p>from honest-to-god 1964. I learned how to build compilers from this back in 1970. There's a mind-blowing moment when you finally grok how the compiler can regenerate itself....</p> <p>I know the website author from my college days, but I have nothing to do with the website.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-08-28T00:01:07"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1344367" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1344367" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1344367/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1344367" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:b0cdc1741d08fcdf,10:1740274359,16:ca9dd21cefea407f,7:1344367,12c86dfe80e666ca4dfb959e4ff6ef9b452dd198dd09f2cd190d0c0b16832694" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/1344367/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2014-03-01 00:09:29Z' class='relativetime'>Mar 1, 2014 at 0:09</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Aug 28, 2009 at 0:01. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1344367" href="/posts/1344367/revisions" title="show revision history for this post"> 4 revs, 2 users 77%<br><a href="/users/120163">Ira Baxter</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">2</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1344367" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="1344367" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-37511137" class="comment js-comment " data-comment-id="37511137" data-comment-owner-id="927333" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">As others say, is BIG argument, I think sushi a task is a final work for bachelor, it requires to know a LOT of concepts of math, computer science and so on.</span> <div class="d-inline-flex ai-center"> – <a href="/users/927333/ingconti" title="11,646 reputation" class="comment-user">ingconti</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2014-06-18 06:10:43Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jun 18, 2014 at 6:10</span> </span> </div> </div> </li> <li id="comment-37524762" class="comment js-comment " data-comment-id="37524762" data-comment-owner-id="120163" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">If you don't know these topics, you shouldn't really be trying to build a serious compiler. However, if you have 2-3 years undergraduate computer science education (programming, data structures, assembly language), the MetaII paper will work for you.</span> <div class="d-inline-flex ai-center"> – <a href="/users/120163/ira-baxter" title="95,392 reputation" class="comment-user">Ira Baxter</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2014-06-18 12:23:51Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jun 18, 2014 at 12:23</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-1344367" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="98010"></a> <div id="answer-98010" class="answer js-answer" data-answerid="98010" data-parentid="1669" data-score="6" data-position-on-page="26" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="98010" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-98010" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:ba0783b0ccc2a9aa,10:1740274359,16:2303fa239f932487,5:98010,59e3fb1a89c80cdf23fe3b26cb58570ebeaf395e37e071231cdd9229283153e1" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="6"> 6 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:db045f4c68902185,10:1740274359,16:a1a29309e7bf61ee,5:98010,33bb1c22f882024a988528b1a805ac4d81482623469a3a1b0d1cdbde55e6307f" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-98010" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="98010" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/98010/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>There's a lot of good answers here, so i thought I'd just add one more to the list:</p> <p>I got a book called Project Oberon more than a decade ago, which has some very well written text on the compiler. The book really stands out in the sense that the source and explanations is very hands on and readable. The complete text (the 2005 edition) has been made available in pdf, so you can download right now. The compiler is discussed in chapter 12:</p> <p><a href="http://www.ethoberon.ethz.ch/WirthPubl/ProjectOberon.pdf" rel="nofollow noreferrer">http://www.ethoberon.ethz.ch/WirthPubl/ProjectOberon.pdf</a></p> <p>Niklaus Wirth, Jürg Gutknecht</p> <p>(The treatment is not as extensive as his book on compilers)</p> <p>I've read several books on compilers, and i can second the dragon book, time spent on this book is very worthwhile.</p> <p><strong>Edit</strong>:</p> <p>As of July 2024, the original link no longer seems to work. However, the 1st and 2nd editions (2005 and 2013, resp.)) can still be obtained through</p> <p><a href="https://people.inf.ethz.ch/wirth/ProjectOberon1992.pdf" rel="nofollow noreferrer">https://people.inf.ethz.ch/wirth/ProjectOberon1992.pdf</a> <a href="https://people.inf.ethz.ch/wirth/ProjectOberon/index.html" rel="nofollow noreferrer">https://people.inf.ethz.ch/wirth/ProjectOberon/index.html</a></p> <p>or the Prof. Wirth's university page:</p> <p><a href="https://people.inf.ethz.ch/wirth/" rel="nofollow noreferrer">https://people.inf.ethz.ch/wirth/</a></p> <p>(Note that Prof. Wirth has deceased in January 2024, so the address might change again or be removed altogether).</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-09-18T23:31:14"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="98010" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/98010" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f4.0%2f" data-se-share-sheet-license-name="CC BY-SA 4.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/98010/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-98010" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:322000961b4c2bd4,10:1740274359,16:73beb06da002d585,5:98010,d4885ed7a7449846a4368e8699786b6513deb432c914a86551816f828100cc1d" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/98010/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2024-07-11 16:58:04Z' class='relativetime'>Jul 11, 2024 at 16:58</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-98010" href="/posts/98010/revisions" title="show revision history for this post"> 5 revs, 3 users 63%<br><a href="/users/12677">tovare</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-98010" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="98010" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-98010" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="22718"></a> <div id="answer-22718" class="answer js-answer" data-answerid="22718" data-parentid="1669" data-score="5" data-position-on-page="27" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="22718" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-22718" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="67:3:31e,16:15f96153ccca3e0e,10:1740274359,16:24e7a80fa82ffe3d,5:22718,cfd2b1ac6074990345a5e293257ce1a90f1406615278fbe056a7ae08feb89ebd" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="5"> 5 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="67:3:31e,16:020dc373d789e19d,10:1740274359,16:cdea1dab885e8bd8,5:22718,caf36411a1285acbba4ed4c0e643d056cf6a80032da7fe08f4989662bf2727d2" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-22718" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="22718" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/22718/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I liked the <A HREF="http://compilers.iecc.com/crenshaw/" rel="nofollow noreferrer">Crenshaw tutorial</A> too, because it makes it absolutely clear that a compiler is just another program that reads some input and writes some out put. </p> <p>Read it. </p> <p>Work it if you want, but then look at another reference on how bigger and more complete compilers are really written.</p> <p>And read <A href="http://cm.bell-labs.com/who/ken/trust.html" rel="nofollow noreferrer">On Trusting Trust</A>, to get a clue about the unobvious things that can be done in this domain.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-08-22T15:57:16"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="22718" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/22718" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/22718/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-22718" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="67:3:31e,16:185aec3339f4cc90,10:1740274359,16:4d78fba2ab40357a,5:22718,3add18407f7f9a45de1c3ec54619da4f8cd3c179902e8c6c7ea24eafd0634f7c" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/22718/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2008-09-02 04:52:41Z' class='relativetime'>Sep 2, 2008 at 4:52</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-22718" href="/posts/22718/revisions" title="show revision history for this post"> 2 revs<br><a href="/users/2509">dmckee</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-22718" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="22718" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-22718" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="156867"></a> <div id="answer-156867" class="answer js-answer" data-answerid="156867" data-parentid="1669" data-score="5" data-position-on-page="28" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="156867" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-156867" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="68:3:31e,16:d879f880d7cc8536,10:1740274359,16:486bb8cdc57d43d6,6:156867,620f29848d2d6a463b9ad5f943f7c2d1a8db06998616927b0954e3360850d3de" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="5"> 5 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="68:3:31e,16:8d37dda15a47d074,10:1740274359,16:92aef308a300010e,6:156867,a3f57aea2970afcfb95337a55aa3ce3148202ea791328c365cfb4d5283320a76" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-156867" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="156867" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/156867/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>If you are interested in writing a compiler for a functional language (rather than a procedural one) Simon Peyton-Jones and David Lester's "<a href="http://research.microsoft.com/~simonpj/papers/pj-lester-book/" rel="noreferrer">Implementing functional languages: a tutorial</a>" is an excellent guide. </p> <p>The conceptual basics of how functional evaluation works is guided by examples in a simple but powerful functional language called "Core". Additionally, each part of the Core language compiler is explained with code examples in Miranda (a pure functional language very similar to Haskell). </p> <p>Several different types of compilers are described but even if you only follow the so-called template compiler for Core you will have an excellent understanding of what makes functional programming tick. </p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2008-10-01T09:30:26"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="156867" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/156867" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/156867/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-156867" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="68:3:31e,16:4bd0a80b5e134aa5,10:1740274359,16:62479b21c168dbfb,6:156867,2a7eede93d35622a2e93fae3a6fe57e754b4b246ad99844aa70920c160818c86" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/156867/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2008-10-01 09:30:26Z' class='relativetime'>Oct 1, 2008 at 9:30</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Oct 1, 2008 at 9:30. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-156867" href="/posts/156867/revisions" title="show revision history for this post"> Mark Reid </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-156867" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="156867" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-156867" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="6695987"></a> <div id="answer-6695987" class="answer js-answer" data-answerid="6695987" data-parentid="1669" data-score="5" data-position-on-page="29" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="6695987" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-6695987" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:b292af5075a9ae70,10:1740274359,16:4d60ac4df1c3f633,7:6695987,496cfffbce91ae2c356b99334779dddff2ed7c4b614d8cc3f8dcfe39ac42409f" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="5"> 5 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:cfce58b9a47bb217,10:1740274359,16:79b0d95734abebc8,7:6695987,153d3eab50916446fbbfd76ad5b5e29daa8640017e3ae27a272988bd84430e0b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-6695987" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="6695987" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/6695987/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>You can use <a href="http://jakarta.apache.org/bcel/" rel="noreferrer">BCEL</a> by the Apache Software Foundation. With this tool you can generate assembler-like code, but it's Java with the BCEL API. You can learn how you can generate intermediate language code (in this case byte code).</p> <h3>Simple example</h3> <ol> <li><p>Create a Java class with this function:</p> <pre><code>public String maxAsString(int a, int b) { if (a > b) { return Integer.valueOf(a).toString(); } else if (a < b) { return Integer.valueOf(b).toString(); } else { return "equals"; } } </code></pre></li> </ol> <p>Now run BCELifier with this class</p> <pre><code>BCELifier bcelifier = new BCELifier("MyClass", System.out); bcelifier.start(); </code></pre> <p>You can see the result on the console for the whole class (how to build byte code MyClass.java). The code for the function is this:</p> <pre><code>private void createMethod_1() { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(ACC_PUBLIC, Type.STRING, new Type[] { Type.INT, Type.INT }, new String[] { "arg0", "arg1" }, "maxAsString", "MyClass", il, _cp); il.append(InstructionFactory.createLoad(Type.INT, 1)); // Load first parameter to address 1 il.append(InstructionFactory.createLoad(Type.INT, 2)); // Load second parameter to adress 2 BranchInstruction if_icmple_2 = InstructionFactory.createBranchInstruction(Constants.IF_ICMPLE, null); // Do if condition (compare a > b) il.append(if_icmple_2); il.append(InstructionFactory.createLoad(Type.INT, 1)); // Load value from address 1 into the stack il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC)); il.append(_factory.createInvoke("java.lang.Integer", "toString", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.append(InstructionFactory.createReturn(Type.OBJECT)); InstructionHandle ih_13 = il.append(InstructionFactory.createLoad(Type.INT, 1)); il.append(InstructionFactory.createLoad(Type.INT, 2)); BranchInstruction if_icmpge_15 = InstructionFactory.createBranchInstruction(Constants.IF_ICMPGE, null); // Do if condition (compare a < b) il.append(if_icmpge_15); il.append(InstructionFactory.createLoad(Type.INT, 2)); il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC)); il.append(_factory.createInvoke("java.lang.Integer", "toString", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.append(InstructionFactory.createReturn(Type.OBJECT)); InstructionHandle ih_26 = il.append(new PUSH(_cp, "equals")); // Return "equals" string il.append(InstructionFactory.createReturn(Type.OBJECT)); if_icmple_2.setTarget(ih_13); if_icmpge_15.setTarget(ih_26); method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); } </code></pre> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2011-07-14T15:42:33"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="6695987" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/6695987" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/6695987/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-6695987" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:058e5c4de4c53aea,10:1740274359,16:d4b954afd61f4aa8,7:6695987,116221cb815126cfa26c35fa7a1d09684b5b7c99bc9b3a182dea88937e77325a" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/6695987/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2014-03-01 00:06:24Z' class='relativetime'>Mar 1, 2014 at 0:06</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Jul 14, 2011 at 15:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-6695987" href="/posts/6695987/revisions" title="show revision history for this post"> 2 revs, 2 users 82%<br><a href="/users/736518">timaschew</a> </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-6695987" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="6695987" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-6695987" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="1156689"></a> <div id="answer-1156689" class="answer js-answer" data-answerid="1156689" data-parentid="1669" data-score="4" data-position-on-page="30" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="1156689" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-1156689" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="69:3:31e,16:6ee605d83396f8f9,10:1740274359,16:496db8b9e28bbfde,7:1156689,bb752686fe7fa65274eed09e146f991194fc3f93338254e307c218b11008a269" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="4"> 4 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="69:3:31e,16:7adadcde051446bf,10:1740274359,16:55604dfe06c4a0fd,7:1156689,64a16d0851d964b2179544ddce3fffd5de42c99b2bdbd1998c6894857034e340" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-1156689" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="1156689" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/1156689/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I'm surprised it hasn't been mentioned, but Donald Knuth's <em>The Art of Computer Programming</em> was originally penned as a sort of tutorial on compiler writing.</p> <p>Of course, Dr. Knuth's propensity for going in-depth on topics has led to the compiler-writing tutorial being expanded to an estimated 9 volumes, only three of which have actually been published. It's a rather complete exposition on programming topics, and covers everything you would ever need to know about writing a compiler, in minute detail.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2009-07-21T00:20:14"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="1156689" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/1156689" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f2.5%2f" data-se-share-sheet-license-name="CC BY-SA 2.5" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/1156689/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-1156689" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="69:3:31e,16:d24ec7a40cb7ca97,10:1740274359,16:d246ac4aa432f502,7:1156689,4b83c266d7dc0decf5aef2887905dd959205e58cad1abaedb39bd36193226ace" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <a href="/posts/1156689/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })"><span title='2009-07-21 00:20:14Z' class='relativetime'>Jul 21, 2009 at 0:20</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info"> <div class="user-details"> <span class="community-wiki" title="This post is community owned as of Sep 2, 2010 at 17:42. Votes do not generate reputation, and it can be edited by users with 100 rep"> community wiki </span> </div><br> <div class="user-details"> <a id="history-1156689" href="/posts/1156689/revisions" title="show revision history for this post"> greyfade </a> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-1156689" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="1156689" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-1156689" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <div class="s-pagination site1 themed pager-answers"> <div class="s-pagination--item is-selected" aria-current="page">1</div> <a class="s-pagination--item js-pagination-item" href="/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top" rel="" title="Go to page 2">2</a> <a class="s-pagination--item js-pagination-item" href="/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top" rel="next" title="Go to page 2"> Next</a></div> <h2 class="bottom-notice" data-loc="1"> <div> Not the answer you're looking for? Browse other questions tagged <ul class='ml0 list-ls-none js-post-tag-list-wrapper d-inline'><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/compiler-construction" class="s-tag post-tag" title="show questions tagged 'compiler-construction'" aria-label="show questions tagged 'compiler-construction'" rel="tag" aria-labelledby="tag-compiler-construction-tooltip-container" data-tag-menu-origin="Unknown">compiler-construction</a></li><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/language-agnostic" class="s-tag post-tag" title="show questions tagged 'language-agnostic'" aria-label="show questions tagged 'language-agnostic'" rel="tag" aria-labelledby="tag-language-agnostic-tooltip-container" data-tag-menu-origin="Unknown">language-agnostic</a></li></ul> or <a href="/questions/ask">ask your own question</a>. </div> </h2> </div> </div> <div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar"> <div class="s-sidebarwidget s-sidebarwidget__yellow s-anchors s-anchors__grayscale mb16" data-tracker="cb=1"> <ul class="s-sidebarwidget--content s-sidebarwidget__items p0"> <li class="s-sidebarwidget--header"> The Overflow Blog </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://stackoverflow.blog/2025/02/21/one-quality-every-engineering-manager-should-have-empathy/" class="js-gps-track" data-ga="["community bulletin board","The Overflow Blog","https://stackoverflow.blog/2025/02/21/one-quality-every-engineering-manager-should-have-empathy/",null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 0, location: questionpage })">One quality every engineering manager should have? Empathy.</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://stackoverflow.blog/2025/02/20/research-roadmap-update-february-2025/" class="js-gps-track" data-ga="["community bulletin board","The Overflow Blog","https://stackoverflow.blog/2025/02/20/research-roadmap-update-february-2025/",null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 1, location: questionpage })">Research roadmap update, February 2025</a> </div> </li> <li class="s-sidebarwidget--header"> Featured on Meta </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing" class="js-gps-track" data-ga="["community bulletin board","Featured on Meta","https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing",null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 2, location: questionpage })">Stacks Editor development and testing</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak" class="js-gps-track" title="Is it better to redirect users who attempt to perform actions they can't yet take?" data-ga="["community bulletin board","Featured on Meta","https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak",null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 3, location: questionpage })">Is it better to redirect users who attempt to perform actions they can't yet...</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned" class="js-gps-track" data-ga="["community bulletin board","Featured on Meta","https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned",null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 4, location: questionpage })">Policy: Generative AI (e.g., ChatGPT) is banned</a> </div> </li> </ul> </div> <div class="js-zone-container zone-container-sidebar"> <div id="dfp-tsb" class="everyonelovesstackoverflow everyoneloves__top-sidebar"></div> <div class="js-report-ad-button-container " style="width: 300px"></div> </div> <div class="js-zone-container zone-container-sidebar"> <div id="dfp-msb" class="everyonelovesstackoverflow everyoneloves__mid-sidebar"></div> <div class="js-report-ad-button-container " style="width: 300px"></div> </div> <div id="hireme"></div> <div class="s-sidebarwidget mb16 module"> <div class="s-sidebarwidget--header d-flex ai-center pb16"> <a href="https://chat.stackoverflow.com/" class="js-chat-ad-link">Visit chat</a> </div> <div class="s-sidebarwidget--content s-sidebarwidget__items d-none js-chat-ad-rooms"></div> </div> <script> // <!-- StackExchange.ready(function () { var options = { chatUrl: 'https://chat.stackoverflow.com/', reloadUrl: '/api/recent-chat', preloadedData: null, tagBased: true, }; StackExchange.chatAd.init(options); }); // --> </script> <div class="module sidebar-linked"> <h4 id="h-linked">Linked</h4> <div class="linked" data-tracker="lq=1"> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 3662410, position: 0 })"> <a href="/q/3662410" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">36</div> </a> <a href="/questions/3662410/create-my-own-programming-language?noredirect=1" class="question-hyperlink">create my own programming language</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 3810119, position: 1 })"> <a href="/q/3810119" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">34</div> </a> <a href="/questions/3810119/how-to-go-about-making-your-own-programming-language?noredirect=1" class="question-hyperlink">How to go about making your own programming language?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 3946911, position: 2 })"> <a href="/q/3946911" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">16</div> </a> <a href="/questions/3946911/how-to-write-a-simple-compiler-in-c?noredirect=1" class="question-hyperlink">How to write a simple compiler in C/++?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 426239, position: 3 })"> <a href="/q/426239" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">13</div> </a> <a href="/questions/426239/parsers-and-compilers-for-dummies-where-to-start?noredirect=1" class="question-hyperlink">Parsers and Compilers for Dummies. Where to start?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 1129785, position: 4 })"> <a href="/q/1129785" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">5</div> </a> <a href="/questions/1129785/compiler-design?noredirect=1" class="question-hyperlink">compiler design</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 4091887, position: 5 })"> <a href="/q/4091887" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">6</div> </a> <a href="/questions/4091887/how-would-you-go-about-writing-a-simple-programming-language?noredirect=1" class="question-hyperlink">How would you go about writing a simple programming language?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 2923287, position: 6 })"> <a href="/q/2923287" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">8</div> </a> <a href="/questions/2923287/what-is-the-process-of-creating-an-interpreted-language?noredirect=1" class="question-hyperlink">What is the process of creating an interpreted language?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 6361462, position: 7 })"> <a href="/q/6361462" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">7</div> </a> <a href="/questions/6361462/where-to-start-if-i-want-to-understand-how-compilers-and-programming-languages-a?noredirect=1" class="question-hyperlink">Where to start if I want to understand how compilers and programming languages are made</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 2034221, position: 8 })"> <a href="/q/2034221" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">2</div> </a> <a href="/questions/2034221/how-can-i-write-a-quick-and-dirty-interpreter?noredirect=1" class="question-hyperlink">How can I write a quick and dirty interpreter?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 1669, target_question_id: 6865026, position: 9 })"> <a href="/q/6865026" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">5</div> </a> <a href="/questions/6865026/help-with-compiler-design?noredirect=1" class="question-hyperlink">Help with Compiler Design</a> </div> <div class="spacer more ml32 pl16 pt8"> <a href="/questions/linked/1669">See more linked questions</a> </div> </div> </div> <div class="module sidebar-related"> <h4 id="h-related">Related</h4> <div class="related js-gps-related-questions" data-tracker="rq=1"> <div class="spacer" data-question-id="95635"> <a href="/q/95635" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted large">648</div> </a> <a href="/questions/95635/what-does-a-just-in-time-jit-compiler-do" class="question-hyperlink">What does a just-in-time (JIT) compiler do?</a> </div> <div class="spacer" data-question-id="3380498"> <a href="/q/3380498" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted large">102</div> </a> <a href="/questions/3380498/how-to-approach-creating-a-jvm-programming-language" class="question-hyperlink">How to approach creating a JVM programming language?</a> </div> <div class="spacer" data-question-id="9554418"> <a href="/q/9554418" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">7</div> </a> <a href="/questions/9554418/can-coco-r-turn-a-parsed-file-into-bytecode" class="question-hyperlink">Can Coco/R turn a parsed file into bytecode?</a> </div> <div class="spacer" data-question-id="2625261"> <a href="/q/2625261" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">9</div> </a> <a href="/questions/2625261/how-is-a-lattice-used-by-a-compiler" class="question-hyperlink">How is a lattice used by a compiler</a> </div> <div class="spacer" data-question-id="1380380"> <a href="/q/1380380" title="Question score (upvotes - downvotes)" > <div class="answer-votes default">4</div> </a> <a href="/questions/1380380/microsoft-cci-resources-references-for-writing-compilers" class="question-hyperlink">Microsoft CCI - resources, references for writing compilers</a> </div> </div> </div> <script type="text/javascript"> $(function() { $(".js-gps-related-questions .spacer").on("click", function () { fireRelatedEvent($(this).index() + 1, $(this).data('question-id')); }); function fireRelatedEvent(position, questionId) { StackExchange.using("gps", function() { StackExchange.gps.track('related_questions.click', { position: position, originQuestionId: 1669, relatedQuestionId: +questionId, location: 'sidebar', source: 'Baseline_Fallback' }); }); } }); </script> <div id="hot-network-questions" class="module tex2jax_ignore"> <h4> <a href="https://stackexchange.com/questions?tab=hot" class="js-gps-track s-link s-link__inherit" data-gps-track="posts_hot_network.click({ item_type:1, location:11 })"> Hot Network Questions </a> </h4> <ul> <li > <div class="favicon favicon-writing" title="Writing Stack Exchange"></div><a href="https://writing.stackexchange.com/questions/70882/writing-fiction-in-a-biblical-style" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:166 }); posts_hot_network.click({ item_type:2, location:11 })"> Writing Fiction in a Biblical Style </a> </li> <li > <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="https://politics.stackexchange.com/questions/90672/why-do-self-described-conservatives-use-the-term-gender-ideology-instead-of-tran" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:475 }); posts_hot_network.click({ item_type:2, location:11 })"> Why do self-described conservatives use the term gender ideology instead of trans ideology? </a> </li> <li > <div class="favicon favicon-retrocomputing" title="Retrocomputing Stack Exchange"></div><a href="https://retrocomputing.stackexchange.com/questions/31307/when-did-crt-monitors-become-common" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:648 }); posts_hot_network.click({ item_type:2, location:11 })"> When did CRT monitors become common? </a> </li> <li > <div class="favicon favicon-scifi" title="Science Fiction & Fantasy Stack Exchange"></div><a href="https://scifi.stackexchange.com/questions/295079/story-identification-man-kills-alien-who-is-in-great-pain-aliens-make-him-amba" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })"> Story identification: man kills alien who is in great pain. Aliens make him ambassador </a> </li> <li > <div class="favicon favicon-chemistry" title="Chemistry Stack Exchange"></div><a href="https://chemistry.stackexchange.com/questions/187521/why-can-t-rare-earth-elements-be-enriched-naturally" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:431 }); posts_hot_network.click({ item_type:2, location:11 })"> Why can’t rare earth elements be enriched naturally? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="https://tex.stackexchange.com/questions/737656/redefine-footnote" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })"> Redefine footnote </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-astronomy" title="Astronomy Stack Exchange"></div><a href="https://astronomy.stackexchange.com/questions/59485/are-solar-systems-formed-from-a-gas-centrifuge" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:514 }); posts_hot_network.click({ item_type:2, location:11 })"> Are solar systems formed from a gas centrifuge? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-diy" title="Home Improvement Stack Exchange"></div><a href="https://diy.stackexchange.com/questions/314879/how-can-i-buy-screwdrivers-that-are-useful-most-of-the-time" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:73 }); posts_hot_network.click({ item_type:2, location:11 })"> How can I buy screwdrivers that are useful most of the time? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-physics" title="Physics Stack Exchange"></div><a href="https://physics.stackexchange.com/questions/843579/does-experiencing-gravity-in-general-relativity-require-an-object-to-have-length" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:151 }); posts_hot_network.click({ item_type:2, location:11 })"> Does experiencing gravity in general relativity require an object to have length? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-codereview" title="Code Review Stack Exchange"></div><a href="https://codereview.stackexchange.com/questions/295427/simplified-simulation-of-unix-ls-command-made-using-c-stdfilesystem-librar" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:196 }); posts_hot_network.click({ item_type:2, location:11 })"> Simplified simulation of Unix "ls" command made using C++ std::filesystem library </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-bicycles" title="Bicycles Stack Exchange"></div><a href="https://bicycles.stackexchange.com/questions/96258/what-does-this-no-entry-sign-mean" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:126 }); posts_hot_network.click({ item_type:2, location:11 })"> What does this no entry sign mean? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="https://politics.stackexchange.com/questions/90700/why-didnt-trumps-executive-order-on-death-penalty-seek-death-penalty-for-major" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:475 }); posts_hot_network.click({ item_type:2, location:11 })"> Why didn't Trump's executive order on death penalty seek death penalty for major drug dealers? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="https://rpg.stackexchange.com/questions/214797/gloves-of-eldritch-admixture-is-the-charge-spent-if-you-miss-on-the-attack" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:122 }); posts_hot_network.click({ item_type:2, location:11 })"> Gloves of Eldritch Admixture, is the charge spent if you miss on the attack? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="https://tex.stackexchange.com/questions/737671/property-newnnnn-how-to-store-and-use-boolean-value" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })"> \property_new:nnnn , how to store and use boolean value? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-superuser" title="Super User"></div><a href="https://superuser.com/questions/1882024/imagemagick-only-trimming-one-side-how-can-i-trim-both" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:3 }); posts_hot_network.click({ item_type:2, location:11 })"> ImageMagick only trimming one side, how can I trim both? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-linguistics" title="Linguistics Stack Exchange"></div><a href="https://linguistics.stackexchange.com/questions/49789/what-is-the-current-status-in-2025-of-the-everett-chomsky-controversy-debate-r" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:312 }); posts_hot_network.click({ item_type:2, location:11 })"> What is the current status in 2025 of the Everett-Chomsky controversy / debate regarding Universal Grammar? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-bicycles" title="Bicycles Stack Exchange"></div><a href="https://bicycles.stackexchange.com/questions/96257/bora-one-carbon-brake-track-worn-out" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:126 }); posts_hot_network.click({ item_type:2, location:11 })"> Bora One carbon brake track worn out </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-mathematica" title="Mathematica Stack Exchange"></div><a href="https://mathematica.stackexchange.com/questions/311127/simplifying-a-trigonometric-expression-involving-arctan" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:387 }); posts_hot_network.click({ item_type:2, location:11 })"> Simplifying a trigonometric expression involving ArcTan </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-softwareengineering" title="Software Engineering Stack Exchange"></div><a href="https://softwareengineering.stackexchange.com/questions/456684/hiding-non-user-facing-executables-for-windows-applications" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:131 }); posts_hot_network.click({ item_type:2, location:11 })"> Hiding non-user-facing executables for Windows applications? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-japanese" title="Japanese Language Stack Exchange"></div><a href="https://japanese.stackexchange.com/questions/107177/is-%e3%81%82%e3%81%9f%e3%81%be%e3%81%ae%e8%9b%87%e5%8f%a3-an-idiom" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:257 }); posts_hot_network.click({ item_type:2, location:11 })"> Is あたまの蛇口 an idiom? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-electronics" title="Electrical Engineering Stack Exchange"></div><a href="https://electronics.stackexchange.com/questions/739636/where-exactly-does-the-resitance-come-from-voltage-source-question" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:135 }); posts_hot_network.click({ item_type:2, location:11 })"> Where exactly does the resitance come from? (Voltage Source Question) </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-movies" title="Movies & TV Stack Exchange"></div><a href="https://movies.stackexchange.com/questions/124563/movie-with-gun-that-creates-a-portal" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:367 }); posts_hot_network.click({ item_type:2, location:11 })"> Movie with gun that creates a portal </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="https://puzzling.stackexchange.com/questions/130619/what-is-the-angle-seven-circles-in-a-triangle" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })"> What is the angle? (seven circles in a triangle) </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-worldbuilding" title="Worldbuilding Stack Exchange"></div><a href="https://worldbuilding.stackexchange.com/questions/264835/slow-interstellar-wars" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:579 }); posts_hot_network.click({ item_type:2, location:11 })"> Slow Interstellar Wars </a> </li> </ul> <a href="#" class="show-more js-show-more js-gps-track" data-gps-track="posts_hot_network.click({ item_type:3, location:11 })"> more hot questions </a> </div> </div> </div> <script>StackExchange.ready(function(){$.get('/posts/1669/ivc/ad61?prg=7d10ab21-2404-42b3-8cfa-996058739490');});</script> <noscript><div><img src="/posts/1669/ivc/ad61?prg=7d10ab21-2404-42b3-8cfa-996058739490" class="dno" alt="" width="0" height="0"></div></noscript><div style="display:none" id="js-codeblock-lang"></div></div> <script defer src="https://cdn.sstatic.net/Js/questions/show.en.js?v=03feb8d88a8b"></script> <script type="application/json" data-role="module-args" data-module-name="entry-points/questions/show.mod">{"doMarkObsolete":false,"doTimeOnPage":false,"sendAnswerEditorEventsToAEH":true,"sendAnswerEditorEventsToPrizm":true,"questionId":1669,"sendAuthQuestionVisitToAEH":false,"sendAuthQuestionVisitToPrizm":false}</script> </div> </div> <script type="text/javascript"> var cam = cam || { opt: {} }; var clcGamLoaderOptions = cam || { opt: {} }; var opt = clcGamLoaderOptions.opt; opt.omni = 'BwoLCJLEgt3_7Ok9EAUYhQ0gAigCOil8Y29tcGlsZXItY29uc3RydWN0aW9ufGxhbmd1YWdlLWFnbm9zdGljfEgA-zCUEzZ5kNXaig'; opt.refresh = !1; opt.refreshInterval = 90; opt.sf = !0; opt.hb = !1; opt.ll = !0; opt.tlb_position = 0; opt.personalization_consent = !1; opt.targeting_consent = !1; opt.performance_consent = !1; opt.targeting = {Registered:['false'],Reputation:['new'],'so-tag':['compiler-construction','language-agnostic'],'tag-reportable':['compiler-construction','language-agnostic'],NumberOfAnswers:['20-plus'],cf_bot_score:'1'}; opt.adReportEnabled = !0; opt.adReportUrl = '/ads/report-ad'; opt.adReportText = 'Report this ad'; opt.adReportFileTypeErrorMessage = 'Please select a PNG or JPG file.'; opt.adReportFileSizeErrorMessage = 'The file must be under 2 MiB.'; opt.adReportErrorText = 'Error uploading ad report.'; opt.adReportThanksText = 'Thanks for your feedback. We’ll review this against our code of conduct and take action if necessary.'; opt.adReportLoginExpiredMessage = 'Your login session has expired, please login and try again.'; opt.adReportLoginErrorMessage = 'An error occurred when loading the report form - please try again'; opt.adReportModalClass = 'js-ad-report'; opt.countryCode = 'SG'; opt.qualtricsSurveyData = '{"isRegistered":"False","repBucket":"new","referrer":"https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler%2f1672","accountAge":"0"}'; opt.perRequestGuid = '7d10ab21-2404-42b3-8cfa-996058739490'; opt.responseHash = 'qniwIInGZSjC4q/6Gjtncja0CZH2na30K3TZzZ5Nd20='; opt.targeting.TargetingConsent = ['False_Passive']; opt.allowAccountTargetingForThisRequest = !1; const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('dfptestads')) { const dfptestads = urlParams.get('dfptestads'); opt.targeting.DfpTestAds = dfptestads; } </script> <script>;(()=>{"use strict";var __webpack_modules__={23:(e,t,s)=>{s.d(t,{Z7:()=>c,eq:()=>l,kG:()=>d});const n="248424177",o=(a=location.pathname,/^\/tags\//.test(a)||/^\/questions\/tagged\//.test(a)?"tag-pages":/^\/discussions\//.test(a)||/^\/beta\/discussions/.test(a)?"discussions":/^\/$/.test(a)||/^\/home/.test(a)?"home-page":/^\/jobs$/.test(a)||/^\/jobs\//.test(a)?"jobs":"question-pages");var a;let i=location.hostname;const r={slots:{lb:[[728,90]],mlb:[[728,90]],smlb:[[728,90]],bmlb:[[728,90]],sb:e=>"dfp-tsb"===e?[[300,250],[300,600]]:[[300,250]],"tag-sponsorship":[[730,135]],"mobile-below-question":[[320,50],[300,250]],msb:[[300,250],[300,600]],"talent-conversion-tracking":[[1,1]],"site-sponsorship":[[230,60]]},ids:{"dfp-tlb":"lb","dfp-mlb":"mlb","dfp-smlb":"smlb","dfp-bmlb":"bmlb","dfp-tsb":"sb","dfp-isb":"sb","dfp-tag":"tag-sponsorship","dfp-msb":"msb","dfp-sspon":"site-sponsorship","dfp-m-aq":"mobile-below-question"},idsToExcludeFromAdReports:["dfp-sspon"]};function d(){return Object.keys(r.ids)}function l(e){return r.idsToExcludeFromAdReports.indexOf(e)<0}function c(e,t){var s=e.split("_")[0];const a=r.ids[s];let d=r.slots[a];return"function"==typeof d&&(d=d(s)),{path:`/${n}/${t||i}/${a}/${o}`,sizes:d,zone:a}}},865:(e,t,s)=>{function n(e){return"string"==typeof e?document.getElementById(e):e}function o(e){return!!(e=n(e))&&"none"===getComputedStyle(e).display}function a(e){return!o(e)}function i(e){return!!e}function r(e){return/^\s*$/.test(n(e).innerHTML)}function d(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.display="none"}function l(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.display="none",[].forEach.call(e.children,l)}function c(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.removeProperty("display")}function g(e){const t=document.createElement("script");t.src=e,document.body.appendChild(t)}function p(e){return s=e,(t=[]).push=function(e){return s(),delete this.push,this.push(e)},t;var t,s}function h(e){let t="function"==typeof HTMLTemplateElement;var s=document.createElement(t?"template":"div");return e=e.trim(),s.innerHTML=e,t?s.content.firstChild:s.firstChild}s.d(t,{$Z:()=>c,Bv:()=>h,Gx:()=>g,Nj:()=>n,QZ:()=>p,cf:()=>d,pn:()=>a,wo:()=>l,xb:()=>r,xj:()=>o,yb:()=>i})},763:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{t:()=>AdReports});var _common_helper__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(865),_console__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(276),_ad_units__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(23);class AdReports{constructor(e,t){if(this.googletag=e,this.cam=t,this.allowedFileTypes=["image/png","image/jpg","image/jpeg"],this.ignoreValidation=!1,_console__WEBPACK_IMPORTED_MODULE_1__.cM("Ad reporting init"),this.cam=t,this.callOnButtonClick=e=>this.onButtonClick(e),this.googletag.pubads().addEventListener("slotRenderEnded",e=>this.handleSlotRendered(e)),Array.isArray(t.slotsRenderedEvents)){_console__WEBPACK_IMPORTED_MODULE_1__.cM("Adding report button to "+t.slotsRenderedEvents.length+" events that have transpired");for(var s=0;s<t.slotsRenderedEvents.length;s++)this.handleSlotRendered(t.slotsRenderedEvents[s])}}handleSlotRendered(e){if(e&&e.slot&&!e.isEmpty&&(e.creativeId||e.lineItemId||!e.isEmpty)){var t=e.slot.getSlotElementId();if(t){var s=document.getElementById(t);if(s)if((0,_ad_units__WEBPACK_IMPORTED_MODULE_0__.eq)(t)){var n=s?.closest(".js-zone-container")?.querySelector(".js-report-ad-button-container");n?(n.innerHTML="",n.append(this.createButton(e)),n.style.height="24px",_console__WEBPACK_IMPORTED_MODULE_1__.cM("Added report button to the bottom of "+t)):_console__WEBPACK_IMPORTED_MODULE_1__.cM("Ad report button not found, may be intentional, element: "+t)}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of "+t+": shouldHaveReportButton = false");else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of "+t+": resolved invalid adUnit element")}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of element: invalid adUnitElementId")}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of element: invalid SlotRenderEndedEvent")}async onButtonClick(e){e.preventDefault();let t=e.target;const s=t.dataset.modalUrl,n=t.dataset.googleEventData;return await this.loadModal(s,t,n),!1}createButton(e){let t=document.createElement("button");var s=JSON.stringify(e);return t.dataset.googleEventData=s,t.dataset.modalUrl=this.cam.opt.adReportUrl,t.dataset.adUnit=e.slot.getSlotElementId(),t.classList.add("js-report-ad","s-btn","s-btn__link","fs-fine","mt2","float-right"),t.append(document.createTextNode(this.cam.opt.adReportText)),t.removeEventListener("click",this.callOnButtonClick),t.addEventListener("click",this.callOnButtonClick),t}async loadModal(url,$link,googleEventData){try{await window.StackExchange.helpers.loadModal(url,{returnElements:window.$($link)}),this.initForm(googleEventData)}catch(e){var message="",response=e.responseText?eval(`(${e.responseText})`):null;message=response&&response.isLoggedOut?this.cam.opt.adReportLoginExpiredMessage:this.cam.opt.adReportLoginErrorMessage,window.StackExchange.helpers.showToast(message,{type:"danger"})}}removeModal(){window.StackExchange.helpers.closePopups(document.querySelectorAll("."+this.cam.opt.adReportModalClass),"dismiss")}initForm(e,t=!1){this.ignoreValidation=t,this.$form=document.querySelector(".js-ad-report-form"),this.$googleEventData=this.$form.querySelector(".js-json-data"),this.$adReportReasons=this.$form.querySelectorAll(".js-ad-report-reason"),this.$adReportReasonOther=this.$form.querySelector(".js-ad-report-reason-other"),this.$fileUploaderInput=this.$form.querySelector(".js-file-uploader-input"),this.$imageUploader=this.$form.querySelector(".js-image-uploader"),this.$clearImageUpload=this.$form.querySelector(".js-clear-image-upload"),this.$imageUploaderText=this.$form.querySelector(".js-image-uploader-text"),this.$imageUploaderPreview=this.$form.querySelector(".js-image-uploader-preview"),this.$fileErrorMessage=this.$form.querySelector(".js-file-error");const s=this.$form.querySelector(".js-drag-drop-enabled"),n=this.$form.querySelector(".js-drag-drop-disabled");this.$googleEventData.value=e,this.$adReportReasons.forEach((e,t)=>e.addEventListener("change",e=>{this.$adReportReasonOther.classList.toggle("d-none","3"!==e.target.value)})),this.$fileUploaderInput.addEventListener("change",()=>{this.validateFileInput()&&this.updateImagePreview(this.$fileUploaderInput.files)}),this.$clearImageUpload.addEventListener("click",e=>{e.preventDefault(),this.clearImageUpload()});try{this.$fileUploaderInput[0].value="",this.$imageUploader.addEventListener("dragenter dragover dragleave drop",this.preventDefaults),this.$imageUploader.addEventListener("dragenter dragover",this.handleDragStart),this.$imageUploader.addEventListener("dragleave drop",this.handleDragEnd),this.$imageUploader.addEventListener("drop",this.handleDrop)}catch(e){s.classList.add("d-none"),n.classList.remove("d-none")}this.$form.removeEventListener("",this.handleDragEnd),this.$form.addEventListener("submit",async e=>(e.preventDefault(),this.submitForm(),!1))}clearImageUpload(){this.$fileUploaderInput.value="",this.$imageUploaderPreview.setAttribute("src",""),this.$imageUploaderPreview.classList.add("d-none"),this.$clearImageUpload.classList.add("d-none"),this.$imageUploaderText.classList.remove("d-none"),this.$imageUploader.classList.add("p16","ba","bas-dashed","bc-black-100")}preventDefaults(e){e.preventDefault(),e.stopPropagation()}handleDragStart(e){this.$imageUploader.classList.remove("bas-dashed"),this.$imageUploader.classList.add("bas-solid","bc-black-100")}handleDragEnd(e){this.$imageUploader.classList.remove("bas-solid","bc-black-100"),this.$imageUploader.classList.add("bas-dashed")}handleDrop(e){var t=e.originalEvent.dataTransfer.files;FileReader&&t&&1===t.length&&(this.$fileUploaderInput.files=t,this.validateFileInput()&&this.updateImagePreview(t))}setError(e){this.$fileErrorMessage.parentElement.classList.toggle("has-error",e)}updateImagePreview(e){this.$imageUploader.classList.remove("p16","ba","bas-dashed","bc-black-100"),this.$clearImageUpload.classList.remove("d-none"),this.$imageUploaderText.classList.add("d-none");var t=new FileReader;t.onload=e=>{null!=e.target&&(this.$imageUploaderPreview.setAttribute("src",e.target.result),this.$imageUploaderPreview.classList.remove("d-none"))},t.readAsDataURL(e[0])}validateFileInput(){if(this.ignoreValidation)return!0;const e=this.cam.opt.adReportFileTypeErrorMessage,t=this.cam.opt.adReportFileSizeErrorMessage;if(null==this.$fileUploaderInput.files)return!1;var s=this.$fileUploaderInput.files[0];return null==s?(this.setError(!0),!1):this.allowedFileTypes.indexOf(s.type)<0?(this.$fileErrorMessage.textContent=e,this.$fileErrorMessage.classList.remove("d-none"),this.setError(!0),!1):s.size>2097152?(this.$fileErrorMessage.textContent=t,this.$fileErrorMessage.classList.remove("d-none"),this.setError(!0),!1):(this.$fileErrorMessage.classList.add("d-none"),this.setError(!1),!0)}async gatherDiagnosticInfo(){return{BrowserVersion:await this.getBrowserVersion()}}getElementSource(e){return e.outerHTML}getNestedIFrameElement(e){var t=e.querySelector("iframe");return t.contentDocument?t.contentDocument.documentElement:t.contentWindow.document.documentElement}async getBrowserVersion(){return await navigator.userAgentData.getHighEntropyValues(["fullVersionList"]).then(e=>JSON.stringify(e.fullVersionList))}async submitForm(){if(!this.validateFileInput())return!1;this.$form.querySelector("[type=submit]").setAttribute("disabled","true");var e=JSON.parse(this.$googleEventData.value||"{}");e.Reason=parseInt(this.$form.querySelector(".js-ad-report-reason:checked").value,10),e.Description=this.$adReportReasonOther.value,this.$googleEventData.value=JSON.stringify(e);var t=new FormData(this.$form);if("1"===t.get("shareDiagnosticInfo")){var s=await this.gatherDiagnosticInfo();Object.keys(s).forEach(e=>t.append(e,s[e]))}try{const e=await window.fetch(this.$form.getAttribute("action"),{method:this.$form.getAttribute("method"),body:t,cache:"no-cache"}),s=e.headers.get("content-type")||"",o=await e.text();if(!e.ok)throw new Error("response not valid");if(0===s.indexOf("text/html")){var n=(0,_common_helper__WEBPACK_IMPORTED_MODULE_2__.Bv)(o);const e=n?n.querySelector(".js-modal-content"):null;if(_console__WEBPACK_IMPORTED_MODULE_1__.cM("$popupContent"),_console__WEBPACK_IMPORTED_MODULE_1__.cM(e),!e)throw new Error(`Could not find .js-modal-content in response from ${this.$form.getAttribute("action")}`);document.querySelector(".js-modal-content").replaceWith(e)}else window.StackExchange.helpers.showToast(this.cam.opt.adReportThanksText,{type:"success"}),this.removeModal()}catch(e){window.StackExchange.helpers.showToast(this.cam.opt.adReportErrorText,{type:"danger"})}finally{let e=this.$form.querySelector("[type=submit]");e&&e.removeAttribute("disabled")}}}},276:(e,t,s)=>{function n(...e){}function o(...e){}s.d(t,{cM:()=>n,vU:()=>o})}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var s=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](s,s.exports,__webpack_require__),s.exports}__webpack_require__.d=(e,t)=>{for(var s in t)__webpack_require__.o(t,s)&&!__webpack_require__.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{var e=__webpack_require__(276),t=(e=>(e[e.Above=0]="Above",e[e.Below=1]="Below",e))(t||{});const s=Object.assign({},{"lib":"https://clc.stackoverflow.com/Content/bundles/js/gam_loader_script.bundle.741.5deb8dc1a671bfb1646b.js?v=7178a92a336c","style":null,"u":null,"wa":true,"kt":2000,"tto":true,"h":"clc.stackoverflow.com","allowed":"^(((talent\\.)?stackoverflow)|(blog\\.codinghorror)|(.*\\.googlesyndication)|(serverfault|askubuntu|superuser)|([^\\.]+\\.stackexchange))\\.com$","wv":true,"al":false,"abd":true,"cpa_liid":[5882654614],"cpa_cid":[138377597667],"dp":false,"tgt_to":1000,"tgt_u":"https://clc.stackoverflow.com/get-user-acct-tgt","tgt_e":true,"tgt_p":100,"dv_enabled":false,"upo":""});var n=__webpack_require__(23),o=__webpack_require__(865),a=__webpack_require__(763);class i{constructor(t,s){this.googletag=t,this.interval=s,e.cM("Ad refresh init. interval: "+s),this.googletag.pubads().addEventListener("impressionViewable",e=>this.onImpressionViewable(e)),e.cM("done enabling ad refresh")}onImpressionViewable(t){var s=t.slot;e.cM("ad refresh - slot "+s.getSlotElementId()+" is viewable, initializing refresh"),this.scheduleRefresh(s)}scheduleRefresh(e){setTimeout(()=>this.refreshAdSlot(e),1e3*this.interval)}static refreshMyAd(t,s){let n=t.pubads().getSlots().find(e=>e.getSlotElementId()===s);n&&(e.cM("refreshMyAd - refreshing ad slot "+s),t.pubads().refresh([n]))}static removeMyAd(t,s){let n=t.pubads().getSlots().find(e=>e.getSlotElementId()===s);n&&(e.cM("removeMyAd - destroying ad slot "+s),t.destroySlots([n]))}refreshAdSlot(t){var s=t.getSlotElementId();this.isElementVisibleInBrowser(s)?(e.cM("refreshing ad slot "+s),googletag.pubads().refresh([t])):(e.cM("refresh skipped this time; ad slot not viewable:"+s),this.scheduleRefresh(t))}isElementVisibleInBrowser(e){var t=document.getElementById(e);if(null!==t){var s=t.getBoundingClientRect();if(s.top>=0&&s.left>=0&&s.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&s.right<=(window.innerWidth||document.documentElement.clientWidth))return!0}return!1}}var r=(e=>(e.Off="Off",e.PreSurvey="PreSurvey",e.Collect="Collect",e.PostSurvey="PostSurvey",e))(r||{});class d{constructor(e,t){this.lineItemImpressions=[],this.surveysIdsCompleted=[],this.lineItemImpressions=e,this.surveysIdsCompleted=t}addImpression(e,t){let s={brandId:e,lineItemId:t,timestamp:new Date};this.lineItemImpressions.push(s)}addBrandSurveyCompleted(e){-1===this.surveysIdsCompleted.indexOf(e)&&this.surveysIdsCompleted.push(e)}getTotalBrandImpressions(){let e=new Map;for(let t of this.lineItemImpressions)if(e.has(t.brandId)){let s=e.get(t.brandId);e.set(t.brandId,s+1)}else e.set(t.brandId,1);return e}getBrandLineItemImpressions(e){let t={};for(let s of this.lineItemImpressions)if(s.brandId==e)if(void 0!==t[s.lineItemId]){let e=t[s.lineItemId];t[s.lineItemId]=e+1}else t[s.lineItemId]=1;return t}}class l{constructor(){this.surveyEngagementLocalStorageKey="clc-survey-engagement"}getBrandSurveyEngagement(){let e=localStorage.getItem(this.surveyEngagementLocalStorageKey);if(null===e)return new d([],[]);let t=JSON.parse(e);return new d(t.lineItemImpressions,t.surveysIdsCompleted)}saveBrandSurveyEngagement(e){let t=JSON.stringify(e);localStorage.setItem(this.surveyEngagementLocalStorageKey,t)}}class c{constructor(){this.surveyRepository=new l}getBrandSurveyEngagement(){return this.surveyRepository.getBrandSurveyEngagement()}recordImpression(e,t){let s=this.getBrandSurveyEngagement();s.addImpression(e,t),this.surveyRepository.saveBrandSurveyEngagement(s)}recordBrandSurveyCompleted(e){let t=this.getBrandSurveyEngagement();t.addBrandSurveyCompleted(e),this.surveyRepository.saveBrandSurveyEngagement(t)}}class g{constructor(t,s){this.googletag=t,this.brandSettings=s,this.brandSlotMap=new Map,this.brandSurveyEngagementService=new c,e.cM("Brand Survey init: "+JSON.stringify(s)),void 0!==s?(this.googletag.pubads().addEventListener("slotRenderEnded",e=>this.handleSlotRendered(e)),this.googletag.pubads().addEventListener("impressionViewable",e=>this.onImpressionViewable(e)),e.cM("done enabling Brand Survey")):e.cM("Brand Survey init: brandSettings is undefined, not initializing")}handleSlotRendered(t){e.cM("Brand Survey - slot rendered - slot:"+JSON.stringify(t.slot.getSlotElementId())+" lineItem: "+t.lineItemId);let s=this.findItemWithId(t.lineItemId);if(null===s||s.mode!==r.Collect)this.brandSlotMap.delete(t.slot.getSlotElementId());else{let e={brandId:s.brandId,lineItemId:t.lineItemId};this.brandSlotMap.set(t.slot.getSlotElementId(),e)}}onImpressionViewable(t){let s=t.slot;if(e.cM("ad - Brand Survey - impression viewable. Details: "+JSON.stringify(s.getSlotElementId())),e.cM("ad - Brand Survey - slot "+s.getSlotElementId()+" is viewable"),this.brandSlotMap.has(s.getSlotElementId())){let t=this.brandSlotMap.get(s.getSlotElementId());e.cM("Brand Survey - brand "+t.brandId+" is viewable"),this.recordImpression(this.brandSlotMap.get(s.getSlotElementId()))}}recordImpression(t){e.cM("ad - Brand Survey - recording impression for brand "+t.brandId),this.brandSurveyEngagementService.recordImpression(t.brandId,t.lineItemId)}findItemWithId(t){return e.cM("brand settings: "+JSON.stringify(this.brandSettings)),this.brandSettings.find(e=>e.lineItemIds.includes(t))||null}}const p="response-brand-survey-submit|",h="request-brand-survey-metadata|",m="record-metric-on-server|",u="request-dsp-tags",f="response-dsp-tags|";class _{static refreshAdIfBrandSurveyIsDuplicated(e,t,s){if(this.alreadyCompletedThisBrandSurvey(t)){var n=document.getElementById(s).closest(".js-zone-container");i.removeMyAd(e,s),n&&n.remove()}}static alreadyCompletedThisBrandSurvey(e){return(new c).getBrandSurveyEngagement().surveysIdsCompleted.includes(e)}}window.cam=new class{constructor(t=null){if(this.gptImported=!1,this.slotsRenderedEvents=[],this.collapsed={},e.cM("constructor"),this.clc_options=s,window.clcGamLoaderOptions)Object.assign(this,window.clcGamLoaderOptions);else if(void 0===this.opt){let e=window.opt;e&&(this.opt=e)}}init(){if(e.cM("init"),void 0===this.opt)throw new Error("opt not set, required by GAM Loader");e.cM("init brand survey service"),this.getUserMetaPromise=this.getUserMeta(),e.cM("setup message handler"),window.addEventListener("message",e=>{this.onmessage(e)})}handleSlotRenderedNoAdReport(){if(googletag.pubads().addEventListener("slotRenderEnded",e=>this.applyExtraMarginBottom(e)),Array.isArray(this.slotsRenderedEvents))for(var e=0;e<this.slotsRenderedEvents.length;e++)this.applyExtraMarginBottom(this.slotsRenderedEvents[e])}onmessage(t){let s="omni";if(t.data&&("string"==typeof t.data||t.data instanceof String))if(0===t.data.indexOf("get-omni-")){e.cM("Recevied get-omni message, sending back omni");var n=t.source,a=this.opt.omni,i="string"==typeof a?a:"";n.postMessage([s,i,this.opt.perRequestGuid].join("|"),"*")}else if(0===t.data.indexOf("collapse-")){e.cM("Recevied collapse message, collapse ad iframe"),e.cM(t);for(var r=t.source.window,d=document.getElementsByTagName("IFRAME"),l=0;l<d.length;l++){var g=d[l];if(g.contentWindow==r)return void(0,o.wo)(g.parentElement.parentElement.parentElement)}}else if(0===t.data.indexOf("resize|")){e.cM("Recevied resize message, resize ad iframe"),e.cM(t);let s=this._getFrameByEvent(t),n=t.data.indexOf("|")+1,o=t.data.slice(n),a=parseFloat(o)+.5;e.cM("New iframe height "+a),s.height=a.toString(),s.parentElement.style.height=a.toString()+"px"}else if(0===t.data.indexOf("getmarkup|")){let s=t.data.indexOf("|")+1,n=t.data.slice(s);e.cM("Recevied get markup message: "+n);let o=this._getFrameByEvent(t).closest(".everyonelovesstackoverflow");const a=document.createElement("script");a.dataset.adZoneId=o.id,a.src=n,document.body.appendChild(a)}else if(0===t.data.indexOf("window-location|")){let s=t.data.indexOf("|")+1,n=t.data.slice(s);e.cM("Recevied window location message: "+n),n.startsWith("/")||(n="/"+n),window.open(window.location.protocol+"//"+window.location.host+n,"_blank")}else if(0===t.data.indexOf("request-brand-survey-submit|")){let s=t.data.split("|"),n=s[1],o=s[2],a=s[3],i=JSON.parse(a);e.cM(n),e.cM(o),e.cM(a),e.cM("Received brand survey "+n+" response message: "+o);var v=new FormData;for(var b in i)v.append(b,i[b]);let r=this._getFrameByEvent(t);if(_.alreadyCompletedThisBrandSurvey(+n))return e.cM("Already completed this brand survey. Not submitting duplicate to server."),void r.contentWindow.postMessage("response-brand-survey-submit-duplicate|","*");e.cM("Send the brand survey to the server"),fetch(o,{method:"POST",body:v}).then(e=>e.json()).then(e=>r.contentWindow.postMessage({messageType:p},"*")).catch(e=>r.contentWindow.postMessage({messageType:p},"*"))}else if(0===t.data.indexOf("brand-survey-completed-store|")){let s=t.data.split("|"),n=(s[1],s[2]);if(e.cM("Received brand survey completed store message for survey ID "+n),_.alreadyCompletedThisBrandSurvey(+n))return void e.cM("Already completed this brand survey. Not recording duplicate locally.");e.cM("Record brand survey completion locally"),(new c).recordBrandSurveyCompleted(+n)}else if(0===t.data.indexOf(h)){let s=t.data.split("|"),n=s[1],o=s[2];e.cM("Received message: "+h+" with Brand Survey ID "+o);let a=(new c).getBrandSurveyEngagement().getBrandLineItemImpressions(+n),i=JSON.stringify(a),r=this._getFrameByEvent(t);e.cM("sending impression data: "+i),r.contentWindow.postMessage("response-brand-survey-metadata|"+this.opt.responseHash+"|"+this.opt.perRequestGuid+"|"+i+"|"+this.opt.countryCode+"|"+this.opt.qualtricsSurveyData,"*")}else if(0===t.data.indexOf("refresh-if-duplicate-brand-survey|")){let e=t.data.split("|")[1],s=this.getSlotElementIdByEvent(t);_.refreshAdIfBrandSurveyIsDuplicated(googletag,+e,s)}else if(0===t.data.indexOf(m)){e.cM("Received message: "+m+" with args: "+t.data);let s=t.data.split("|"),n=s[1],o=s[2],a=s[3],i=s[4],r=new FormData;r.append("brandSurveyId",a.toString()),r.append("responseHash",this.opt.responseHash),r.append("perRequestGuid",this.opt.perRequestGuid),r.append("questionNumber",n.toString()),r.append("metricType",i.toString()),fetch(o,{method:"POST",body:r}).then(e=>e.ok).catch(t=>{e.cM("SendMetricToServer: Error sending metric to server: "+t)})}else if(0===t.data.indexOf(u)){e.cM("Received message: "+u+" with args: "+t.data);let s=this._getFrameByEvent(t);if(!this.opt.targeting["so-tag"])return void s.contentWindow.postMessage(f,"*");const n=this.opt.targeting["so-tag"].join(",");e.cM("sending targeting tags: "+n),s.contentWindow.postMessage(f+n,"*")}else e.cM("Received unhandled message")}getSlotElementIdByEvent(e){let t=this._getFrameByEvent(e),s=t.parentElement?.parentElement?.id;return s||""}_getFrameByEvent(e){return Array.from(document.getElementsByTagName("iframe")).filter(t=>t.contentWindow===e.source)[0]}classifyZoneIds(e){const t=e.map(o.Nj).filter(o.yb);return{eligible:t.filter(o.xb).filter(o.pn),ineligible:t.filter(o.xj)}}applyExtraMarginBottom(t){if(t&&t.slot&&!t.isEmpty&&(t.creativeId||t.lineItemId||!t.isEmpty)){var s=t.slot.getSlotElementId();if(s){var o=document.getElementById(s);if(o)if((0,n.eq)(s)){var a=o?.closest(".js-zone-container");a.style.marginBottom="24px",e.cM("Applied extra margin to the bottom of "+s)}else e.cM("Not applying extra margin to the bottom of "+s+": shouldHaveReportButton = false");else e.cM("Not applying extra margin to the bottom of "+s+": resolved invalid adUnit element")}else e.cM("Not applying extra margin to the bottom of element: invalid adUnitElementId")}else e.cM("Not applying extra margin to the bottom of element: invalid SlotRenderEndedEvent")}async load(s=(0,n.kG)()){const r=this.opt.tlb_position===t.Above?["dfp-mlb","dfp-smlb"]:["dfp-mlb","dfp-smlb","dfp-tlb"];if(!this.isGptReady())return e.cM("Initializing..."),this.initGpt(),void googletag.cmd.push(()=>this.load(s));this.opt.adReportEnabled?(e.cM("Ad reporting enabled"),this.adReports=new a.t(googletag,this)):(e.cM("Ad reporting not enabled"),this.handleSlotRenderedNoAdReport()),this.opt.refresh?(e.cM("Ad refresh enabled"),this.adRefresh=new i(googletag,this.opt.refreshInterval)):e.cM("Ad refresh not enabled"),this.opt.brandSurveyEnabled&&(e.cM("Brand Survey enabled"),this.brandSurvey=new g(googletag,this.opt.brandSurveySettings)),e.cM("Attempting to load ads into ids: ",s);const{eligible:d,ineligible:l}=this.classifyZoneIds(s);if(this.initDebugPanel(googletag,d.concat(l)),d.forEach(e=>(0,o.cf)(e)),l.forEach(o.wo),0===d.length)return void e.cM("Found no ad ids on page");e.cM("Eligible ids:",d),this.opt.abd&&this.appendAdblockDetector();var c=googletag.pubads().getSlots();if(c){var p=c.filter(e=>s.indexOf(e.getSlotElementId())>=0);googletag.destroySlots(p)}this.opt.sf&&(googletag.pubads().setForceSafeFrame(!0),googletag.pubads().setSafeFrameConfig({allowOverlayExpansion:!0,allowPushExpansion:!0,sandbox:!0})),e.cM("Targeting consent: Checking...");let h=!1,m=!1;void 0!==this.opt.targeting_consent&&(m=!0,e.cM("Targeting consent: Parameter set"),e.cM("Targeting consent: Consent given? ",this.opt.targeting_consent),h=this.opt.targeting_consent),void 0!==this.opt.personalization_consent&&(e.cM("Personalization consent: Parameter set"),e.cM("Personalization consent: Consent given? ",this.opt.personalization_consent),h=h&&this.opt.personalization_consent),h=h&&m,this.setPrivacySettings(h),this.opt.ll||googletag.pubads().enableSingleRequest(),cam.sreEvent||(googletag.pubads().addEventListener("slotRenderEnded",e=>this.onSlotRendered(e)),cam.sreEvent=!0),await this.setTargeting();var u=d.filter(e=>!this.opt.ll||r.indexOf(e.id)<0),f=d.filter(e=>!!this.opt.ll&&r.indexOf(e.id)>=0);e.cM("Up front ids:",u),e.cM("Lazy loaded ids:",f),u.forEach(t=>{e.cM(`Defining ad for element ${t.id}`),this.defineSlot(t.id,googletag),t.setAttribute("data-dfp-zone","true")}),googletag.enableServices(),u.forEach(t=>{e.cM(`Displaying ad for element ${t.id}`),this.clc_options.dv_enabled?window.onDvtagReady(function(){googletag.display(t.id)}):googletag.cmd.push(()=>googletag.display(t.id))}),this.opt.ll&&(e.cM("Enabling lazy loading for GAM"),googletag.pubads().enableLazyLoad({fetchMarginPercent:0,renderMarginPercent:0}),e.cM("Setting up lazy loaded ad units"),f.forEach(t=>{e.cM(`Lazy loading - Defining Slot ${t.id}`),this.defineSlot(t.id,googletag)}),f.forEach(t=>{e.cM(`Lazy loading - Displaying ad for element ${t.id}`),this.clc_options.dv_enabled?window.onDvtagReady(function(){googletag.display(t.id)}):googletag.cmd.push(()=>googletag.display(t.id))}))}setPrivacySettings(e){e||googletag.pubads().setPrivacySettings({nonPersonalizedAds:!0})}async setTargeting(){if(!googletag)throw new Error("googletag not defined");let t=this.opt.targeting;if(!t)throw new Error("Targeting not defined (is "+typeof t+")");Object.keys(t).forEach(s=>{e.cM(`-> targeting - ${s}: ${t[s]}`),googletag.pubads().setTargeting(s,t[s])});let s=!1;if(void 0!==this.opt.targeting_consent&&(s=this.opt.targeting_consent),s){let t=(new c).getBrandSurveyEngagement();if(t.getTotalBrandImpressions().forEach((t,s)=>{e.cM(`-> targeting - BrandImpressions: ${s}: ${t}`),googletag.pubads().setTargeting("brand_"+s.toString()+"_impressions",t.toString())}),t.surveysIdsCompleted.forEach(t=>{e.cM(`-> targeting - SurveysTaken: ${t}`),googletag.pubads().setTargeting("survey_"+t+"_taken","true")}),this.clc_options.tgt_e&&this.getUserMetaPromise){let t=await this.getUserMetaPromise;t&&t.tgt_acct?(e.cM("-> targeting - User Account: "+t.tgt_acct),googletag.pubads().setTargeting("user-acct",t.tgt_acct.company_name),googletag.pubads().setTargeting("user_acct_top",t.tgt_acct.company_name),googletag.pubads().setTargeting("user_industry",t.tgt_acct.industry),googletag.pubads().setTargeting("user_employee_count",t.tgt_acct.employee_range)):e.cM("-> targeting - User Account: Not Found"),t&&Object.prototype.hasOwnProperty.call(t,"is_high_rep_earner")?(e.cM("-> targeting - High Rep Earner: "+t.is_high_rep_earner),googletag.pubads().setTargeting("IsHighRepEarner",t.is_high_rep_earner?"true":"false")):e.cM("-> targeting - High Rep Earner: not found")}if(localStorage){e.cM('Checking local storage for "jobs-last-clicked" key.');let t=localStorage.getItem("jobs-last-clicked")?"true":"false";e.cM(`-> targeting - jobs_clicked: ${t}`),googletag.pubads().setTargeting("jobs_clicked",t)}}}appendAdblockDetector(){const e=document.createElement("div");e.className="adsbox",e.id="clc-abd",e.style.position="absolute",e.style.pointerEvents="none",e.innerHTML=" ",document.body.appendChild(e)}onSlotRendered(s){try{const i=s.slot.getSlotElementId();let r=[];i||r.push("id=0");const d=document.getElementById(i);if(i&&!d&&r.push("el=0"),0!==r.length)return void this.stalled(r.join("&"));const{path:l,sizes:c,zone:g}=(0,n.Z7)(i,this.clc_options.upo);if(this.collapsed[g]&&s.isEmpty)return e.cM(`No line item for the element #${d.id}... collapsing.`),void(0,o.wo)(d);if(this.slotsRenderedEvents.push(s),s.lineItemId||s.creativeId||!s.isEmpty){e.cM(`Rendered ad for element #${d.id} [line item #${s.lineItemId}]`),e.cM(s);var a=d.parentElement;if(a.classList.contains("js-zone-container")){switch((0,o.cf)(a),i){case"dfp-tlb":this.opt.tlb_position===t.Above?a.classList.add("mb8"):a.classList.add("mt16");break;case"dfp-tag":a.classList.add("mb8");break;case"dfp-msb":a.classList.add("mt16");break;case"dfp-mlb":case"dfp-smlb":case"dfp-bmlb":a.classList.add("my8");break;case"dfp-isb":a.classList.add("mt24");break;case"dfp-m-aq":a.classList.add("my12"),a.classList.add("mx-auto")}(0,o.$Z)(a),(0,o.$Z)(d)}else e.cM(`No ad for element #${d.id}, collapsing`),e.cM(s),(0,o.wo)(d)}}catch(t){e.cM("Exception thrown onSlotRendered"),e.cM(t),this.stalled("e=1")}}stalled(e){(new Image).src=`https://${this.clc_options.h}/stalled.gif?${e}`}defineSlot(t,s){"dfp-isb"===t&&(e.cM("-> targeting - Sidebar: Inline"),s.pubads().setTargeting("Sidebar",["Inline"])),"dfp-tsb"===t&&(e.cM("-> targeting - Sidebar: Right"),s.pubads().setTargeting("Sidebar",["Right"]));const{path:o,sizes:a,zone:i}=(0,n.Z7)(t,this.clc_options.upo);e.cM(`Defining slot for ${t}: ${o}, sizes: ${JSON.stringify(a)}`),s.defineSlot(o,a,t).addService(s.pubads())}importGptLibrary(){this.gptImported||(this.gptImported=!0,void 0===this.opt.targeting_consent||this.opt.targeting_consent?(0,o.Gx)("https://securepubads.g.doubleclick.net/tag/js/gpt.js"):(0,o.Gx)("https://pagead2.googlesyndication.com/tag/js/gpt.js"))}importDvLibrary(){this.clc_options.dv_enabled&&(e.cM("Adding DoubleVerify library"),(0,o.Gx)("https://pub.doubleverify.com/dvtag/21569774/DV1289064/pub.js"),e.cM("Adding DoubleVerify onDvtagReady handler"),window.onDvtagReady=function(t,s=750){e.cM("DoubleVerify onDvtagReady called"),window.dvtag=window.dvtag||{},dvtag.cmd=dvtag.cmd||[];const n={callback:t,timeout:s,timestamp:(new Date).getTime()};dvtag.cmd.push(function(){dvtag.queueAdRequest(n)}),setTimeout(function(){const e=n.callback;n.callback=null,e&&e()},s)})}isGptReady(){return"undefined"!=typeof googletag&&!!googletag.apiReady}initGpt(){"undefined"==typeof googletag&&(window.googletag={cmd:(0,o.QZ)(()=>{this.importGptLibrary(),this.importDvLibrary()})})}getUserMeta(){if(this.opt.allowAccountTargetingForThisRequest&&this.clc_options.tgt_e&&this.clc_options.tgt_p>0){if(e.cM("Targeting enabled."),this.clc_options.tgt_p<100){e.cM("Targeting rate limit enabled. Rolling the dice...");const t=Math.floor(100*Math.random())+1;if(e.cM("Rolled "+t+" and the max is "+this.clc_options.tgt_p),t>this.clc_options.tgt_p)return void e.cM("Will not request targeting.")}return e.cM("Will request targeting."),function(e,t,s,n){if(t){const t=new Headers;return t.append("Accept","application/json"),async function(e,t={},s=5e3){if("number"!=typeof s&&null!=s&&!1!==s){if("string"!=typeof s)throw new Error("fetchWithTimeout: timeout must be a number");if(s=parseInt(s),isNaN(s))throw new Error("fetchWithTimeout: timeout must be a number (or string that can be parsed to a number)")}const n=new AbortController,{signal:o}=n,a=fetch(e,{...t,signal:o}),i=setTimeout(()=>n.abort(),s);try{const e=await a;return clearTimeout(i),e}catch(e){throw clearTimeout(i),e}}(s+"?"+new URLSearchParams({omni:e}),{method:"GET",mode:"cors",headers:t},n).then(e=>e.json())}return Promise.reject("No consent")}(this.opt.omni,this.opt.targeting_consent,this.clc_options.tgt_u,this.clc_options.tgt_to).catch(t=>{e.vU("Error fetching user account targeting"),e.vU(t)})}e.cM("Targeting disabled. Will not request account targeting data.")}initDebugPanel(t,s){e.cM("initDebugPanel"),e.cM("Not showing debug panel.")}},window.clcGamLoaderOptions&&(cam.init(),cam.load())})()})();</script> <footer id="footer" class="site-footer js-footer theme-light__forced" role="contentinfo"> <div class="site-footer--container"> <div class="site-footer--logo"> <a href="https://stackoverflow.com" aria-label="Stack Overflow"><svg aria-hidden="true" class="native svg-icon iconGlyphMd" width="32" height="37" viewBox="0 0 32 37"><path fill="#BCBBBB" d="M26 33v-9h4v13H0V24h4v9z"/><path fill="#F48024" d="m21.5 0-2.7 2 9.9 13.3 2.7-2zM26 18.4 13.3 7.8l2.1-2.5 12.7 10.6zM9.1 15.2l15 7 1.4-3-15-7zm14 10.79.68-2.95-16.1-3.35L7 23zM23 30H7v-3h16z"/></svg></a> </div> <nav class="site-footer--nav" aria-label="Footer"> <div class="site-footer--col"> <h5 class="-title"><a href="https://stackoverflow.com" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 15})">Stack Overflow</a></h5> <ul class="-list js-primary-footer-links"> <li><a href="/questions" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 16})">Questions</a></li> <li><a href="/help" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 3 })">Help</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 5 })" href="https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com">Chat</a></li> </ul> </div> <div class="site-footer--col"> <h5 class="-title"><a href="https://stackoverflow.co/" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 19 })">Products</a></h5> <ul class="-list"> <li><a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams" class="js-gps-track -link" data-ga="["teams traffic","footer - site nav","stackoverflow.com/teams",null,{"dimension4":"teams"}]" data-gps-track="footer.click({ location: 2, link: 29 })">Teams</a></li> <li><a href="https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 21 })">Advertising</a></li> <li><a href="https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 20 })">Talent</a></li> </ul> </div> <div class="site-footer--col"> <h5 class="-title"><a class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">Company</a></h5> <ul class="-list"> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">About</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 27 })" href="https://stackoverflow.co/company/press/">Press</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 9 })" href="https://stackoverflow.co/company/work-here/">Work Here</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 7 })" href="https://stackoverflow.com/legal">Legal</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 8 })" href="https://stackoverflow.com/legal/privacy-policy">Privacy Policy</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 37 })" href="https://stackoverflow.com/legal/terms-of-service/public">Terms of Service</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 13 })" href="/contact">Contact Us</a></li> <li id="consent-footer-link"><button type="button" data-controller="cookie-settings" data-action="click->cookie-settings#toggle" class="s-btn s-btn__link py4 js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 38 })" data-consent-popup-loader="footer">Cookie Settings</button></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 39 })" href="https://stackoverflow.com/legal/cookie-policy">Cookie Policy</a></li> </ul> </div> <div class="site-footer--col site-footer--categories-nav"> <div> <h5 class="-title"><a href="https://stackexchange.com" data-gps-track="footer.click({ location: 2, link: 30 })">Stack Exchange Network</a></h5> <ul class="-list"> <li> <a href="https://stackexchange.com/sites#technology" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Technology </a> </li> <li> <a href="https://stackexchange.com/sites#culturerecreation" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Culture & recreation </a> </li> <li> <a href="https://stackexchange.com/sites#lifearts" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Life & arts </a> </li> <li> <a href="https://stackexchange.com/sites#science" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Science </a> </li> <li> <a href="https://stackexchange.com/sites#professional" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Professional </a> </li> <li> <a href="https://stackexchange.com/sites#business" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Business </a> </li> <li class="mt16 md:mt0"> <a href="https://api.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> API </a> </li> <li> <a href="https://data.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Data </a> </li> </ul> </div> </div> </nav> <div class="site-footer--copyright fs-fine md:mt24"> <ul class="-list -social md:mb8"> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link:4 })" href="https://stackoverflow.blog?blb=1">Blog</a></li> <li><a href="https://www.facebook.com/officialstackoverflow/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 31 })">Facebook</a></li> <li><a href="https://twitter.com/stackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 32 })">Twitter</a></li> <li><a href="https://linkedin.com/company/stack-overflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 33 })">LinkedIn</a></li> <li><a href="https://www.instagram.com/thestackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 36 })">Instagram</a></li> </ul> <p class="md:mb0"> <span>Site design / logo © 2025 Stack Exchange Inc; </span> <span>user contributions licensed under </span> <a class="-link s-link td-underline" href="https://stackoverflow.com/help/licensing">CC BY-SA</a> <span>. </span> <span id="svnrev">rev 2025.2.21.22958</span> </p> </div> </div> </footer> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-WCZ03SZFCQ"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } </script> <script> StackExchange.ready(function() { var ga3Settings = { autoLink: ["stackoverflow.blog","info.stackoverflowsolutions.com","stackoverflowsolutions.com"], sendTitles: true, tracker: window.ga, trackingCodes: [ 'UA-108242619-1' ], checkDimension: 'dimension42' }; var customGA4Dimensions = {}; customGA4Dimensions["requestid"] = "7d10ab21-2404-42b3-8cfa-996058739490"; customGA4Dimensions["routename"] = "Questions/Show"; customGA4Dimensions["post_id"] = "1669"; customGA4Dimensions["tags"] = "|compiler-construction|language-agnostic|"; var ga4Settings = { tracker: gtag, trackingCodes: [ 'G-WCZ03SZFCQ' ], consentsToPerformanceCookies: "denied", consentsToTargetingCookies: "denied", eventParameters: customGA4Dimensions, checkForAdBlock: true, sendTitles: true, trackClicks: false, }; StackExchange.ga.init({ GA3: ga3Settings, GA4: ga4Settings }); StackExchange.ga.setDimension('dimension2', '|compiler-construction|language-agnostic|'); StackExchange.ga.setDimension('dimension3', 'Questions/Show'); StackExchange.ga.setDimension('dimension7', "1740274359.1544348198"); StackExchange.ga.trackPageView(); }); </script> <script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" charset="UTF-8" data-document-language="true" data-domain-script="c3d9f1e3-55f3-4eba-b268-46cee4c6789c"></script> <script defer src="https://cdn.sstatic.net/Js/modules/cookie-consent.en.js?v=36bebc18e04f"></script> <script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'916376971db4f924',t:'MTc0MDI3NDM1OS4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body> </html>