From b012e557f0b85d69d343b4cf7088ca630601d11d Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 27 Aug 2019 00:26:02 -0700 Subject: [PATCH] Add small improvements to the small improvements post. --- content/blog/04_compiler_improvements.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/content/blog/04_compiler_improvements.md b/content/blog/04_compiler_improvements.md index fe795d1..6b90e07 100644 --- a/content/blog/04_compiler_improvements.md +++ b/content/blog/04_compiler_improvements.md @@ -69,7 +69,7 @@ but we don't need indentation, or recursion: {{< codelines "C++" "compiler/04/ast.cpp" 116 121 >}} Let's print the bodies of each function we receive from the parser: -{{< codelines "C++" "compiler/04/main.cpp" 35 50 >}} +{{< codelines "C++" "compiler/04/main.cpp" 44 53 >}} ### Printing Types Types are another thing that we want to be able to inspect, so let's @@ -83,11 +83,13 @@ The implementation is simple enough: Let's also print out the types we infer. We'll make it a separate loop in the `typecheck_program` function, because it's mostly just -for debugging purposes. +for debugging purposes: +{{< codelines "C++" "compiler/04/main.cpp" 34 38 >}} ### Fixing Bugs We actually discover not one, but two bugs in our implementation thanks -to this output. Observe the output for `works3.txt`: +to the output we get from printing trees and types. +Observe the output for `works3.txt`: ``` length l: CASE: @@ -127,7 +129,8 @@ We replace the fragment with the proper reverse iteration: ### Setting up CMake -This would be extremely easy if not for Flex and Bison. We start with the usual: +We will set up CMake as our build system. This would be extremely easy +if not for Flex and Bison, but it's not hard either way. We start with the usual: {{< codelines "CMake" "compiler/04/CMakeLists.txt" 1 2 >}} Next, we want to set up Flex and Bison. CMake provides two commands for this: