From b032f455b035458089fd7317497b928ead777d6b Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Sun, 25 Mar 2018 23:44:48 +0100 Subject: [PATCH] Annotate bitwise003 --- pervognsen/bitwise/bitwise/bitwise003.hmml | 71 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/pervognsen/bitwise/bitwise/bitwise003.hmml b/pervognsen/bitwise/bitwise/bitwise003.hmml index a1da344..33a1b8d 100644 --- a/pervognsen/bitwise/bitwise/bitwise003.hmml +++ b/pervognsen/bitwise/bitwise/bitwise003.hmml @@ -1,2 +1,69 @@ -[video member=pervognsen stream_platform=twitch project=bitwise title="More Programming & Parsing" vod_platform=youtube id=L4P98pGhpnE annotator=] -[/video] \ No newline at end of file +[video member=pervognsen stream_platform=twitch project=bitwise title="More Programming & Parsing" vod_platform=youtube id=L4P98pGhpnE annotator=Miblo] +[0:10][Recap and set the stage for the day, pointing out the homework from yesterday[ref + site=GitHub + page="pervognsen / bitwise / Day 2: C Programming & Parsing (March 14, 2018)" + url=https://github.com/pervognsen/bitwise/blob/master/notes/streams.md#day-2-c-programming--parsing-march-14-2018]][:speech] +[4:27][A note on the pull request policy][:speech] +[7:01][Point out off-stream fixes to xmalloc() and buf_free(), assertion additions to buf_test() and start-end range for everything in the Token struct][:memory :research] +[10:01][Note the reason for the alphabetical switch statement in next_token()][:parsing :research] +[12:28][Check out the :asm for the switch statement, to illustrate its efficacy over a loop][:parsing :run] +[14:47][All the C data structures you'll ever need: 1. Stretchy buffers; 2. Pointer / uintptr hash tables; 3. String intern table][:language :speech] +[16:47][String interning][:parsing :speech] +[23:13][Introduce str_intern_range() to work on a global interning table][:parsing] +[30:36][Note the reason for doing *str rather than str\[0\]][:parsing :speech] +[32:12][Introduce str_intern() as a slow version][:parsing] +[33:18][Fix up our buf_push() call in str_intern_range(), with a few words on the C preprocessor's parenthesis counting capabilities][:memory] +[35:13][Introduce str_intern_test()][:parsing] +[36:15][Step through str_intern_range() to see what it does][:parsing :run] +[37:10][Make str_intern_test() call str_intern() on our two strings on separate lines][:parsing] +[37:47][Step in to str_intern_test() to see that str_intern_range() didn't return anything][:parsing :run] +[37:52][Make str_intern_range() return the str][:parsing] +[38:30][Continue to step through str_intern_test() to see that it works][:parsing :run] +[38:39][Augment str_intern_test() with more testing][:parsing] +[39:19][Step through str_intern_test() to see that it works correctly][:parsing :run] +[39:26][A few words on this ptr testing][:parsing :speech] +[40:50][Add a name to the Token struct and duplicate a substring of our test string in lex_test()][:parsing] +[42:29][Step in to next_token() and inspect the interned strings][:parsing :run] +[45:02][Introduce init_keywords()][:parsing] +[48:11][Q&A][:speech] +[50:15][Why are you using string interns?][:authored :parsing] +[50:56][Would you recommend using this technique in most languages, or is it just C?][:authored :language :parsing] +[53:41][Why not just use a stretchy buffer instead of the intern str stuff?][:authored :memory :parsing] +[54:37][buf\[0\] is a nonstandard extension][:authored :language] +[55:36][Introduce the standard set of functions for :parsing: is_token(), is_token_name(), match_token() and expect_token()] +[1:01:29][Introduce fatal()[ref + site=cppreference.com + page=va_start + url=http://en.cppreference.com/w/cpp/utility/variadic/va_start]] +[1:05:19][Introduce token_kind_name()][:parsing] +[1:09:36][Introduce parse_test(), parse_expr() and its layers of accompanying functions, as a usage example of our parser][:parsing] +[1:23:38][Step in to parse_expr() to see what it does][:parsing :run] +[1:24:41][Introduce test_parse_expr() and enable parse_test() to perform more tests] +[1:26:02][Step in to parse_test() to see what it does][:parsing :run] +[1:26:52][Add a test for "!" in parse_test()][:parsing] +[1:27:46][Step in to parse_test() and correctly receive the error upon finding the '!' character][:parsing :run] +[1:28:15][Add a test for "(1)" in parse_test()][:parsing] +[1:28:24][Step in to parse_test() to see how that works][:parsing :run] +[1:29:00][Make the parse_expr() functions return their evaluated result][:parsing] +[1:34:56][Step in to parse_test() to see that it works][:parsing :run] +[1:35:02][Add some precedence, unary and parenthesis checks in parse_test(), according to C's own evaluations][:parsing] +[1:39:17][Step through parse_test() to see that it does something][:parsing :run] +[1:39:38][Set the homework[ref + site=GitHub + page="pervognsen / bitwise / Day 3: More Programming & Parsing (March 15, 2018)" + url=https://github.com/pervognsen/bitwise/blob/master/notes/streams.md#day-3-more-programming--parsing-march-15-2018]][:speech] +[1:45:50][Q&A][:speech] +[1:46:19][@nothings2][@pervognsen Should the grammar be 'expr2 = expr3 | -expr2' to allow for "- - 5"?][:language :parsing] +[1:46:27][Fix parse_expr2() to return -parse_expr2() if it matches the '-' character][:parsing] +[1:48:00][The homework seems kind of daunting][:authored] +[1:49:15][@xanatos387][@pervognsen You've used the phrase "left-fold" several times tonight. What does that refer to?] +[1:53:19][@elavid][@gargltk Yes, grammar is broken right now, doesn't use expr3][:language :parsing] +[1:54:34][@captainkraft][@pervognsen If you were on Linux, would you use gdb to frequently run the code through the debugger, use a different debugger, or use some other method entirely?] +[1:55:18][There's a typo in the Wirth book[ref + author="Niklaus Wirth" + title="Compiler Construction" + url=https://www.inf.ethz.ch/personal/wirth/CompilerConstruction]][:authored] +[1:57:32][A few words on not having solved the entire homework on stream][:parsing :speech] +[1:59:11][@teluial][@pervognsen Also are you going to develop within the VM later on when cross-compiling isn't necessary] +[2:00:00][Stop the stream][:speech] +[/video]