[video output=day510 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Making a Parser for HHTs" vod_platform=youtube id=Ha3NbEhXAtU annotator=Miblo] [0:03][Welcome to the stream][:speech] [0:33][Announce a job opening on the game Sub Rosa[ref site=Steam page="Sub Rosa" url=https://steamcommunity.com/app/272230] by [@crypticsea Alex Austin][ref site=Twitter page="Alex Austin" url=https://twitter.com/crypticsea]][:speech] [6:11][Fix typos in base_game.hht[ref site=GitHub page="HandmadeHero / cpp / Typo's in tags file" url=https://github.com/HandmadeHero/cpp/issues/85]][:admin :"asset system"] [8:44][Note the need to search for asset files][:"asset system" :speech] [11:44][Consider allowing for placeholder stubs of nonexistent assets][:"asset system" :speech] [15:37][Set up to make our existing :parsing code usable by multiple routines][:speech] [19:10][Get the simple_preprocessor building][:parsing] [24:30][Save off handmade_generated.h as handmade_generated_original.h and diff them with Meld[ref site=Meld url=https://meldmerge.org/]][:admin :parsing] [26:38][Intentionally break the tokenizer and see the diff in Meld][:admin :parsing] [27:59][Pull out the tokenizing code from the simple_preprocessor into handmade_tokenizer.cpp and .h][:parsing] [30:17][Convert the token struct to contain a length-string][:parsing :"string manipulation"] [36:11][Organise the :"string manipulation" code into handmade_shared.h][:admin] [42:34][Convert the whole tokenizer over to use length-strings, introducing Tokenizer()][:"file io" :parsing :"string manipulation"] [47:38][Update EatAllWhitespace() and GetToken() to use length-strings, noting that hand-coded token checking is the one thing made harder by length-strings vs null-terminated ones][:parsing] [56:09][Introduce AdvanceChars() and Refill()][:parsing] [1:00:37][Find that our generated files are identical][:admin :parsing] [1:02:01][Introduce ParseHHT() in a newly created handmade_hht.cpp, augmenting the tokenizer to handle all the single-character tokens in our .hht :"file format"][:parsing] [1:16:20][Make ParseTopLevelBlock() use RequireToken() and add systemic :"error handling" in the tokenizer][:parsing] [1:26:37][Verify that our generated files are identical][:admin :parsing] [1:26:54][Enable ParseTopLevelBlock() to parse all the fields of a block, introducing ParseTagList()][:parsing] [1:33:38][Include handmade_hht.cpp everywhere necessary, and clean up compile errors][:parsing] [1:39:43][Make hhaedit call ParseHHT() on intro_cutscene.hht, changing ReadEntireFile() to return a string][:"asset system" :"file io" :parsing] [1:48:01][Step through ParseHHT() to see what it does][:parsing :run] [1:49:13][Add the "plate" keyword to ParseTopLevelBlock()][:parsing] [1:49:29][Continue to step through ParseHHT()][:parsing :run] [1:50:08][Encounter an apparent ~4coder bug in which some contents of intro_cutscene.hht is missing][:admin] [1:52:26][Continue to step through ParseHHT() to completion][:parsing :run] [1:53:16][:Run the parser on base_game.hht and hit a (correctly handled) error][:parsing] [1:53:50][Enable ParseTopLevelBlock() to handle the "default" block specially][:parsing] [1:54:58][:Run the parser to completion] [1:55:12][Q&A][:speech] [1:55:46][@Miblo][Q: Could the ~4coder bug be at all related to your in-comment calculator?] [1:55:56][@longboolean][Q: Now that we are using this method to assign tags, does this change how you plan to organize lots of little items on a sheet that may have differing, non sheet-wide tags, and in cases where using significance of positioning in the sprite sheet is too limiting? For example, maybe a collection of different fauna, each plant may have different tags for attributes, but can not be easily put into categories][:"asset system" :parsing] [1:56:55][@jessef][Q: What are some advanced :parsing features that are interesting to you but may be too much work / not necessary for [~hero Handmade Hero]?] [1:59:39][@sgtrumbi][Q: Wnat] [1:59:56][@xxthebigfoxx][Q: Are there things that recursive descent is not good for, or does it cut it for most of the :parsing stuff?] [2:01:39][@s0imn][Q: What is your opinion of the Vulkan :API, and its future?] [2:01:59][@ivereadthesequel][Q: I wasn't here for all of today's stream, but is RequireToken() what you'd use for lookahead (or a peektoken), ensuring you have an upcoming series of tokens to be of a specific form before you process those tokens?][:language :parsing] [2:06:57][Bow out gracefully][:speech] [/video]