[{"data":1,"prerenderedAt":292},["ShallowReactive",2],{"project-28048528":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":33,"aspects":34,"strip":39,"post_text":42,"what":43,"said":63,"maker_in_thread":127,"shape":139,"grid":143,"attempts":253,"same_week":254,"maker_shows":36,"maker_hidden":284,"reader_version":285,"card":286},"28048528","ocean","A work-in-progress C compiler from scratch","title","Show HN: A work-in-progress C compiler from scratch","https:\u002F\u002Fgithub.com\u002Friicchhaarrd\u002Focean","github.com","r1chardnl",1627995032,2021,159,42,303,2533,12,"notable","languages","c compiler","cli",[21,24,25,26],"x86 elf","compiler from scratch","recursive descent parser","curious",0.025,{"positive":30,"neutral":31,"mixed":32,"critical":30},2,10,0,14,{"idea":35,"execution":37,"docs":38},{"positive":32,"critical":36},1,{"positive":32,"critical":36},{"positive":32,"critical":32},[32,32,32,32,32,32,32,32,32,36,32,40,32,32,32,32,32,32,32,40,40,32,32,40,32,41,36,32,32,32,40,40,32,40,40,32,40,32,40,41],3,5,null,{"problem":42,"audience":42,"pricing":42,"motivation":44,"time_to_build":42,"stack":51,"openness":60,"stage":61,"team_size":62},{"value":45,"source":46,"evidence":47},"Learning, hobby and fun, with an aspiration to create a language they would like to use.","maker",[48],{"id":49,"by":11,"text":50},"28051003","Learning, hobby and fun. Aspiration to create a language that I would love to use some day.",[52],{"value":53,"source":54,"evidence":55},"C","inferred",[56],{"id":57,"by":58,"text":59},"28052136","thamer","Just a few small suggestions: 1. Some code seems to be duplicated (although with slightly different formatting) across multiple files, like dd\u002Fdw\u002Fdb in elf.c and x86.c for…","open_source","prototype","solo",{"praise":64,"objections":74,"requests":82,"questions":90,"alternatives":98},[65],{"value":66,"source":67,"evidence":68},"Good learning project and great way to learn compilers","commenter",[69,70],{"id":57,"by":58,"text":59},{"id":71,"by":72,"text":73},"28053703","justinlloyd","Great job! Writing a compiler from scratch is a massively valuable learning experience. I wrote one in BASIC for the 6502, that became self-hosting on April 24th, 1982. I'm going…",[75],{"value":76,"source":67,"evidence":77},"Not really a C compiler yet; the function syntax deviates from C",[78],{"id":79,"by":80,"text":81},"28049086","MisterTea","> Programming language that compiles into a x86 ELF executable. > a compiler somewhat resembling C > Add new or borrow from other language(s) features ontop of C, deviate away…",[83],{"value":84,"source":67,"evidence":85},"Use C-style string handling alternatives such as length-carrying strings",[86],{"id":87,"by":88,"text":89},"28051352","jeffrallen","If you are exploring alternatives to the stdlib, you might commit yourself to no zero terminated strings and see where it takes you. A fundamental data type with a pointer, a…",[91],{"value":92,"source":67,"evidence":93},"What resources were used to learn compiler construction",[94],{"id":95,"by":96,"text":97},"28050381","kinga254","Any specific resources you've used that you could recommend in line with compiler construction?",[99,109,120],{"value":100,"source":67,"evidence":101},"Flex and Bison \u002F yacc",[102,106],{"id":103,"by":104,"text":105},"28051766","jjice","This is just an anecdote, but I had to write a SQL DDL and DML parser during my last semester. I wrote the DDL parser by hand, and it wasn't as bad as I expected, but it was time…",{"id":107,"by":11,"text":108},"28050687","You could use https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FYacc I decided to write my own lexer\u002Fparser\u002Fcompiler it's pretty straightforward. Sources I use(d) to program this, e.g look at…",{"value":110,"source":67,"evidence":111},"ANTLR",[112,116],{"id":113,"by":114,"text":115},"28051507","optymizer","I wrote a C compiler* using flex [1] and bison [2] that generated MIPS code. The biggest downside was the rather complex glue code. At some point ANTLR [3] looked promising, but…",{"id":117,"by":118,"text":119},"28051590","MH15","I've had good luck with ANTLR4 and ObjWeb ASM for my JVM language Imp https:\u002F\u002Fgithub.com\u002Fmh15\u002Fimp",{"value":121,"source":67,"evidence":122},"Crafting Interpreters",[123],{"id":124,"by":125,"text":126},"28050782","blcArmadillo","This is specific to interpreters but the beginning part related to parsing and AST is common: http:\u002F\u002Fcraftinginterpreters.com\u002Fcontents.html",{"comments":128,"answered":30,"key":129},6,[130,133,136],{"id":131,"text":132},"28049129","The main goal at the moment is to create a C compiler, the function keyword there is just a placeholder for the time being. At the moment anything returned is just mov'd into the…",{"id":134,"text":135},"28049405","Looks really interesting, thanks for sharing this. I'm not sure whether I'll incorporate everything from C or just make it compatible with C and behind the scenes do things…",{"id":137,"text":138},"28051069","Can't edit my original reply anymore, but fair point, I've changed the keyword 'function' in the AST to a function return type instead. There's no error handling done yet to…",{"commenters":140,"max_depth":41,"maker_replies":128,"first_comment_mins":141,"lifespan_hours":142},32,53,250,[144,146,150,153,155,158,161,164,167,169,171,173,176,178,181,184,187,190,192,195,198,200,203,204,207,209,212,215,219,222,224,227,231,234,235,236,237,238,242,243,246,251],[103,32,32,145,104,32],"other\u002Fneutral\u002Fnone",[147,32,32,148,149,32],"28051990","commenter\u002Fneutral\u002Fnone","brundolf",[151,32,32,148,152,32],"28052956","qorrect",[154,32,32,148,149,32],"28053318",[156,32,32,145,157,32],"28052390","dboreham",[159,32,32,148,160,32],"28055150","WalterBright",[162,32,32,145,163,32],"28055563","neilv",[165,32,32,148,166,32],"28056180","codr7",[168,32,32,145,160,32],"28056742",[79,36,36,170,80,32],"project\u002Fcritical\u002Fidea",[131,36,32,172,11,36],"maker\u002Fneutral\u002Fnone",[174,36,40,175,80,32],"28049285","maker\u002Fneutral\u002Fidea",[134,36,32,177,11,36],"maker\u002Fpositive\u002Fidea",[179,36,32,145,180,32],"28049641","kubb",[182,36,32,145,183,32],"28052905","kragen",[185,36,32,145,186,32],"28050024","spijdar",[188,36,32,145,189,32],"28050232","mananaysiempre",[191,36,32,145,80,32],"28050490",[193,36,32,145,194,32],"28057960","pjmlp",[196,36,32,145,197,32],"28175825","lerno",[87,36,40,199,88,32],"project\u002Fneutral\u002Fidea",[201,36,40,199,202,32],"28052033","guntars",[137,36,32,172,11,36],[205,36,32,148,206,32],"28052889","tills13",[57,30,40,208,58,32],"project\u002Fneutral\u002Fexecution",[210,40,32,145,211,32],"28056997","muth02446",[71,213,41,214,72,32],4,"project\u002Fpositive\u002Fnone",[216,41,36,217,218,32],"28052071","project\u002Fcritical\u002Fexecution","SavantIdiot",[220,41,32,148,221,32],"28052104","fao_",[223,41,32,148,218,32],"28052326",[225,41,32,145,226,32],"28054081","rot13xor",[228,128,40,229,230,32],"28057331","project\u002Fneutral\u002Fnone","quantumOctopus",[95,232,40,233,96,32],7,"maker\u002Fneutral\u002Fdocs",[107,232,32,233,11,36],[124,232,40,233,125,32],[113,232,40,233,114,32],[117,232,32,145,118,32],[239,240,40,172,241,32],"28050820",8,"gwbas1c",[49,240,32,172,11,36],[244,240,40,175,245,32],"28051189","d6ba56c039d9",[247,248,41,249,250,32],"28049051",9,"maker\u002Fpositive\u002Fnone","bruce343434",[252,248,32,249,11,36],"28049097",[],[255,260,265,270,275,279],{"id":256,"name":257,"points":258,"category":259},"28012829","Static.wiki",796,"learning_science",{"id":261,"name":262,"points":263,"category":264},"28017051","redbean",223,"infrastructure",{"id":266,"name":267,"points":268,"category":269},"28059291","Till",209,"dev_tools",{"id":271,"name":272,"points":273,"category":274},"27996348","Clockwise",162,"productivity",{"id":276,"name":277,"points":278,"category":264},"28063597","Hookdeck",126,{"id":280,"name":281,"points":282,"category":283},"28037113","Open by Design",118,"creative",false,"v2",{"id":287,"name":5,"line":6,"ai":284,"cat":20,"year":13,"points":14,"comments":15,"rec":27,"s":288,"top":18,"kw":289,"maker":11,"domain":10,"tier":19,"attempts":32,"strip":290,"url":9,"mix":291,"praise":66,"objection":76,"sub":21},28048528,0.03,[21,24,25,26],"0000000001030000000330030510003303303035",[30,31,32,30],1793991031338]