Inthisbookwewillcreateaprogramminglanguagetogether.We'llstartwith0linesofcodeandendupwithafullyworkinginterpreterfortheMonkey*programminglanguage.Stepbystep.Fromtokenstooutput.Allcodeshownandincluded.Fullytested.Buythisbooktolearn-HowtobuildaninterpreterforaC-likeprogramminglanguagefromscratch-Whatalexer,aparserandanAbstractSyntaxTree(AST)areandhowtobuildyourown-Whatclosuresareandhowandwhytheywork-WhatthePrattparsingtechniqueandarecursivedescentparseris-Whatotherstalkaboutwhentheytalkaboutbuilt-indatastructures-WhatREPLstandsforandhowtobuildoneWhythisbookThisisthebookIwantedtohaveayearago.ThisisthebookIcouldn'tfind.Iwrotethisbookforyouandme.Sowhyshouldyoubuyit?What'sdifferentaboutit,comparedtootherinterpreterorcompilerliterature?-Workingcodeisthefocus.Codeisnotjustfoundintheappendix.Codeisthemainfocusofthisbook.-It'ssmall!Ithasaround200pagesofwhichagreatdealarereadable,syntax-highlighted,workingcode.-Thecodepresentedinthebookiseasytounderstand,easytoextend,easytomaintain.-No3rdpartylibraries!You'renotleftwondering:"ButhowdoestoolXdothat?"Wewon'tuseatoolX.WeonlyusetheGostandardlibraryandwriteeverythingourselves.-Tests!Theinterpreterwebuildinthebookisfullytested!SometimesinTDDstyle,sometimeswiththetestswrittenafter.Youcaneasilyruntheteststoexperimentwiththeinterpreterandmakechanges.Thisbookisforyouifyou...-learnbybuilding,lovetolookunderthehood-loveprogrammingandtoprogramforthesakeoflearningandjoy!-areinterestedinhowyourfavorite,interpretedprogramminglanguageworks-nevertookacompilercourseincollege-wanttogetstartedwithinterpretersorcompilers…-...butdon'twanttoworkthroughatheory-heavy,800pages,4poundscompilerbookasabeginner-keptscreaming"showmethecode!"whenreadingaboutinterpretersandcompilers-alwayswantedtosay:"Holyshit,Ibuiltaprogramminglanguage!"TableofContentsAcknowledgmentsIntroductionLexingParsingEvaluationExtendingtheInterpreterResourcesFeedbackChangelog
1