[video output=day206 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Implementing Introspection" vod_platform=youtube id=1IwYEJsvdcs annotator=Miblo annotator=Kelimion] [0:32][Recap and set the stage for the day] [3:45][simple_preprocessor.cpp: Introspection] [6:25][simple_preprocessor.cpp: Name this function ReadEntireFileIntoMemoryAndNullTerminate] [7:16][simple_preprocessor.cpp: Call this function to run on handmade_sim_region.h and build it up] [9:00][build.bat: Add simple_preprocessor.cpp] [9:45][Debugger: Step into simple_preprocessor.cpp and ensure that it works as expected] [10:51][simple_preprocessor.cpp: Null terminate the file] [11:19][handmade.h: #define introspect] [12:31][handmade_sim_region.h: Use this introspect macro] [12:42][Brown butter][quote 274] [13:16][Describe tokens] [14:58][simple_preprocessor.cpp: Introduce token structures] [16:41][simple_preprocessor.cpp: Loop over the Tokens and print them out] [20:18][simple_preprocessor.cpp: Introduce struct tokenizer] [21:20][simple_preprocessor.cpp: Introduce EatAllWhitespace] [23:09][Get a little brained][quote 275] [28:06][simple_preprocessor.cpp: Provide a way to parse identifiers] [29:20][simple_preprocessor.cpp: Move GetToken's functionality to the correct place and write EatAllWhitespace] [31:13][simple_preprocessor.cpp: Provide the ability to parse C-style comments and introduce IsEndOfLine] [34:36][simple_preprocessor.cpp: Introduce IsAlpha and IsNumeric] [35:57][simple_preprocessor.cpp: Handle unknown tokens] [37:00][simple_preprocessor.cpp: Skip the closing quote] [38:47][simple_preprocessor.cpp: Implement ParseIdentifier] [40:09][Debugger: Step into simple_preprocessor.cpp and inspect the Tokenizer] [41:07][simple_preprocessor.cpp: Handle skipping over the first character] [42:33][Debugger: Step back in and inspect the Token] [43:30][Run the preprocessor and look at its output] [44:09][simple_preprocessor.cpp: Introduce ParseIntrospectable] [45:29][simple_preprocessor.cpp: Introduce TokenEquals] [48:08][Debugger: Step in to TokenEquals] [48:51][simple_preprocessor.cpp: Check for the string "intr"] [49:37][Debugger: Step through the loop inspecting At and Index] [50:51][simple_preprocessor.cpp: Implement ParseIntrospectable] [53:11][simple_preprocessor.cpp: Introduce ParseIntrospectionParams] [53:54][simple_preprocessor.cpp: Introduce ParseStruct] [55:17][simple_preprocessor.cpp: Introduce ParseMember] [56:04][simple_preprocessor.cpp: Introduce RequireToken] [56:59][simple_preprocessor.cpp: Provide the ability to print out the DEBUG_VALUE] [1:00:43][Run the preprocessor and see what happens] [1:01:55][Q&A][:speech] [1:02:52][@paulsm1th][It seems like you are doing recursive descent parsing. Is that how you would describe it?] [1:03:35][Blackboard: Recursive Descent Parser] [1:05:04][simple_preprocessor.cpp: Introduce a more recursive example of ParseMember] [1:09:17][@Pseudonym73][Can you please satisfy my C standard anal retention by accepting 'v' and 'f' as whitespace?] [1:10:10][@garryjohanson][Have you an opinion on OpenCLC? Would that be out of bounds for Handmade Hero?] [1:10:31][@insofaras][How would you handle errors if you were deep in the recursion? Is checking return values everywhere the best way?] [1:11:18][@radlabgaming][I showed up late. Can you explain what introspection is?] [1:16:22][@Popcorn0x90][Do you if Jon does "metaprogramming" for his language?] [1:17:12][@insofaras][Regarding errors again, would this be a place where exceptions would actually be useful?] [1:18:00][@evraire][Now that we have the preprocessor, do you plan to make more use of it going forward in Handmade Hero?] [1:18:18][@hoganlong][Who is Jon and what language are you talking about?] [1:18:39][@cvaucher][I'm writing a parser that looks pretty similar to this, but it runs on multi-GB files which takes a while. Any common approaches to use SIMD/multithreading to speed up text parsing? Seems more difficult since the characters aren't "independent" in the way pixels are] [1:20:18][@desophos][This stream makes me feel like an extremely inferior and incompetent programmer. Do you approve of this?] [1:22:58][@paulsm1th][How does metaprogramming change your workflow? Can you talk about incorporating generated code with the "regular" C files?] [1:25:52][Wrap up][:speech] [/video]