[video member=pervognsen stream_platform=twitch project=bitwise title="C Programming & Parsing" vod_platform=youtube id=0woxSWjWsb8 annotator=Miblo] [0:01][Recap and set the stage for the day, with a recommendation to read Chapter 2 through 4.1 of Wirth's 'Compiler Construction'[ref author="Niklaus Wirth" title="Compiler Construction" url=https://www.inf.ethz.ch/personal/wirth/CompilerConstruction]][:language :parsing :speech] [3:05][Dive in to ion.c, with a few words about debugger-centric workflow][:language] [12:42][Introduce stretchy buffers, invented by [@nothings Sean Barrett]][:memory] [18:28][Introduce BufHdr struct and the buf__hdr(), buf__fits(), buf__fit(), buf_len(), buf_cap() and buf_push() macros][:memory] [28:15][Introduce buf__grow(), buf_free() and MAX()][:memory] [38:55][Step in to buf_push() and inspect the buf][:memory :run] [40:14][Enable buf__grow() to include the BufHdr in the reallocation][:memory] [42:06][Step back in to buf_push() and inspect the buf][:memory :run] [43:32][Fix buf__grow() to return the new_hdr->buf][:memory] [47:33][Step through a loop of buf_push()][:memory :run] [49:11][@chargrove_dev][@pervognsen Here's another poke to check your stream z-order; your camera is behind the IDE] [49:37][@asafgartner][@pervognsen (1) There's a lot of audio buzzing. (2) Visual Studio is on top of your webcam. (3) We can't see menus in VS] [50:26][@normalnull_][@pervognsen One idea, designate one trusted helper who is able to ping you while you ignore regular chat for hints like audio issues or window switching or whatever] [51:20][@manokara][Dedicated capture hardware is better so your CPU doesn't struggle with encoding and streaming] [51:33][@captainkraft][@pervognsen Why use macros for this instead of functions?] [51:37][@garretttypes][@pervognsen Line 17, shouldn't "buf" be just "b"?] [51:48][Fix buf__hdr() to operate on b rather than buf][:memory] [53:10][@danbokser][@pervognsen For buf__hdr it looks like you're using buf instead of b] [54:04][Could you add more functions like reserve()?][:authored :memory] [54:32][Loft our code out into buf_test()][:memory] [54:50][@symbolic_butt][@pervognsen This is kind of similar to the implementation of lists in cpython right?][:language] [55:42][@onebloke][@pervognsen The menus and pop up windows cannot be seen] [56:13][@manokara][Is it me or is the mic lower than yesterday?] [57:05][@satire_][What's the reasoning for using macros vs functions for most of the stuff?] [58:47][@zxsnkx][Connection here is unreliable... Will have to catch this later on YouTube] [59:08][@manokara][Jesus, is that coke?] [59:37][@manokara][But I think it's a bit too acidic to hydrate] [59:50][Introduce lexing, with a TokenKind enum and Token struct][:parsing] [1:03:29][Introduce the notion of a global state machine, with next_token()][:parsing] [1:06:35][Introduce lex_test() with a few words on this testing approach][:parsing] [1:08:21][Step into lex_test() to see what it does][:parsing :run] [1:08:41][Set TokenKind to start at 128][:parsing] [1:08:56][Continue to step through lex_test()][:parsing :run] [1:10:16][Augment the Token struct with semantic information, and implement string to integer conversion][:parsing] [1:12:28][Step in to lex_test() to see if that worked, waxing lyrical on Ctrl-F10 for stepping through the loop][:parsing :run] [1:13:34][Introduce identifier :parsing with cases for every letter in the alphabet, including print_token(), with a few words on ] [1:19:59][A few words on printf()'s .* pattern to specify the number of bytes to print][:speech] [1:20:33][Let lex_test() test alphabetical characters and finish implementing print_token()][:parsing] [1:25:14][Step in to lex_test() to see how the identifier stuff shakes out][:parsing :run] [1:26:07][Revert print_token() to use printf()] [1:26:27][Step in to lex_test() and note Visual Studio's ability to let us specify how many bytes of the string to print][:parsing :run] [1:28:52][Prevent print_token() from falling through the entire switch statement] [1:29:12][Continue to step through lex_test() to see how it works][:parsing :run] [1:29:47][A few words on our basic lexer, before stopping the recording][:parsing :speech] [/video]